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

Correctly concatenate pandas.Index objects #875

Merged
merged 7 commits into from
Jun 16, 2016

Conversation

shoyer
Copy link
Member

@shoyer shoyer commented Jun 8, 2016

We now have a dedicated method, Coordinate.concat that will correctly
concatenate pandas.Index objects, even if they can't be properly expressed as
NumPy arrays (e.g., PeriodIndex and MultiIndex).

As part of this change, I removed and replaced the internal interleaved_concat
routine. It turns out we can do this with an inverse permutation instead, which
results in much simpler and cleaner code. In particular, we no longer need a
special path to support dask.array.

This should help with #818.

We now have a dedicated method, Coordinate.concat that will correctly
concatenate pandas.Index objects, even if they can't be properly expressed as
NumPy arrays (e.g., PeriodIndex and MultiIndex).

As part of this change, I removed and replaced the internal `interleaved_concat`
routine. It turns out we can do this with an inverse permutation instead, which
results in much simpler and cleaner code. In particular, we no longer need a
special path to support dask.array.

This should help with GH818.
@shoyer shoyer mentioned this pull request Jun 8, 2016
3 tasks
@@ -66,6 +67,52 @@ def _dummy_copy(xarray_obj):
raise AssertionError
return res

def _is_one_or_none(obj):
return obj == 1 or obj is None
Copy link
Member

Choose a reason for hiding this comment

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

do you want to treat True as 1? If not, this should be obj is 1 or obj is None.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Interesting! I never knew that.
I always thought ints & strings should use ==, but for -1 to 256 is is fine: http://stackoverflow.com/questions/2239737/is-it-better-to-use-is-or-for-number-comparison-in-python

Copy link
Member

Choose a reason for hiding this comment

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

But this depends on the interpreter, then. CPython might work, but others might not I guess?

Copy link
Member Author

Choose a reason for hiding this comment

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

These slice objects are generated internally by groupby, so I think it's pretty far fetched to get step is True. Using == feels more idiomatic, anyways.

along the given dimension.
"""
variables = list(variables)
print(variables)
Copy link
Collaborator

Choose a reason for hiding this comment

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

guessing this is left over from debugging

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed, thanks

@shoyer shoyer merged commit 918945c into pydata:master Jun 16, 2016
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.

4 participants