Skip to content

Commit

Permalink
Attempt to fix HDF5ExtError (#157)
Browse files Browse the repository at this point in the history
* change HistoryHdf5 file to read to avoid concurrent writing in HDFStore
  • Loading branch information
glyg committed Aug 30, 2019
1 parent dc956f8 commit 81561be
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 20 deletions.
34 changes: 34 additions & 0 deletions doc/bibliography/tyssue.bib
Expand Up @@ -3451,5 +3451,39 @@ @article{Bidensityindependentrigiditytransition2015
author = {Bi, Dapeng and Lopez, J. H. and Schwarz, J. M. and Manning, M. Lisa}
}
@article{Lardennoisactinbasedviscoplasticlock2019,
langid = {english},
title = {An Actin-Based Viscoplastic Lock Ensures Progressive Body-Axis Elongation},
issn = {1476-4687},
url = {https://www.nature.com/articles/s41586-019-1509-4},
doi = {10.1038/s41586-019-1509-4},
abstract = {Molecular analysis and mathematical modelling are combined to identify a network of factors that account for viscoplastic deformation in elongation of Caenorhabditis elegans during embryonic development.},
journaltitle = {Nature},
shortjournal = {Nature},
urldate = {2019-08-30},
date = {2019-08-28},
pages = {1-5},
author = {Lardennois, Alicia and P\'asti, Gabriella and Ferraro, Teresa and Llense, Flora and Mahou, Pierre and Pontabry, Julien and Rodriguez, David and Kim, Samantha and Ono, Shoichiro and Beaurepaire, Emmanuel and Gally, Christelle and Labouesse, Michel},
file = {/home/guillaume/.mozilla/firefox/14u1jeb7.default-1392277802592/zotero/storage/LM8X8TZP/s41586-019-1509-4.html}
}
@article{ChenExtracellularmatrixstiffness2019,
langid = {english},
title = {Extracellular Matrix Stiffness Cues Junctional Remodeling for {{3D}} Tissue Elongation},
volume = {10},
issn = {2041-1723},
url = {https://www.nature.com/articles/s41467-019-10874-x},
doi = {10.1038/s41467-019-10874-x},
abstract = {The extracellular matrix can shape developing organs, but how external forces direct intercellular morphogenesis is unclear. Here, the authors use 3D imaging to show that elongation of the Drosophila egg chamber involves polarized cell reorientation signalled by changes in stiffness of the surrounding extracellular matrix.},
number = {1},
journaltitle = {Nature Communications},
shortjournal = {Nat Commun},
urldate = {2019-08-30},
date = {2019-07-26},
pages = {1-15},
author = {Chen, Dong-Yuan and Crest, Justin and Streichan, Sebastian J. and Bilder, David},
file = {/home/guillaume/.mozilla/firefox/14u1jeb7.default-1392277802592/zotero/storage/7PIYA6CG/Chen et al. - 2019 - Extracellular matrix stiffness cues junctional rem.pdf;/home/guillaume/.mozilla/firefox/14u1jeb7.default-1392277802592/zotero/storage/LPS26KHN/s41467-019-10874-x.html}
}
@preamble{ "\ifdefined\DeclarePrefChars\DeclarePrefChars{'’-}\else\fi " }
40 changes: 20 additions & 20 deletions tyssue/core/history.py
Expand Up @@ -48,7 +48,7 @@ def __init__(self, sheet, save_every=None, dt=None, extra_cols=None):

self.sheet = sheet

self.time = 0.
self.time = 0.0
self.index = 0
if save_every is not None:
self.save_every = save_every
Expand Down Expand Up @@ -151,16 +151,13 @@ def record(self, to_record=None, time_stamp=None):
cols = self.columns[element]
df = self.sheet.datasets[element][cols].reset_index(drop=False)
if not "time" in cols:
times = pd.Series(
np.ones((df.shape[0],)) * self.time, name="time")
df = pd.concat(
[df, times], ignore_index=False, axis=1, sort=False)
times = pd.Series(np.ones((df.shape[0],)) * self.time, name="time")
df = pd.concat([df, times], ignore_index=False, axis=1, sort=False)
if self.time in hist["time"]:
# erase previously recorded time point
hist = hist[hist["time"] != self.time]

hist = pd.concat(
[hist, df], ignore_index=True, axis=0, sort=False)
hist = pd.concat([hist, df], ignore_index=True, axis=0, sort=False)

self.datasets[element] = hist

Expand Down Expand Up @@ -260,14 +257,15 @@ def __init__(
break
if sheet is None:
last = self.time_stamps[-1]
with pd.HDFStore(self.hf5file, "a") as file:
with pd.HDFStore(self.hf5file, "r") as file:
keys = file.keys()
if "\cell" in keys:
sheet = Epithelium

History.__init__(self, sheet, save_every, dt, extra_cols)
self.dtypes = {k: df[self.columns[k]].dtypes
for k, df in sheet.datasets.items()}
self.dtypes = {
k: df[self.columns[k]].dtypes for k, df in sheet.datasets.items()
}

@classmethod
def from_archive(cls, hf5file, columns=None, eptm_class=None):
Expand Down Expand Up @@ -316,34 +314,36 @@ def record(self, to_record=None, time_stamp=None):
if time_stamp is not None:
self.time = time_stamp
else:
self.time += 1.
self.time += 1.0

dtypes_ = {k: df.dtypes for k, df in self.sheet.datasets.items()}

for element, df in self.sheet.datasets.items():
diff_col = set(dtypes_[element].keys()).difference(
set(self.dtypes[element].keys()))
set(self.dtypes[element].keys())
)
if diff_col:
warnings.warn(
"New columns {} will not be saved in the {} table".format(diff_col, element))
"New columns {} will not be saved in the {} table".format(
diff_col, element
)
)
else:
if dtypes_[element].to_dict() != self.dtypes[element].to_dict():
raise ValueError(
"There is a change of datatype in {} table".format(element))
"There is a change of datatype in {} table".format(element)
)

if (self.save_every is None) or (
self.index % (int(self.save_every / self.dt)) == 0
):
for element, df in self.sheet.datasets.items():
times = pd.Series(
np.ones((df.shape[0],)) * self.time, name="time")
times = pd.Series(np.ones((df.shape[0],)) * self.time, name="time")
df = df[self.columns[element]]
df = pd.concat([df, times], ignore_index=False,
axis=1, sort=False)
df = pd.concat([df, times], ignore_index=False, axis=1, sort=False)

with pd.HDFStore(self.hf5file, "a") as file:
file.append(key=element, value=df,
data_columns=["time"])
file.append(key=element, value=df, data_columns=["time"])

self.index += 1

Expand Down

0 comments on commit 81561be

Please sign in to comment.