get_dims_from_str#
- hdf5view.models.get_dims_from_str(dims_as_str)#
Take a tuple of strings describing the desired dimensions input by the user into the hdf5widget.dims_view and turn it into a tuple of ints and/or slices, which can be used to index the dataset at the node.
The method to create slices from strings is given here: https://stackoverflow.com/questions/680826/python-create-slice-object-from-string/23895339
- Parameters:
- dims_as_str
Tuple
Tuple of strings describing the dimensions (dims) e.g. (“0”, “0”, “:”) or (“2:6:2”, “:”, “2”, “3”).
- dims_as_str
- Returns:
Tuple
Tuple of ints and/or slices to be used as an indexing object for array indexing, e.g. (0, 0, slice(None, None, None)) or (slice(2, 6, 2), slice(None, None, None), 2, 3), corresponding to the two examples given above for dims_as_str.
Examples
>>> from hdf5view.models import get_dims_from_str >>> get_dims_from_str(("0", "0", ":")) (0, 0, slice(None, None, None)) >>> get_dims_from_str(("2:6:2", ":", "2", "3")) (slice(2, 6, 2), slice(None, None, None), 2, 3)