Open esteinig opened 2 years ago
I should rewrite the distribution classes, they are a mess
Distributions identifiers are now PrivateAttr
and not settable on instantiation; instead, a unique (uuid4
) identifier is assigned on instance creation. Each parameter in the distribution is also assigned a private identifier (but Parameter
classes identifiers can still be set if needed).
class Distribution(BaseModel):
_id: str = PrivateAttr()
class Uniform(Distribution):
def __init__(self, **data):
super().__init__(**data)
self._id: str = f"Uniform.{get_uuid(short=False)}"
Instances are unique:
from critter.blocks.distributions import Uniform
uni1, uni2 = Uniform(), Uniform()
assert uni1._id != uni2._id
Might change this to an incremental numeric identifier instead of unique, so the output XML files for BEAST
can be tested - leaving issue open for now.
Unique identifier in distributions and parameters (using
critter.utils.get_uuid
) is instantiated at import, so that using the same import results in assignment of the same (replicated) identifiers.