Skip to content
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

Extract method _postprocess_dataset() and make bounds generation optional #223

Merged
merged 12 commits into from
Apr 20, 2022

Conversation

tomvothecoder
Copy link
Collaborator

@tomvothecoder tomvothecoder commented Apr 20, 2022

This PR extracts the _postprocess_dataset() function from xcdat.open_dataset() and xcdat.open_mfdataset() to reduce code duplication.

It also adds the optional boolean kwarg add_bounds (defaults to False) to both dataset opening functions, since generating missing bounds might not be desired in some cases. If the user ends up needing to generate bounds, they can either call ds.bounds.add_missing_bounds() to generate bounds that are missing for all supported axis (time, lat, lon), or ds.bounds.add_bounds("key_of_coords") for a specific axis.

Summary of Changes

  • Add boolean kwarg add_bounds for adding bounds to dataset opening functions, defaults to False.
  • Update docstrings to reduce redundancy and increase conciseness
  • Update variable names for clarity
  • Update reference to "regular" data vars to "non-bounds" data vars
  • Update optional function arg data_var to required arg key
  • Update line spacing and make sure there is a line break with return statements
  • Update BoundsAccessor property names for clarity

Description

Checklist

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • My changes generate no new warnings
  • Any dependent changes have been merged and published in downstream modules

If applicable:

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass with my changes (locally and CI/CD build)
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have noted that this is a breaking change for a major release (fix or feature that would cause existing functionality to not work as expected)

- Add option `add_bounds` for optionally adding bounds
- Update docstrings to reduce redundancy and increase conciseness
- Update variable names for clarity
- Update reference to "regular" data vars to "non-bounds" data vars
- Update optional function arg `data_var` to required arg `key`
- Update line spacing and make sure there is a line break with return statements
@tomvothecoder tomvothecoder self-assigned this Apr 20, 2022
@codecov-commenter
Copy link

codecov-commenter commented Apr 20, 2022

Codecov Report

Merging #223 (8c78cf1) into main (1fdc8a9) will not change coverage.
The diff coverage is 100.00%.

❗ Current head 8c78cf1 differs from pull request most recent head 89ad615. Consider uploading reports for the commit 89ad615 to get more accurate results

@@            Coverage Diff            @@
##              main      #223   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            9         8    -1     
  Lines          742       700   -42     
=========================================
- Hits           742       700   -42     
Impacted Files Coverage Δ
xcdat/__init__.py 100.00% <ø> (ø)
xcdat/utils.py 100.00% <ø> (ø)
xcdat/bounds.py 100.00% <100.00%> (ø)
xcdat/dataset.py 100.00% <100.00%> (ø)
xcdat/spatial.py 100.00% <100.00%> (ø)
xcdat/temporal.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 17c7d97...89ad615. Read the comment docs.

Copy link
Collaborator Author

@tomvothecoder tomvothecoder left a comment

Choose a reason for hiding this comment

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

Update docstrings

xcdat/bounds.py Outdated Show resolved Hide resolved
xcdat/bounds.py Outdated Show resolved Hide resolved
xcdat/dataset.py Outdated Show resolved Hide resolved
tests/test_bounds.py Outdated Show resolved Hide resolved
tests/test_dataset.py Outdated Show resolved Hide resolved
tests/test_bounds.py Outdated Show resolved Hide resolved
xcdat/dataset.py Outdated Show resolved Hide resolved
xcdat/dataset.py Outdated Show resolved Hide resolved
xcdat/dataset.py Outdated Show resolved Hide resolved
@tomvothecoder tomvothecoder added the breaking-change A breaking change, intended for a major release. label Apr 20, 2022
@tomvothecoder tomvothecoder merged commit 79c488e into main Apr 20, 2022
@tomvothecoder tomvothecoder deleted the feature/220-optional-bounds branch April 20, 2022 23:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking-change A breaking change, intended for a major release. type: enhancement New enhancement request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE]: Make generating bounds optional in open_dataset() and open_mfdataset()
2 participants