-
Notifications
You must be signed in to change notification settings - Fork 21
fix: change concat alignment handling #3686
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
Conversation
|
Hm, the test case that makes this fail is: and that doesn't hold now because So unless we want to make |
|
import numpy as np
import xarray as xr
da1 = xr.DataArray(
np.arange(4),
{'x': np.arange(4), 'b': np.array('abc')},
dims=('x',)
)
da2 = xr.DataArray(
2 * np.arange(4),
{'x': np.arange(4), 'b': np.array('abc')},
dims=('x',)
)
da3 = xr.DataArray(
np.arange(4),
{'x': np.arange(4), 'b': np.array('123')},
dims=('x',)
)
print(da1, da2 ,da3)
comb = xr.concat([da1, da2], dim='b')
print(comb)
print(comb + da3)in the sense that |
|
Yes this is how I understand it too. Xarray behaves same as scipp when the coord is a 'dimension coord', and different otherwise. But scipp doesn't have the concept of a dimension coord', so we have to choose one behavior. It seems to me we can't do much about this. |
Well, if the coord has the same name as the dimension then it is a dimension coord. Others are not.
Can't we not set the alignment flag for non-dimension coords (that where not aligned in the input)? |
Aha I didn't know we could take the name of the coord into account, in that case yeah we can do that. I'll try it out |
|
Not sure if we want to make the coord aligned if all instances of the coord in the inputs are aligned, or if we want to make the coord aligned if any instances of the coord in the input are aligned. When all instances of the coord in the input have the same alignment then all and any are going to produce the same result. If the different instances of the coord in the input have different alignment, should we prefer to set the coord on the concatenated array aligned or unaligned? |
If any, because we should never remove and "aligned" flag, since users may rely on it for safety.
|
|
I think this may have worked correctly before the alignment flag was introduced (when Edit: Have to correct myself, it looks like it was broken before, since |
Fixes #3685
With this change, this is the output from the MRE in the issue:
This seems more reasonable because
commentis not made aligned.But I'm not sure if this behavior makes most sense here in every case.
How do we actually want this to work?