Skip to content

Conversation

@rajeeja
Copy link
Contributor

@rajeeja rajeeja commented Aug 5, 2025

#1329 better performance and more maintainable, improved coverage.

…asset :), keeping GeoPandas, Structured and HEALPix as they are different and just file format reading/writing, geopandas uses Grid.from_file() unlike others
@rajeeja rajeeja requested review from erogluorhan and philipc2 August 5, 2025 23:49
Copy link
Member

@philipc2 philipc2 left a 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?

  1. 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.

@philipc2 philipc2 linked an issue Aug 6, 2025 that may be closed by this pull request
@rajeeja rajeeja changed the title Replace 7 scattered IO test files with unified test_io Base class for IO test files Aug 6, 2025
@rajeeja
Copy link
Contributor Author

rajeeja commented Aug 6, 2025

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?

  1. 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.

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.

@philipc2
Copy link
Member

philipc2 commented Aug 6, 2025

I have made this change, but I like the one-module design is better.

I'm open to having a one-module design, especially one that tests basic functionality like you've shown, including

  • Reading and Writing Grids
  • Checking UGRID compliance.

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.

Rajeev Jain and others added 3 commits August 13, 2025 23:03
- 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
@rajeeja
Copy link
Contributor Author

rajeeja commented Aug 14, 2025

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.

@rajeeja rajeeja requested a review from philipc2 August 14, 2025 04:14
@rajeeja
Copy link
Contributor Author

rajeeja commented Aug 14, 2025

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.

@rajeeja rajeeja requested a review from philipc2 August 15, 2025 22:34
rajeeja and others added 2 commits August 15, 2025 17:40
Co-authored-by: Philip Chmielowiec <67855069+philipc2@users.noreply.github.com>
Comment on lines 30 to 41
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
]
Copy link
Member

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>
rajeeja and others added 5 commits August 18, 2025 10:16
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.
Comment on lines 21 to 24
try:
import constants
except ImportError:
from . import constants
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajeeja

Can we remove this? I don't think is doing anything right now.

Comment on lines 147 to 151
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rajeeja

Can we remove this test?

Rajeev Jain and others added 2 commits August 18, 2025 14:15
rajeeja and others added 4 commits August 18, 2025 18:11
Copy link
Member

@philipc2 philipc2 left a 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!

@rajeeja rajeeja merged commit 2e68c1a into main Aug 20, 2025
19 of 20 checks passed
@erogluorhan erogluorhan deleted the rajeeja/io_test_consolidation branch September 26, 2025 17:47
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.

IO Test Overhaul

2 participants