Skip to content

Make TopologySeafloorGrid the class, and SeafloorGrid its deprecated alias - #469

Merged
jcannon-gplates merged 2 commits into
masterfrom
topology-seafloor-grid
Oct 2, 2026
Merged

jcannon-gplates merged 2 commits into
masterfrom
topology-seafloor-grid

Conversation

@jcannon-gplates

@jcannon-gplates jcannon-gplates commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

TopologySeafloorGrid (added in 129f018, the commit that created grids/) subclassed SeafloorGrid only to give it a generate() named like IsochronSeafloorGrid's. So grids/oceans.py was the topology gridder under another name, and topology_seafloor_grid.py held a single forwarding method.

  • TopologySeafloorGrid is now the class. The implementation moves from grids/oceans.py into grids/topology_seafloor_grid.py, with generate() included and unchanged. grids/oceans.py is deleted.
  • There is no shared base class. The two gridders share no code, and their generate() methods take different arguments, so a base class would only document a coincidence. Each has its own generate().
  • SeafloorGrid has been public since GPlately 1.x, so it stays as a deprecated alias. It is the same class as TopologySeafloorGrid, so isinstance checks work with either name. A module-level __getattr__ (PEP 562) raises the DeprecationWarning whenever the name is looked up, including when unpickling an object pickled under the old name. It isn't in __all__, so from gplately import * doesn't warn. Its old module paths still work, both as imports and as attributes:
    • from gplately.oceans import SeafloorGrid;
    • from gplately.grids.oceans import SeafloorGrid, which 2.1.0rc0 had.
  • The netCDF metadata_source attribute stays "GPlately.SeafloorGrid", so output files are unchanged.
  • Updated to TopologySeafloorGrid: the CLI, the tests, the docs (use_cases.rst, examples.rst), Notebooks/README.md and CLAUDE.md. api.rst drops gplately.SeafloorGrid, whose page would only duplicate TopologySeafloorGrid's. The 2.1.0 release notes gain a bullet covering both gridders.

Interaction with #413: #413 modifies grids/oceans.py. The merge base also has a topology_seafloor_grid.py, so git sees a delete and a rewrite here rather than a rename. Merging this into #413 will therefore be a modify/delete conflict on oceans.py, to be resolved by porting #413's changes into the renamed file. I'll do that when I next merge master into #413.

Testing

On Windows, Python 3.13:

  • tests-dir/pytestcases: 246 passed and 12 skipped. The skips are the raster tests that the default test level leaves out.
  • A new test checks that SeafloorGrid is TopologySeafloorGrid, warns on every lookup (directly, by import, and through both old module paths, as imports and as attributes), and that the current name doesn't warn.
  • Also checked by hand: isinstance holds both ways, inspect.signature(SeafloorGrid) shows the real parameters, and pickles naming gplately.oceans.SeafloorGrid or gplately.grids.oceans.SeafloorGrid load as TopologySeafloorGrid.
  • The Sphinx docs, built from scratch for master and this branch: no warnings in either. The TopologySeafloorGrid page now renders the class docstring's links and three images; they were Markdown, left over from the pdoc docs, and rendered as literal text. The use_cases.rst example also had two lines indented one space too far, which made it fail with IndentationError when copied. That's fixed, and it calls generate().
  • The CLI config topology-seafloor-gridding-1.toml, run through this branch, wrote all 18 grids, the same as before.

🤖 Generated with Claude Code

https://claude.ai/code/session_012j73LisSSEedpvtr4odRCG

jcannon-gplates and others added 2 commits October 1, 2026 14:59
…alias

TopologySeafloorGrid subclassed SeafloorGrid only to give it a
generate() named like IsochronSeafloorGrid's, so oceans.py was really
the topology gridder under another name. The implementation now lives
in grids/topology_seafloor_grid.py as TopologySeafloorGrid (generate()
included, unchanged), and grids/oceans.py is gone. There is no shared
base class: the two gridders share no code and their generate() methods
take different arguments.

SeafloorGrid is public since GPlately 1.x, so it stays as a subclass
that warns on construction, and both of its old import paths keep
working (gplately.oceans, and gplately.grids.oceans from 2.1.0rc0).
The netCDF metadata_source attribute stays "GPlately.SeafloorGrid", so
output files don't change.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j73LisSSEedpvtr4odRCG
…lookup

From a review of this PR. As a subclass, SeafloorGrid made
isinstance(TopologySeafloorGrid(...), SeafloorGrid) False (True on
master), and hid the constructor's signature behind *args/**kwargs.
It's now the same class object, served by a module __getattr__ (PEP
562) in gplately and in topology_seafloor_grid that raises the
DeprecationWarning on every lookup of the name, not just construction,
so SeafloorGrid.SEAFLOOR_AGE_KEY users see it too. That also covers old
pickles, which find the class through the same lookup. It's out of
__all__, so 'from gplately import *' doesn't warn.

Also from the review:
- gplately.grids.oceans (2.1.0rc0) worked as an import but not as an
  attribute; the grids package's __getattr__ now returns it, and the
  same for gplately.oceans (that gap predates this PR).
- The alias test built a grid in the shared fixture's directory, which
  the constructor clears; it now checks identity and warnings only.
- api.rst drops SeafloorGrid (its page would duplicate this one); the
  class docstring's pdoc-era Markdown links and images are now
  reStructuredText, so they render; the use_cases example's indentation
  is fixed and it calls generate().

Docs built from scratch for master and this branch: no warnings in
either, and the TopologySeafloorGrid page now shows its images.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012j73LisSSEedpvtr4odRCG
@jcannon-gplates

jcannon-gplates commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor Author

Hi @michaelchin, this reworks part of the grids/ layout from 129f018: TopologySeafloorGrid becomes the class itself (moved from oceans.py), rather than a SeafloorGrid subclass that adds generate(). SeafloorGrid stays as a deprecated alias, so existing code keeps working. Could you check it fits what you intended for the two gridders? (There's no shared base class, since they share no code.)

If you're happy then I'll merge it.

Note: Michael approved this via email (2nd Oct).

@jcannon-gplates
jcannon-gplates merged commit 479ce55 into master Oct 2, 2026
20 checks passed
@jcannon-gplates
jcannon-gplates deleted the topology-seafloor-grid branch October 2, 2026 05:46
jcannon-gplates added a commit that referenced this pull request Oct 2, 2026
#469 moved SeafloorGrid from grids/oceans.py into grids/topology_seafloor_grid.py
as TopologySeafloorGrid (SeafloorGrid is now its deprecated alias). Git saw a
modify/delete on oceans.py rather than a rename, so this branch's oceans.py
changes are ported into topology_seafloor_grid.py by hand: the single
ReconstructByTopologies path, the deprecated subduction_collision_parameters,
reconstruct_by_topological_model() as a deprecated alias, and the deprecated
use_topological_model argument of generate() (now on the class itself, so
super() becomes self). oceans.py is deleted.

The 2.1.0 release-note bullet for #413 now names TopologySeafloorGrid.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant