Skip to content

Commit

Permalink
style: Remove unnecessary asserts
Browse files Browse the repository at this point in the history
Remove unnecessary `isinstance` checks.
In an era of `mypy` these asserts are not
necessary. They reduce readability.
  • Loading branch information
riddell-stan committed Feb 8, 2021
1 parent bb39e25 commit da21bb6
Showing 1 changed file with 0 additions and 8 deletions.
8 changes: 0 additions & 8 deletions stan/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ def sample(self, **kwargs) -> stan.fit.Fit:
Fit: instance of Fit allowing access to draws.
"""
assert isinstance(self.data, dict)
assert "chain" not in kwargs, "`chain` id is set automatically."
assert "data" not in kwargs, "`data` is set in `build`."
assert "random_seed" not in kwargs, "`random_seed` is set in `build`."
Expand Down Expand Up @@ -194,7 +193,6 @@ def is_iteration_or_elapsed_time_logger_message(msg: simdjson.Object):
parser = simdjson.Parser()
nonstandard_logger_messages = []
for stan_output in stan_outputs:
assert isinstance(stan_output, bytes)
for line in stan_output.splitlines():
# Do not attempt to parse non-logger messages. Draws could contain nan or inf values.
# simdjson cannot parse lines containing such values.
Expand Down Expand Up @@ -258,8 +256,6 @@ def constrain_pars(
The unconstrained parameters are passed to the `write_array` method of the `model_base`
instance. See `model_base.hpp` in the Stan C++ library for details.
"""
assert isinstance(self.data, dict)

payload = {
"data": self.data,
"unconstrained_parameters": unconstrained_parameters,
Expand Down Expand Up @@ -292,8 +288,6 @@ def unconstrain_pars(self, constrained_parameters: List[float]) -> List[float]:
The unconstrained parameters are passed to the `transform_inits` method of the
`model_base` instance. See `model_base.hpp` in the Stan C++ library for details.
"""
assert isinstance(self.data, dict)

payload = {"data": self.data, "constrained_parameters": constrained_parameters}

async def go():
Expand Down Expand Up @@ -322,8 +316,6 @@ def log_prob(self, unconstrained_parameters: List[float], adjust_transform: bool
function in stan::model.
"""
assert isinstance(self.data, dict)

payload = {
"data": self.data,
"unconstrained_parameters": unconstrained_parameters,
Expand Down

0 comments on commit da21bb6

Please sign in to comment.