fix: matplotlib 3.10 compatibility + baseline toolkit unit tests refs #943#968
Open
ilayfalach wants to merge 4 commits into
Open
fix: matplotlib 3.10 compatibility + baseline toolkit unit tests refs #943#968ilayfalach wants to merge 4 commits into
ilayfalach wants to merge 4 commits into
Conversation
ContourSet.collections was removed in matplotlib 3.10 (ContourSet now inherits
from Collection directly). Replace the old collections iteration with
ContourData.get_paths() which works in both old and new matplotlib:
- Old (<3.10): zip(ContourData.collections, levels) with inner col.get_paths()
- New (>=3.10): zip(ContourData.get_paths(), levels) directly
Also fix a pre-existing inverted condition: `inunits if inunits is None` was
always passing None to unumToPint; corrected to `inunits if inunits is not None`.
Add 16 pytest tests in test_matplotlibContour.py covering:
- standardize_polygon (array input, scaling, list-of-tuples)
- toGeopandas output structure (GeoDataFrame, columns, geometry type, validity,
level count, level values)
- toGeopandas geometry correctness (nonzero area, unit conversion scaling)
- matplotlib compatibility (no DeprecationWarning, new API confirmed in >=3.10,
edge case with only 2 levels)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Mark all four test classes with @pytest.mark.unit — they use only in-memory matplotlib/shapely objects with no external dependencies. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds test_toolkit_coverage.py with 34 @pytest.mark.unit tests covering: - TopographyToolkit.convertPointsCRS (CRS transform, roundtrip, type check) - topographyAnalysis.calculateStastics (mean, size, max/min locations) - LSMTemplate.prepareParams (passthrough, duration, TopoXn int-cast) - OFToolkit.processorList + Presentation.to_paraview_CSV (glob, CSV output) - BriggsRural.getSigma (formula accuracy, monotonicity, all stability classes) - MeteoAnalysis.addDatesColumns (season labels, HHMM time, index fallback) All tests run without MongoDB; optional OF dependencies mocked at sys.modules. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…943 hasattr(ContourData, 'collections') returns True on matplotlib 3.8/3.9 but accessing .collections immediately raises MatplotlibDeprecationWarning (a DeprecationWarning subclass), causing test_no_deprecation_warning to fail on CI (matplotlib 3.8). Switch to explicit version comparison: use get_paths() for mpl >= 3.8 (deprecated there, removed in 3.10); fall back to .collections only for mpl < 3.8 where it is the stable API. Co-Authored-By: Claude Sonnet 4.6 <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.
Summary
inunitsinversion bug inhera/utils/matplotlibCountour.py(inunits if inunits is not None else 1*ureg.m)ContourSet.collectionswas removed; now usesget_paths()fallback viahasattrcheck@pytest.mark.unittests across two files:test_matplotlibContour.py(16 tests) — toGeopandas structure, geometry, unit conversion, matplotlib version compatibilitytest_toolkit_coverage.py(34 tests) — baseline I/O regression coverage for TopographyToolkit, LSMTemplate, OFToolkit, BriggsRural (Gaussian), and LowFreq meteorology analysis; all run without MongoDBTest plan
pytest hera/tests/test_matplotlibContour.py hera/tests/test_toolkit_coverage.py -v— 50 passedpytest hera/tests/ -m unit— zero MongoDB errorsCloses #943
🤖 Generated with Claude Code