model

Model definition constants and validation functions

class cmepy.model.Model(**entries)

Simple CME Model structure. Data can be accessed via key or attribute.

validate()
raise exception if model is not valid
cmepy.model.create(**entries)

Returns a model instance, using the specified entries.

Entries should be model parameters as keyword arguments.

cmepy.model.must_be_callable(value, descr=None)
raises TypeError if value is not callable
cmepy.model.must_be_int_like(value, descr=None, min_value=None, max_value=None)
raises TypeError if value isn’t int-like
cmepy.model.must_be_mapping(value, descr=None)

raises TypeError if value isn’t a mapping

this is a very loose definition of a mapping.

cmepy.model.must_be_string_like(value, descr=None)
raises TypeError if value isn’t string-like
cmepy.model.must_be_within_range(value, descr=None, min_value=None, max_value=None)
raises ValueError if value is not within specified range
cmepy.model.must_contain_item(value, descr, item)
raises KeyError if value doesn’t contain item
cmepy.model.must_have_length(value, descr=None, min_len=None, max_len=None)

raises TypeError if value has no len()

optionally checks to see if len(value) is inside specified range

cmepy.model.raise_error(error_type, descr, value, message)
raise_error(error_type, descr, value, message) -> raise error_type(...)
cmepy.model.validate_initial_state(value)
raises exception if value is not a valid model initial_state entry
cmepy.model.validate_model(m)

raises exceptions if there’s anything suspect about the model m

this is not intended to be exhaustive or foolproof, it is intended merely to raise exceptions with more detailed and explanatory messages for the more obvious kinds of mistakes.

cmepy.model.validate_name(value)
raises exception if value is not a valid model name entry
cmepy.model.validate_propensities(value)
raises exception if value is not a valid model propensities entry
cmepy.model.validate_shape(value)
raises exception if value is not a valid model shape entry
cmepy.model.validate_species_counts(value)
raises exception if value is not a valid model species_counts entry
cmepy.model.validate_species_names(value)
raises exception if value is not a valid model species entry
cmepy.model.validate_transitions(value)
raises exception if value is not a valid model transitions entry

Previous topic

measurement

Next topic

models

This Page