Skip to content

Added CI workflow, fixed data_vars bug, expanded tests, added API docs, and notebook runner.#117

Closed
GauravSRC wants to merge 3 commits intoioos:mainfrom
GauravSRC:gsoc/ci-tests-docs-bugfix
Closed

Added CI workflow, fixed data_vars bug, expanded tests, added API docs, and notebook runner.#117
GauravSRC wants to merge 3 commits intoioos:mainfrom
GauravSRC:gsoc/ci-tests-docs-bugfix

Conversation

@GauravSRC
Copy link

Summary

This PR makes several related improvements to the project's infrastructure
and code quality, motivated by #108.

Changes

Bug Fix

  • xarray_subset_grid/accessor.py: Fixed a bug in the data_vars
    property where self._ds was checked instead of self._grid. When no
    grid implementation recognises the dataset, self._grid is None, and
    the previous code would call None.data_vars(ds), raising an
    AttributeError. The fix is a single-line change to check self._grid.

CI / GitHub Actions

  • .github/workflows/ci.yml: Adds a test workflow that runs on every
    push and pull request to main. It tests against Python 3.10, 3.11, and
    3.12 on Ubuntu, Windows, and macOS. Coverage is reported to Codecov from
    the Ubuntu/3.12 runner.

Tests

  • tests/test_accessor.py: New test file covering accessor presence,
    grid recognition, all accessor properties (including a regression test for
    the data_vars bug), and subsetting methods (subset_bbox,
    subset_polygon, subset_vars, subset_surface_level).
  • tests/test_utils.py: Expanded with two new tests for the
    compute_2d_subset_mask utility function.

Documentation

  • docs/api.rst: New page with autodoc entries for the accessor,
    grid, selector, and utils modules.
  • docs/index.rst: Updated toctree to include the new API reference page.

Testing

All offline tests pass locally:

- Fix data_vars bug in GridDatasetAccessor: was checking self._ds
  instead of self._grid, causing AttributeError when no grid recognised
- Add .github/workflows/ci.yml: runs pytest on Python 3.10/3.11/3.12
  across Linux, Windows, and macOS with coverage reporting
- Add tests/test_accessor.py: covers accessor presence, grid recognition,
  property correctness (including data_vars regression test), and
  subsetting methods
- Expand tests/test_utils.py: add tests for compute_2d_subset_mask
- Add docs/api.rst: autodoc for accessor, grid, selector, and utils
- Update docs/index.rst to include the new api page
@GauravSRC GauravSRC marked this pull request as draft March 3, 2026 20:08
- Add tests/test_notebooks.py: discovers all .ipynb files in
  docs/examples/ and runs them via nbconvert in a subprocess.
  Follows the existing --online marker pattern from conftest.py:
  regular_grid_2d.ipynb (local data) runs offline; all other
  notebooks (OPeNDAP/THREDDS/S3) are marked @pytest.mark.online
  and skipped unless --online is passed.
- Update pyproject.toml: add nbconvert and ipykernel to dev deps
- Update ci.yml: install nbconvert and ipykernel in test environment
  so offline notebook test runs automatically in CI
@GauravSRC GauravSRC changed the title Added CI workflow, fixed data_vars bug, expanded tests and added API docs Added CI workflow, fixed data_vars bug, expanded tests, added API docs, and notebook runner. Mar 3, 2026
@GauravSRC GauravSRC closed this Mar 3, 2026
@GauravSRC GauravSRC deleted the gsoc/ci-tests-docs-bugfix branch March 3, 2026 21:08
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.

1 participant