def create_dataset(self, ds_name, data, attrs=None, dtype=None):
if ds_name in self._datasets:<EOL><INDENT>ds = self._datasets[ds_name]<EOL>if ds.dtype != data.dtype:<EOL><INDENT>warnings.warn('<STR_LIT>')<EOL><DEDENT><DEDENT>else:<EOL><INDENT>if dtype is None:<EOL><INDENT>dtype = data.dtype<EOL><DEDENT>ds = self._group.create_dataset(ds_name, data.shape,<EOL>dtype=dtype)<EOL>if attrs is not None:<EOL><INDENT>for key in attrs:<EOL><INDENT>setattr(ds.attrs, key, attrs[key])<EOL><DEDENT><DEDENT><DEDENT>ds.read_direct(data)<EOL>self._datasets[ds_name] = ds<EOL>return ds<EOL>
Saves a Numpy array in a dataset in the HDF file, registers it as
ds_name and returns the h5py dataset.

:param ds_name: string
Registration name of the dataset to be registered.

:param data: Numpy ndarray

:param dtype: dtype
Datatype of the dataset

:return: h5py dataset