refactor: Deprecate DataContainer and replace with xarray#168
Conversation
- The custom `DataContainer` class has been deprecated and replaced with `xarray.Dataset`. - An `xarray` accessor `fleks` has been created to house the domain-specific logic for calculating derived variables and plotting. - The `get_slice` and `get_domain` methods in `flekspy/yt/yt.py` now return `xarray.Dataset` objects. - All relevant tests have been updated to use the new `xarray`-based API. - The `plot_slice` method in `flekspy/yt/yt.py` has been updated to use the new `fleks` accessor.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #168 +/- ##
==========================================
+ Coverage 68.05% 77.55% +9.50%
==========================================
Files 26 27 +1
Lines 4232 4157 -75
==========================================
+ Hits 2880 3224 +344
+ Misses 1352 933 -419 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Code Review
This pull request is a significant and valuable refactoring that replaces the custom DataContainer with the more standard and powerful xarray.Dataset. The introduction of the fleks accessor to encapsulate domain-specific logic is an excellent design choice that improves modularity. My review focuses on a few areas where functionality appears to have been lost during the transition, particularly in the plotting methods. I've also included some suggestions to improve the robustness and maintainability of the new accessor code.
- The custom `DataContainer` class has been deprecated and replaced with `xarray.Dataset`. - An `xarray` accessor `fleks` has been created to house the domain-specific logic for calculating derived variables and plotting, including `plot`, `add_contour`, and `add_stream`. - The `get_slice` and `get_domain` methods in `flekspy/yt/yt.py` now return `xarray.Dataset` objects and propagate metadata attributes. - The `plot` method in the `FleksAccessor` now correctly displays metadata on the plot. - All relevant tests have been updated to use the new `xarray`-based API. - The `plot_slice` method in `flekspy/yt/yt.py` has been updated to use the new `fleks` accessor. - The expression for calculating `ps` in the `FleksAccessor` has been updated to use an f-string for improved readability.
- The custom `DataContainer` class has been deprecated and replaced with `xarray.Dataset`. - An `xarray` accessor `fleks` has been created to house the domain-specific logic for calculating derived variables and plotting, including `plot`, `add_contour`, and `add_stream`. - The `get_slice` and `get_domain` methods in `flekspy/yt/yt.py` now return `xarray.Dataset` objects and propagate metadata attributes. - The `plot` method in the `FleksAccessor` now correctly displays metadata on the plot using the `bottomline` parameter and uses `np.isclose` for robust float comparisons. - All relevant tests have been updated to use the new `xarray`-based API. - The `plot_slice` method in `flekspy/yt/yt.py` has been updated to use the new `fleks` accessor. - The expression for calculating `ps` in the `FleksAccessor` has been updated to use an f-string for improved readability.
|
/gemini summary |
Summary of ChangesThis pull request significantly refactors the data handling and plotting infrastructure by deprecating the custom Highlights
Changelog
Activity
|
DataContainerclass has been deprecated and replaced withxarray.Dataset.xarrayaccessorflekshas been created to house the domain-specific logic for calculating derived variables and plotting.get_sliceandget_domainmethods inflekspy/yt/yt.pynow returnxarray.Datasetobjects.xarray-based API.plot_slicemethod inflekspy/yt/yt.pyhas been updated to use the newfleksaccessor.Superceded #57