Skip to content

Type annotation and validation of exact in simulation.py #284

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
16 changes: 14 additions & 2 deletions ciw/simulation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class Simulation(object):
def __init__(
self,
network,
exact=False,
exact: int = 0,
name="Simulation",
tracker=None,
deadlock_detector=None,
Expand All @@ -32,8 +32,20 @@ def __init__(
server_class=None,
):
"""
Initialise an instance of the simualation.
Initialise an instance of the simulation.

This class supports exact arithmetic when `exact` is given a positive integer
representing the desired numerical precision. A precision of `0` is interpreted
to mean using ordinary float precision.
"""

# Input validation
if not isinstance(exact, int):
raise TypeError(f"{exact=} must be an integer.")
if exact < 0:
raise TypeError(f"{exact=} must be non-negative.")

# Assignments
self.current_time = 0.0
self.network = network
self.set_classes(node_class, arrival_node_class, exit_node_class, individual_class, server_class)
Expand Down
Loading