diff --git a/b_asic/save_load_structure.py b/b_asic/save_load_structure.py index 57a2792e181ce6173ce8f1517a2d9cbf5d435ae7..1c8a70b544ad11aae2345a7dc29f3ddbbfce66e9 100644 --- a/b_asic/save_load_structure.py +++ b/b_asic/save_load_structure.py @@ -33,6 +33,9 @@ def sfg_to_python( True if printing a schedule. """ + if not isinstance(sfg, SFG): + raise TypeError("An SFG must be provided") + _type = "Schedule" if schedule else "SFG" result = ( @@ -139,7 +142,7 @@ def sfg_to_python( def python_to_sfg(path: str) -> Tuple[SFG, Dict[str, Tuple[int, int]]]: """ - Given a serialized file try to deserialize it and load it to the library. + Given a serialized file, try to deserialize it and load it to the library. Parameters ========== @@ -167,6 +170,8 @@ def schedule_to_python(schedule: Schedule) -> str: schedule : Schedule The schedule to serialize. """ + if not isinstance(schedule, Schedule): + raise TypeError("A Schedule must be provided") sfg_name = ( schedule.sfg.name.replace(" ", "_").replace("-", "_") if schedule.sfg.name diff --git a/b_asic/schedule.py b/b_asic/schedule.py index 5bbfc2a6ad93c8c3c273b81c3a77289ca8541dd1..cff3a16681ca69b88a605bf3bae7e15d99cdb259 100644 --- a/b_asic/schedule.py +++ b/b_asic/schedule.py @@ -83,6 +83,9 @@ class Schedule: laps: Optional[Dict[GraphID, int]] = None, ): """Construct a Schedule from an SFG.""" + if not isinstance(sfg, SFG): + raise TypeError("An SFG must be provided") + self._original_sfg = sfg() # Make a copy self._sfg = sfg self._start_times = {} diff --git a/b_asic/simulation.py b/b_asic/simulation.py index 20716a42045e234a80e6d4b2e7d63acd43c0482e..bd4ae903bc0f2f11bd8998787a150db5476b9663 100644 --- a/b_asic/simulation.py +++ b/b_asic/simulation.py @@ -59,6 +59,9 @@ class Simulation: input_providers: Optional[Sequence[Optional[InputProvider]]] = None, ): """Construct a Simulation of an SFG.""" + if not isinstance(sfg, SFG): + raise TypeError("An SFG must be provided") + # Copy the SFG to make sure it's not modified from the outside. self._sfg = sfg() self._results = defaultdict(list)