Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
Args:
model (pymer4.models): an instance of a pymer4 model
filepath (str): full filepath string ending with .h5 or .hd5f
"""
if filepath.endswith(".h5") or filepath.endswith('.hdf5'):
if not os.path.exists(filepath):
raise IOError("File not found!")
# Load h5 first
model_atts = dd.io.load(filepath)
# Figure out what kind of model we're dealing with
if model_atts['simple_atts']['model_class'] == 'Lmer':
model = Lmer('', [])
elif model_atts['simple_atts']['model_class'] == 'Lm2':
model = Lm2('', [] , '')
elif model_atts['simple_atts']['model_class'] == 'Lm':
model = Lm('', [])
# Set top level attributes
for k, v in model_atts['simple_atts'].items():
if k != 'model_class':
setattr(model, k, v)
# Make sure the model formula is a python string string so that rpy2 doesn't complain
model.formula = str(model.formula)
# Set data attributes
# Container for already set items
completed = []
for k, v in model_atts['data_atts'].items():
# Re-assembe dataframes
if k.startswith('df_'):