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

Add Dataset.dtypes property #6706

Merged
merged 7 commits into from
Jun 22, 2022
Merged

Add Dataset.dtypes property #6706

merged 7 commits into from
Jun 22, 2022

Conversation

headtr1ck
Copy link
Collaborator

@headtr1ck headtr1ck commented Jun 19, 2022

  • Closes mypy CI is failing on main #6714
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

Currently returns a Mapping from variable names to dtypes for ALL variables in the Dataset, including coordinates.
Possibly better to only return data_vars dtypes? Give me your thoughts on that, it is easy to change.

@max-sixty
Copy link
Collaborator

Great!

My inkling would be only data variables, given that's all we iterate over on a Dataset. We could also add this into the DatasetCoords / DataArrayCoords for completeness.

Any other thoughts?

@headtr1ck
Copy link
Collaborator Author

My inkling would be only data variables, given that's all we iterate over on a Dataset.

I would have thought the same. I have updated it now.

@dcherian
Copy link
Contributor

dcherian commented Jun 20, 2022

See related discussion here: #1699

I like the idea of .dtypes only listing data variables and coords.dtypes for the rest. This nicely generalizes to DataArray.coords.dtypes

@headtr1ck
Copy link
Collaborator Author

Is it intentional that DataArrayCoordinates and DatasetCoordinates are not part of api?

@max-sixty
Copy link
Collaborator

Is it intentional that DataArrayCoordinates and DatasetCoordinates are not part of api?

Good question, I'm not sure. They are not intended to be created by users IIUC, it's more like a "view" of the underlying coords. Does anyone have a view?

@TomNicholas
Copy link
Member

TomNicholas commented Jun 20, 2022

Good question, I'm not sure. They are not intended to be created by users IIUC, it's more like a "view" of the underlying coords. Does anyone have a view?

My understanding of these classes is that they are just slightly more complex mapping-like objects that we return instead of returning dicts in some cases. Sometimes they are intended to be immutable views and sometimes mutable IIUC. But I agree that they aren't intended to be instantiated directly by users.

@max-sixty max-sixty merged commit abad670 into pydata:main Jun 22, 2022
@max-sixty
Copy link
Collaborator

Thank you v much @headtr1ck !

dcherian added a commit to bzah/xarray that referenced this pull request Jun 24, 2022
* main: (129 commits)
  docs on specifying chunks in to_zarr encoding arg (pydata#6542)
  [skip-ci] List count under Aggregation (pydata#6711)
  Add `Dataset.dtypes` property (pydata#6706)
  try to import `UndefinedVariableError` from the new location (pydata#6701)
  DOC: note of how `chunks` can be defined (pydata#6696)
  pdyap version dependent client.open_url call (pydata#6656)
  use `pytest-reportlog` to generate upstream-dev CI failure reports (pydata#6699)
  [pre-commit.ci] pre-commit autoupdate (pydata#6694)
  Bump actions/setup-python from 3 to 4 (pydata#6692)
  Fix Dataset.where with drop=True and mixed dims (pydata#6690)
  pass kwargs through from save_mfdataset to to_netcdf (pydata#6686)
  Docs: indexing.rst finetuning (pydata#6685)
  use micromamba instead of mamba (pydata#6674)
  install the development version of `matplotlib` into the upstream-dev CI (pydata#6675)
  Add whatsnew section for v2022.06.0
  release notes for 2022.06.0rc0
  release notes for the pre-release (pydata#6676)
  more testpypi workflow fixes (pydata#6673)
  thin: add examples (pydata#6663)
  Update multidimensional-coords.ipynb (pydata#6672)
  ...
@headtr1ck headtr1ck deleted the dataset_dtypes branch June 26, 2022 08: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.

mypy CI is failing on main
4 participants