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

Encodings for object data types are not saved. #40

Closed
wants to merge 2 commits into from

Conversation

akleeman
Copy link
Contributor

@akleeman akleeman commented Mar 3, 2014

decode_cf_variable will not save encoding for any 'object' dtypes.

When encoding cf variables check if dtype is np.datetime64 as well as DatetimeIndex.

fixes akleeman/xray/issues/39

When encoding cf variables check if dtype is np.datetime64.

fixes akleeman/xray/issues/39
@@ -249,11 +249,12 @@ def encode_cf_variable(array):
attributes = array.attributes.copy()
encoding = array.encoding

if isinstance(data, pd.DatetimeIndex):
if (isinstance(data, pd.DatetimeIndex) or
Copy link
Member

Choose a reason for hiding this comment

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

I think the right check is np.issubdtype(data.dtype, np.datetime64), which will cover both these cases.

Changed datetime check, copied encoding.
@akleeman akleeman closed this Mar 7, 2014
shoyer added a commit that referenced this pull request Mar 7, 2014
This allows us to simplify our internal model for XArray (it always cached
internally as a base ndarray) and supports some previously tricky aspects
involving pandas.Index objects. Noteably:
1. The dtype of arrays stored as pandas.Index objects can now be faithfully
   saved and restored. Doing math with XArray objects always yields objects
   with the right dtype, so `ds['latitude'] + 1` has dtype=float, not
   dtype=object.
2. It's no longer necessary to load index data into memory upon creating a new
   Dataset. Instead, the index data can be loaded on demand.
3. `var.data` is always an ndarray. `var.index` is always a pandas.Index.

Related issues: #17, #39, #40.
@shoyer shoyer deleted the ignore-object-dtype branch April 9, 2014 04:10
keewis pushed a commit to keewis/xarray that referenced this pull request Jan 17, 2024
* tests for name collisions between variables and children

* pass 2/3 tests
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.

None yet

2 participants