Fix broken doctests in geotensor module#48
Open
toadlyBroodle wants to merge 1 commit into
Open
Conversation
Several doctests in geotensor.py were failing: - 9 examples used `from georeader import GeoTensor` but GeoTensor is not exposed at the package level. Changed to the canonical `from georeader.geotensor import GeoTensor` (matches the rest of the codebase). - 6 examples referenced `transform` and `crs` without defining them. Added explicit setup with `rasterio.Affine` and an EPSG string. - `__add__` and `isel` print examples lacked or had wrong expected output. Updated to match actual repr (float coords, etc). - `footprint` had several aspirational examples (load_file with fake paths, writing files). Reworked to use checked output for runnable examples and marked file-dependent lines with +SKIP. - `resize` examples are marked +SKIP because skimage is an optional dep. - `concatenate` example was calling a bare `concatenate(...)` function instead of the classmethod `GeoTensor.concatenate(...)`. Also: - Add `doctest_optionflags = ["ELLIPSIS", "NORMALIZE_WHITESPACE"]` to pyproject.toml so doctest output comparisons tolerate whitespace and truncated reprs. - Add `make test-doctest` target to run doctests on geotensor.py. After: 17 passed, 1 skipped (resize, optional skimage dep). Before: 17 failed, 1 passed. Refs spaceml-org#40
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.
Fix broken doctests in geotensor module
Refs #40. Re-targets the doctest-fix portion of #45 against
feature/geotensor_npapiper maintainer request.Summary
Running
pytest --doctest-modules georeader/geotensor.pyonfeature/geotensor_npapifails on 17 of 18 examples. This PR fixes the breakages, addsmake test-doctest, and configures default doctest flags.Before:
17 failed, 1 passedAfter:
17 passed, 1 skipped(resize, depends on optionalskimage)Changes
Import path
from georeader import GeoTensor, butGeoTensoris not exposed at the package level. Changed tofrom georeader.geotensor import GeoTensorto match the canonical import used everywhere else in the codebase (abstract_reader.py,save.py,mosaic.py,read.py, etc.).Missing setup
expand_dims,pad_array,resize,transpose,write_from_window,concatenate) referencedtransformandcrswithout defining them, raisingNameError. Added explicit setup usingrasterio.Affine(...)and an EPSG string.Mismatched expected output
GeoTensor.__add__:print(gt_offset.shape)had no expected output line. Added(3, 100, 100).GeoTensor.isel: expected(500000, 4650000)but actual repr is(500000.0, 4650000.0). Updated.Aspirational examples
GeoTensor.footprinthad 6 examples; some used fakeload_file('image1.tif')paths or wrote files. Reworked: examples 1, 2, 5, 6 now use real checked output; file-dependent lines in examples 3 and 4 marked# doctest: +SKIP.GeoTensor.resizerequiresskimage(optional dependency). Marked example+SKIP.Other fixes
GeoTensor.concatenateexample called bareconcatenate(...)instead of the classmethodGeoTensor.concatenate(...). Fixed.GeoTensor.pad_arrayexample asserted ongt.shapeinstead of the returned padded tensor. Fixed.Tooling
pyproject.toml: addeddoctest_optionflags = ["ELLIPSIS", "NORMALIZE_WHITESPACE"]so future doctests tolerate whitespace and truncated reprs.Makefile: addedmake test-doctesttarget.Scope
Only
georeader/geotensor.pyis touched.rasterio_reader.pyandio.pyalso have failing doctests (file-path dependent), but most of their examples would need per-line+SKIPmarkers that obscure the docs. Happy to address them in a follow-up if you'd prefer.Test results
Existing test suite unaffected.