Repository navigation
Make TopologySeafloorGrid the class, and SeafloorGrid its deprecated alias - #469
Merged
Merged
Conversation
…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
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
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TopologySeafloorGrid(added in129f018, the commit that createdgrids/) subclassedSeafloorGridonly to give it agenerate()named likeIsochronSeafloorGrid's. Sogrids/oceans.pywas the topology gridder under another name, andtopology_seafloor_grid.pyheld a single forwarding method.TopologySeafloorGridis now the class. The implementation moves fromgrids/oceans.pyintogrids/topology_seafloor_grid.py, withgenerate()included and unchanged.grids/oceans.pyis deleted.generate()methods take different arguments, so a base class would only document a coincidence. Each has its owngenerate().SeafloorGridhas been public since GPlately 1.x, so it stays as a deprecated alias. It is the same class asTopologySeafloorGrid, soisinstancechecks work with either name. A module-level__getattr__(PEP 562) raises theDeprecationWarningwhenever the name is looked up, including when unpickling an object pickled under the old name. It isn't in__all__, sofrom 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.metadata_sourceattribute stays"GPlately.SeafloorGrid", so output files are unchanged.TopologySeafloorGrid: the CLI, the tests, the docs (use_cases.rst,examples.rst),Notebooks/README.mdandCLAUDE.md.api.rstdropsgplately.SeafloorGrid, whose page would only duplicateTopologySeafloorGrid'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 atopology_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 onoceans.py, to be resolved by porting #413's changes into the renamed file. I'll do that when I next mergemasterinto #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.SeafloorGridisTopologySeafloorGrid, 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.isinstanceholds both ways,inspect.signature(SeafloorGrid)shows the real parameters, and pickles naminggplately.oceans.SeafloorGridorgplately.grids.oceans.SeafloorGridload asTopologySeafloorGrid.masterand this branch: no warnings in either. TheTopologySeafloorGridpage now renders the class docstring's links and three images; they were Markdown, left over from the pdoc docs, and rendered as literal text. Theuse_cases.rstexample also had two lines indented one space too far, which made it fail withIndentationErrorwhen copied. That's fixed, and it callsgenerate().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