-
Notifications
You must be signed in to change notification settings - Fork 46
Base class for IO test files #1331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…asset :), keeping GeoPandas, Structured and HEALPix as they are different and just file format reading/writing, geopandas uses Grid.from_file() unlike others
philipc2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great. I like the idea of centralized tests for all grid formats.
Though, I still would like to have separate modules (i.e. test_mpas) instead of putting all in one module.
Maybe something like the following structure?
- Create a base set of tests we can run on all grid formats (similar to what you've done), which can be imported and used within each of the individual modules. This would still allow us to add extra tests via inheritance if needed.
…array into rajeeja/io_test_consolidation
I have made this change, but I like the one-module design is better. It is typically the case that one reader-writer breaks the others, and we don't test it. If needed, we can always run a part of the tests from that one module. |
I'm open to having a one-module design, especially one that tests basic functionality like you've shown, including
However, for grid-specific tests (i.e. HEALPix or MPAS), it still makes sense to me to keep the existing modules, which would test extra functionality on top of the standard set in the suite you created. |
- Revert format-specific test files to original state - Add new test_io_common.py with common IO tests across all formats - Remove complex inheritance structure - Keep flat test structure as requested - Tests cover: basic read, UGRID compliance, error handling, lazy loading - All format-specific tests remain in their original files
|
adding only test_io_common.py for shared IO functionality while keeping all format-specific tests unchanged. We should create a follow-up issue to reorganize the entire test suite into a hierarchical structure (mirroring uxarray's module organization), breaking down large files like test_geometry.py (60KB) into smaller, more manageable components. |
|
Thanks for the detailed review and comments. I have tried to keep the changes minimal in this pull request, addressed most of your comments. There might be some duplicated tests in individual I/O modules and this new test. But IMO that's okay for now. I think we can first do a complete reorganization of the test suite by folders and modules and let this pull request go first. |
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
| IO_READ_TEST_FORMATS = [ | ||
| ("ugrid", "ugrid/quad-hexagon", "grid.nc"), | ||
| ("ugrid", "ugrid/outCSne30", "outCSne30.ug"), | ||
| ("ugrid", "ugrid/outRLL1deg", "outRLL1deg.ug"), | ||
| ("mpas", "mpas/QU/480", "grid.nc"), | ||
| ("esmf", "esmf/ne30", "ne30pg3.grid.nc"), | ||
| ("exodus", "exodus/outCSne8", "outCSne8.g"), | ||
| ("exodus", "exodus/mixed", "mixed.exo"), | ||
| ("scrip", "scrip/outCSne8", "outCSne8.nc"), | ||
| ("icon", "icon/R02B04", "icon_grid_0010_R02B04_G.nc"), | ||
| ("fesom", "fesom/pi", None), # Special case - multiple files | ||
| ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we include HEALPix in here?
There's no grid file associated with it, but within our fixture below we can construct a basic one by doing:
grid = ux.Grid.from_healpix(zoom=1, pixels_only=False)Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
…from_healpix to IO_READ_TEST_FORMATS fixture; refactor tests to use fixture; check properties via grid.connectivity/coordinates; use np.issubdtype for dtype checks.
test/test_io_common.py
Outdated
| try: | ||
| import constants | ||
| except ImportError: | ||
| from . import constants |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this? I don't think is doing anything right now.
test/test_io_common.py
Outdated
| def test_lazy_loading(self, grid_from_format): | ||
| """Test that grids support lazy loading where applicable.""" | ||
| grid = grid_from_format | ||
|
|
||
| assert grid._ds is not None |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove this test?
Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
philipc2
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Other than my other comment, this looks great!
#1329 better performance and more maintainable, improved coverage.