sciunit.models package¶
Submodules¶
sciunit.models.backends module¶
Base class for simulator backends for SciUnit models.
-
class
sciunit.models.backends.
Backend
[source]¶ Bases:
object
Base class for simulator backends.
Should only be used with model classes derived from RunnableModel. Supports caching of simulation results. Backend classes should implement simulator-specific details of modifying, running, and reading results from the simulation.
-
__module__
= 'sciunit.models.backends'¶
-
__weakref__
¶ list of weak references to the object (if defined)
-
f
= None¶ The function that handles running the simulation
-
get_memory_cache
(key=None)[source]¶ Return result in memory cache for key ‘key’ or None if not found.
-
name
= None¶ Name of the backend
-
recorded_variables
= None¶ Optional list of state variables for a backend to record.
-
set_disk_cache
(results, key=None)[source]¶ Store result in disk cache with key matching model state.
-
sciunit.models.base module¶
Base class for SciUnit models.
-
class
sciunit.models.base.
Model
(name=None, **params)[source]¶ Bases:
sciunit.base.SciUnit
Abstract base class for sciunit models.
-
__module__
= 'sciunit.models.base'¶
-
_backend
= None¶ Optional model backend for executing some methods, e.g. simulations.
-
property
capabilities
¶
-
check_params
()[source]¶ Check model parameters to see if they are reasonable.
For example, this method could check self.params to see if a particular value was within an acceptable range. This should be implemented as needed by specific model classes.
-
description
= ''¶ A description of the model.
-
extra_capability_checks
= None¶ Optional extra checks of capabilities on a per-instance basis.
-
property
failed_extra_capabilities
¶ Check to see if instance passes its extra_capability_checks.
-
is_match
(match)[source]¶ Return whether this model is the same as match.
Matches if the model is the same as or has the same name as match.
-
name
= None¶ The name of the model. Defaults to the class name.
-
params
= None¶ The parameters to the model (a dictionary). These distinguish one model of a class from another.
-
run_args
= None¶ These are the run-time arguments for the model. Execution of run() should make use of these arguments.
-
sciunit.models.examples module¶
Example SciUnit model classes.
-
class
sciunit.models.examples.
CacheByInstancePersistentUniformModel
(a, b, name=None)[source]¶ Bases:
sciunit.models.examples.PersistentUniformModel
TODO
-
__module__
= 'sciunit.models.examples'¶
-
produce_number
(**kwargs)¶ Produce a number.
-
-
class
sciunit.models.examples.
CacheByValuePersistentUniformModel
(a, b, name=None)[source]¶ Bases:
sciunit.models.examples.PersistentUniformModel
TODO
-
__module__
= 'sciunit.models.examples'¶
-
produce_number
(**kwargs)¶ Produce a number.
-
-
class
sciunit.models.examples.
ConstModel
(constant, name=None)[source]¶ Bases:
sciunit.models.base.Model
,sciunit.capabilities.ProducesNumber
A model that always produces a constant number as output.
-
__module__
= 'sciunit.models.examples'¶
-
-
class
sciunit.models.examples.
PersistentUniformModel
(a, b, name=None)[source]¶ Bases:
sciunit.models.examples.UniformModel
TODO
-
__module__
= 'sciunit.models.examples'¶
-
-
class
sciunit.models.examples.
RepeatedRandomNumberModel
(name=None, **params)[source]¶ Bases:
sciunit.models.base.Model
,sciunit.capabilities.ProducesNumber
An example model to demonstrate ProducesNumber with cypy.lazy.
-
__module__
= 'sciunit.models.examples'¶
-
Bases:
sciunit.models.base.Model
A model that, each time it is instantiated with the same parameters, will return the same instance at the same locaiton in memory. Attributes should not be set post-instantiation unless the goal is to set those attributes on all models of this class.
Override used by cypy.intern to cache instances of this class.
Override used by cypy.intern to cache instances of this class.
-
class
sciunit.models.examples.
UniformModel
(a, b, name=None)[source]¶ Bases:
sciunit.models.base.Model
,sciunit.capabilities.ProducesNumber
A model that always produces a random uniformly distributed number in [a,b] as output.
-
__module__
= 'sciunit.models.examples'¶
-
-
class
sciunit.models.examples.
UniqueRandomNumberModel
(name=None, **params)[source]¶ Bases:
sciunit.models.base.Model
,sciunit.capabilities.ProducesNumber
An example model to ProducesNumber.
-
__module__
= 'sciunit.models.examples'¶
-
sciunit.models.runnable module¶
Runnable model.
-
class
sciunit.models.runnable.
RunnableModel
(name, backend=None, attrs=None)[source]¶ Bases:
sciunit.models.base.Model
,sciunit.capabilities.Runnable
A model which can be run to produce simulation results
-
__module__
= 'sciunit.models.runnable'¶
-
check_run_params
()[source]¶ Check if run parameters are reasonable for this model class.
Raise a sciunit.BadParameterValueError if any of them are not.
-
set_default_run_params
(**params)[source]¶ Set default parameters for all runs.
Note these are parameters of the simulation itself, not the model.
-
property
state
¶
-
Module contents¶
SciUnit models.