diff --git a/tiledb/dense_array.py b/tiledb/dense_array.py index 51489e8057..000256f4e3 100644 --- a/tiledb/dense_array.py +++ b/tiledb/dense_array.py @@ -441,7 +441,7 @@ def _setitem_impl(self, selection, val, nullmaps: dict): labels = { name: ( data - if not type(data) is np.ndarray or data.dtype is np.dtype("O") + if not isinstance(data, np.ndarray) or data.dtype == np.dtype("O") else np.ascontiguousarray( data, dtype=self.schema.dim_label(name).dtype ) @@ -458,7 +458,7 @@ def _setitem_impl(self, selection, val, nullmaps: dict): attributes.append(attr._internal_name) # object arrays are var-len and handled later - if type(attr_val) is np.ndarray and attr_val.dtype is not np.dtype("O"): + if isinstance(attr_val, np.ndarray) and attr_val.dtype != np.dtype("O"): if attr.isnullable and name not in nullmaps: try: nullmaps[name] = ~np.ma.masked_invalid(attr_val).mask @@ -527,7 +527,7 @@ def _setitem_impl(self, selection, val, nullmaps: dict): name = attr.name attributes.append(attr._internal_name) # object arrays are var-len and handled later - if type(val) is np.ndarray and val.dtype is not np.dtype("O"): + if isinstance(val, np.ndarray) and val.dtype != np.dtype("O"): val = np.ascontiguousarray(val, dtype=attr.dtype) try: if attr.isvar: diff --git a/tiledb/sparse_array.py b/tiledb/sparse_array.py index 55692bfcd1..122fe46501 100644 --- a/tiledb/sparse_array.py +++ b/tiledb/sparse_array.py @@ -108,7 +108,7 @@ def _setitem_impl_sparse(self, selection, val, nullmaps: dict): labels = { name: ( data - if not type(data) is np.ndarray or data.dtype is np.dtype("O") + if not isinstance(data, np.ndarray) or data.dtype == np.dtype("O") else np.ascontiguousarray(data, dtype=self.schema.dim_label(name).dtype) ) for name, data in val.items()