Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
(Scalar) Use this value for uninitialized parts of the dataset.
track_times
(T/F) Enable dataset creation timestamps.
"""
if self.id.http_conn.mode == 'r':
raise ValueError("Unable to create dataset (No write intent on file)")
if shape is None and data is None:
raise TypeError("Either data or shape must be specified")
# Convert data to a C-contiguous ndarray
if data is not None:
if dtype is None:
dtype = guess_dtype(data)
# if dtype is None:
# dtype = numpy.float32
if not isinstance(data, numpy.ndarray) or dtype != data.dtype:
data = numpy.asarray(data, order="C", dtype=dtype)
dtype = data.dtype
self.log.info("data dtype: {}".format(data.dtype))
# Validate shape
if shape is None:
if data is None:
raise TypeError("Either data or shape must be specified")
shape = data.shape
else:
shape = tuple(shape)
if data is not None and (numpy.product(shape) != numpy.product(data.shape)):
raise ValueError("Shape tuple is incompatible with data")
def __setitem__(self, name, value):
""" Set a new attribute, overwriting any existing attribute.
The type and shape of the attribute are determined from the data. To
use a specific type or shape, or to preserve the type of an attribute,
use the methods create() and modify().
"""
self.create(name, data=value, dtype=base.guess_dtype(value))
isn't provided.
dtype
Numpy dtype or string. If omitted, dtype('f') will be used.
Required if "data" isn't provided; otherwise, overrides data
array's dtype.
data
Provide data to initialize the dataset. If used, you can omit
shape and dtype arguments.
Keyword-only arguments:
"""
# Convert data to a C-contiguous ndarray
shape = None
if data is not None:
if dtype is None:
dtype = guess_dtype(data)
if dtype is None:
dtype = numpy.float32
if not isinstance(data, numpy.ndarray) or dtype != data.dtype:
data = numpy.asarray(data, order="C", dtype=dtype)
self.log.info("data dtype: {}".format(data.dtype))
if len(data.shape) != 1:
ValueError("Table must be one-dimensional")
if numrows and numrows != data.shape[0]:
ValueError("Data does not match numrows value")
shape = data.shape
elif numrows:
shape = [numrows,]
else:
shape = [0,]
if dtype is None: