Conversation
Codecov Report
@@ Coverage Diff @@
## dev #48 +/- ##
=========================================
+ Coverage 97.58% 97.6% +0.01%
=========================================
Files 11 11
Lines 1369 1376 +7
=========================================
+ Hits 1336 1343 +7
Misses 33 33
Continue to review full report at Codecov.
|
dragly
left a comment
There was a problem hiding this comment.
I think we should definitely use np.shape, but I'm not sure if np.array(data) is a good idea (see the inline comment for details).
| prepared_data, attrs, meta = ds._prepare_write(data, self.plugin_manager.dataset_plugins.write_order) | ||
|
|
||
| if not isinstance(prepared_data, np.ndarray) and prepared_data is not None: | ||
| prepared_data = np.array(prepared_data) |
There was a problem hiding this comment.
Which types will be affected by this? I remember something about quantities automatically getting converted the wrong way (i.e. not by the plugin if there was no plugin) because there was some support for conversion that we didn't expect. If this only affects lists (and other types that you'd really expect to get converted to an np.array), I'm all for it. But if this may trigger some unexpected conversion that a plugin should have done when the plugin is not enabled, I think we should only add it for types we already know (such as lists).
| raise ValueError( | ||
| "Provided shape and data.shape do not match: {} vs {}".format( | ||
| shape, data.shape | ||
| shape, np.shape(shape) |
There was a problem hiding this comment.
Looks like a typo. Should it be np.shape(data)?
| data = [1, 2, 3] | ||
| dset = grp.create_dataset('foo', data=data) | ||
| assert dset.shape == (3,) | ||
| assert np.array_equal(dset.data, np.array(data)) |
Converts data to a numpy array if data is not a ndarray or None. Among other things this enables lists to directly be used when creating a dataset, similar to h5py.
This also enables other objects to be converted to numpy object arrays. This is in line with the current support for and handling of object arrays, but see issue #47.