Skip to content
Snippets Groups Projects
Commit ced7fa2c authored by Sebastian Müller's avatar Sebastian Müller 🐈
Browse files

gird: to_/from_canonical: allow additional dimensions

parent f5fb87ef
No related branches found
No related tags found
1 merge request!286Add mask to Info object
......@@ -519,7 +519,9 @@ class StructuredGrid(Grid):
ValueError
When data has wrong shape.
"""
if not np.array_equal(np.shape(data), self.data_shape):
rev = -1 if self.axes_reversed else 1
d_shp, in_shp, shp_len = self.data_shape, np.shape(data), len(self.data_shape)
if not np.array_equal(d_shp[::rev], in_shp[::rev][:shp_len]):
msg = "to_canonical: data has wrong shape."
raise ValueError(msg)
if self.axes_reversed and np.ndim(data) > 1:
......@@ -552,7 +554,8 @@ class StructuredGrid(Grid):
When data has wrong shape.
"""
rev = -1 if self.axes_reversed else 1
if not np.array_equal(np.shape(data)[::rev], self.data_shape):
d_shp, in_shp, shp_len = self.data_shape, np.shape(data), len(self.data_shape)
if not np.array_equal(d_shp[::rev], in_shp[:shp_len]):
msg = "from_canonical: data has wrong shape."
raise ValueError(msg)
for i, inc in enumerate(self.axes_increase):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment