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
dimension scale creation method is in wrong (confusing) location #830
Comments
This looks like it could be converted into a static method on the Having the At a minimum it should be better documented. |
I agree with @equaeghe that it's somewhat confusing to have this method associated with an uninvolved dataset. Instead of this: f['data'].dims.create_scale(f['x2'], 'x2 name') It would conceptually align with HDF5 better to do something like this: f['x2'].make_scale('x2 name') Or it could be an option when you create a dataset - this makes the intent clearer to my mind, though it's somewhat less flexible. f.create_dataset('x2', data=np.arange(10), as_scale='x2 name') |
I looked at it in a different way: I use dimension scales as follows:
row = np.arange(0, 256, dtype='u2') # define data for my dimension
ds_row = fid.create_dataset('row', data=row) # create a dataset
ds_row.dims.create_scale(fid['row'], 'some description') # turn this dataset into a dimension
dset = fid.create_dataset('frame', data=frame) # create a real dataset
dset.dims[0].attach_scale(ds_row) # attach one of its dimensions
I think the problem is in the third line, where I have to use fid['row']
again. Reading the previous emails I realize that I create a
dimension-scale by saying that it is its own dimension scale, which I can
then use it for other datasets. This approach works well and is also
accepted also by netCDF4 S/W.
Thus I would also prefer the construction as suggested by Thomas
Kluyver: `ds_row.make_scale('some
description')`. Then it is clear that I can use ds_row as dimension scale
and attach it to other datasets in the file.
Greetings, Richard
…On Wed, 24 Oct 2018 at 13:46, Thomas Kluyver ***@***.***> wrote:
I agree with @equaeghe <https://github.com/equaeghe> that it's somewhat
confusing to have this method associated with an uninvolved dataset.
Instead of this:
f['data'].dims.create_scale(f['x2'], 'x2 name')
It would conceptually align with HDF5 better to do something like this:
f['x2'].make_scale('x2 name')
Or it could be an option when you create a dataset - this makes the intent
clearer to my mind, though it's somewhat less flexible.
f.create_dataset('x2', data=np.arange(10), as_scale='x2 name')
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#830 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ADi7qt2fM0lZPGGMRkkCENo9TOAFVKhxks5uoFMugaJpZM4LpX6P>
.
|
Replaces other_ds.dims.create_scale(ds), which is deprecated here. Closes h5pygh-830
I've opened PR #1212 to address this. |
Currently, dimension scales are created as
dataset.dims.create_scale(scale_dataset, 'scale name')
, i.e., using thecreate_scale
method of thedims
attribute of aDataset
. However, as far as I can tell, dimension scale creation only acts onscale_dataset
and has nothing to do withdataset
, so it would be more logical to have acreate_scale
method (which can take a scale name as an argument) onDataset
or perhaps a static method that takes a scale dataset (and a scale name) as an argument.The current practice is confusing, as it may lead people to believe that the scale is created specifically for
dataset
, which is not the case, I think. (At least I was confused.)The change I propose does not need to lead to an API incompatibility: the new method could be added and the old one kept (perhaps in some way deprecated or advised against).
The text was updated successfully, but these errors were encountered: