You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
NDCollection does not support the internal representation of aligned_axes in the constructor #846
While I am loathed to support more permutations of the aligned_axes= keyword argument seeing as we apparently already support nearly every conceivable option, the one we don't support is the one we use internally (the dict) representation.
>>>spice.aligned_axes
{'Mg IX 706 - Peak': (np.int64(1), np.int64(2)),
'N IV 765 - Peak': (np.int64(1), np.int64(2)),
'Ne VIII 770 - Peak': (np.int64(1), np.int64(2)),
'Ly-gamma-CIII group (Merged)': (np.int64(1), np.int64(2)),
'Ly Beta 1025 (Merged)': (np.int64(1), np.int64(2)),
'O VI 1032 - Peak': (np.int64(1), np.int64(2))}
>>>new_collection=NDCollection(new_cubes, aligned_axes=spice.aligned_axes)
---------------------------------------------------------------------------KeyErrorTraceback (mostrecentcalllast)
CellIn[23], line97c=NDCube(cube, meta=dict(cube.meta))
8new_items.append((key, c))
---->9spice=NDCollection(new_items, aligned_axes=spice.aligned_axes)
10spiceFile~/.virtualenvs/hinode-talk/lib/python3.13/site-packages/ndcube/ndcollection.py:69, inNDCollection.__init__(self, key_data_pairs, aligned_axes, meta, **kwargs)
67# Sanitize aligned axes unless hidden kwarg indicates not to.68ifsanitize_inputs:
--->69aligned_axes=collection_utils._sanitize_aligned_axes(keys, data, aligned_axes)
70else:
71aligned_axes=dict(zip(keys, aligned_axes))
File~/.virtualenvs/hinode-talk/lib/python3.13/site-packages/ndcube/utils/collection.py:23, in_sanitize_aligned_axes(keys, data, aligned_axes)
20sanitized_axes=tuple([tuple(range(len(cube0_dims)))] *len(data))
21else:
22# Else, sanitize user-supplied aligned axes.--->23sanitized_axes=_sanitize_user_aligned_axes(data, aligned_axes)
25returndict(zip(keys, sanitized_axes))
File~/.virtualenvs/hinode-talk/lib/python3.13/site-packages/ndcube/utils/collection.py:43, in_sanitize_user_aligned_axes(data, aligned_axes)
40aligned_axes_error_message= ("aligned_axes must contain ints or "41"a tuple of ints for each element in data.")
42ifisinstance(data[0].shape, tuple):
--->43cube0_dims=np.array(data[0].shape, dtype=object)[np.array(aligned_axes[0])]
44else:
45cube0_dims=data[0].shape[np.array(aligned_axes[0])]
KeyError: 0
Activity
Cadair commentedon Jun 11, 2025
The solution is to use
tuple(spice.aligned_axes.values())which is obtuse.DanRyanIrish commentedon Jun 11, 2025
Adding this support sounds reasonable to me.