Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@ count = True
max-line-length = 88
extend-ignore = E203
exclude =
.venv,
venv,
.vscode,
.conda,
.venv,
tests.venv/,
.hatch,
__pycache__
2 changes: 2 additions & 0 deletions bdms/mutators.py
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,8 @@ def __init__(
f"Transition matrix {transition_matrix} is not a valid stochastic"
" matrix."
)
if (not len(transition_matrix) == 1) and np.diag(transition_matrix).any():
raise ValueError("transition_matrix diagonal must be zero.")
super().__init__(attr=attr)
self.state_space = state_space
self.state_space_idxs: dict[Any, int] = {
Expand Down
10 changes: 10 additions & 0 deletions bdms/poisson.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,8 @@ class ConstantProcess(HomogeneousProcess):
def __init__(self, value: float = 1.0):
super().__init__()
self.value = value
if self.value < 0:
raise ValueError("The constant rate must be a non-negative float")

def λ_homogeneous(
self, x: Hashable | Sequence[Hashable] | NDArray[Any]
Expand All @@ -216,6 +218,14 @@ def __init__(
self, rates: Mapping[Hashable, float] | Sequence[float], attr: str = "state"
):
super().__init__(attr=attr)
if isinstance(rates, Mapping):
for rate in rates.values():
if rate < 0.0:
raise ValueError("The rate for each state must be >= 0")
else:
for rate in rates:
if rate < 0.0:
raise ValueError("The rate for each state must be >= 0")
self.rates = rates

def λ_homogeneous(
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ packages = ["bdms"]
[tool.hatch.version]
path = "bdms/__init__.py"



# this puts hatch envs in a .hatch directory, so vscode can find them


Expand Down Expand Up @@ -102,3 +104,6 @@ format = [
"black .",
"docformatter --black --in-place **/*.py",
]

[tool.flake8]
exclude = ".venv,venv"