metawards.mixers.InteractionMatrix
- class metawards.mixers.InteractionMatrix(n: int, value: float = 0.0)[source]
This is an interaction matrix, which is used to control how the FOIs of different demographics are merged together.
An interaction matrix is just a square matrix, with a list[][] being perfectly acceptable. This is really a convenience class that makes it easier to create more complex interaction matrixes
- __init__(n: int, value: float = 0.0)[source]
Construct an interaction matrix that is n x n in size, where all values equal ‘value’
Methods
__delattr__
(name, /)Implement delattr(self, name).
__dir__
()Default dir() implementation.
__eq__
(other)Return self==value.
__format__
(format_spec, /)Default object formatter.
__ge__
(value, /)Return self>=value.
__getattribute__
(name, /)Return getattr(self, name).
__getitem__
(i)Return the ith row of the matrix
__gt__
(value, /)Return self>value.
__init__
(n[, value])Construct an interaction matrix that is n x n in size, where all values equal 'value'
__init_subclass__
This method is called when a class is subclassed.
__le__
(value, /)Return self<=value.
__len__
()__lt__
(value, /)Return self<value.
__ne__
(value, /)Return self!=value.
__new__
(**kwargs)__reduce__
()Helper for pickle.
__reduce_ex__
(protocol, /)Helper for pickle.
__repr__
()Return repr(self).
__setattr__
(name, value, /)Implement setattr(self, name, value).
__setitem__
(i, row)"Set the ith row of the matrix equal to 'row'
__sizeof__
()Size of object in memory, in bytes.
__str__
()Return str(self).
__subclasshook__
Abstract classes can override this to customize issubclass().
detach
(n)Detach the 'nth' demographic from interacting with any other demographics.
diagonal
(n[, value, off_diagonal])Return a n x n matrix where each diagonal element equals 'value' and each off-diagonal element equals 'off_diagonal'
identity
(n[, value, off_diagonal])Return a n x n matrix where each diagonal element equals 'value' and each off-diagonal element equals 'off_diagonal'
ones
(n[, value])Return a n x n matrix where each element equals 'value'
resize
(n[, value])Resize this matrix to 'n x n', adding in extra values equal to 'value' if needed
zeroes
(n[, value])Return a n x n matrix where each element equals 'value'
Attributes
__dict__
__doc__
__module__
__weakref__
list of weak references to the object (if defined)
- __hash__ = None
- __init__(n: int, value: float = 0.0)[source]
Construct an interaction matrix that is n x n in size, where all values equal ‘value’
- detach(n: int)[source]
Detach the ‘nth’ demographic from interacting with any other demographics. This sets the ith row and ith column equal to zero (which not changing m[n][n])
- static diagonal(n: int, value: float = 1.0, off_diagonal: float = 0.0)[source]
Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’
- static identity(n: int, value: float = 1.0, off_diagonal: float = 0.0)[source]
Return a n x n matrix where each diagonal element equals ‘value’ and each off-diagonal element equals ‘off_diagonal’
- static ones(n: int, value: float = 1.0)[source]
Return a n x n matrix where each element equals ‘value’