Skip to content

Commit

Permalink
Don't chunk attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
Sten Linnarsson committed Feb 19, 2020
1 parent d64799a commit fb8ed35
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 0 additions & 2 deletions loompy/attribute_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,13 +153,11 @@ def __setattr__(self, name: str, val: np.ndarray) -> None:
if self.ds._file[a].__contains__(name):
del self.ds._file[a + name]

chunk_size = min(values.shape[0], 1000)
self.ds._file.create_dataset(
a + name,
data=values,
dtype=h5py.special_dtype(vlen=str) if values.dtype == np.object_ else values.dtype,
maxshape=(values.shape[0], ) if len(values.shape) == 1 else (values.shape[0], None),
chunks=(chunk_size, ) if len(values.shape) == 1 else (chunk_size , 1),
fletcher32=False,
compression="gzip",
shuffle=False,
Expand Down
2 changes: 2 additions & 0 deletions loompy/loompy.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def add_columns(self, layers: Union[np.ndarray, Dict[str, np.ndarray], loompy.La
self.shape = (self.ra[k].shape[0], self.shape[1])
if len(self.ca) == 0:
for k, v in col_attrs.items():
v = np.array(v)
self.ca[k] = np.zeros(0, v.dtype)

layers_dict: Dict[str, np.ndarray] = {}
Expand Down Expand Up @@ -388,6 +389,7 @@ def add_columns(self, layers: Union[np.ndarray, Dict[str, np.ndarray], loompy.La
self.shape = (self.shape[0], n_cols)
todel = []
for key, vals in col_attrs.items():
vals = np.array(vals)
if vals.shape[1:] != self.col_attrs[key].shape[1:]:
logging.debug(f"Removing attribute {key} because shape {vals.shape} did not match existing shape {self.col_attrs[key].shape} beyond first dimension")
todel.append(key)
Expand Down

0 comments on commit fb8ed35

Please sign in to comment.