From 6d5c4867492142bcfb917ba79b2a4cafc8e0dd9d Mon Sep 17 00:00:00 2001 From: Iglesia Dolci Date: Mon, 26 Feb 2024 10:50:10 +0000 Subject: [PATCH 1/3] Remove hint that is not working for python3.8 --- pyadjoint/tape.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pyadjoint/tape.py b/pyadjoint/tape.py index 996527c1..63759d19 100644 --- a/pyadjoint/tape.py +++ b/pyadjoint/tape.py @@ -6,8 +6,6 @@ from functools import wraps from itertools import chain from abc import ABC, abstractmethod -from typing import Optional -from collections.abc import Iterable from .checkpointing import CheckpointManager, CheckpointError _working_tape = None @@ -770,9 +768,17 @@ class TimeStepSequence(list): This behaves like a list of blocks. To access a list of the timesteps, use the :attr:`steps` property. + + Args: + blocks (list[Block] or TimeStepSequence, optional): If provided, `blocks` can be a list of :class:`Block` + or another TimeStepSequence to copy from. + steps (list[TimeStep], optional): If provided, `steps` should be a list of :class:`TimeStep` to copy from. + + Atributes: + steps (list[TimeStep]): A list of timesteps. """ - def __init__(self, blocks=None, steps: Optional[Iterable[Iterable[TimeStep]]] = None): + def __init__(self, blocks=None, steps=None): # Keep both per-timestep and unified block lists. if steps and blocks: raise ValueError("set blocks or steps but not both.") From f4e9c64e5f1e44bfe21cc41e9a3901fdf03ed3d7 Mon Sep 17 00:00:00 2001 From: Iglesia Dolci Date: Mon, 26 Feb 2024 11:37:41 +0000 Subject: [PATCH 2/3] Import Iterable from typing. --- pyadjoint/tape.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pyadjoint/tape.py b/pyadjoint/tape.py index 63759d19..2b423919 100644 --- a/pyadjoint/tape.py +++ b/pyadjoint/tape.py @@ -5,6 +5,7 @@ from contextlib import contextmanager from functools import wraps from itertools import chain +from typing import Optional, Iterable from abc import ABC, abstractmethod from .checkpointing import CheckpointManager, CheckpointError @@ -778,7 +779,7 @@ class TimeStepSequence(list): steps (list[TimeStep]): A list of timesteps. """ - def __init__(self, blocks=None, steps=None): + def __init__(self, blocks=None, steps: Optional[Iterable[Iterable[TimeStep]]] = None): # Keep both per-timestep and unified block lists. if steps and blocks: raise ValueError("set blocks or steps but not both.") From 72cb31c4a6879ec0bae3ad89c11f3d64460c8664 Mon Sep 17 00:00:00 2001 From: Daiane Iglesia Dolci <63597005+Ig-dolci@users.noreply.github.com> Date: Mon, 26 Feb 2024 11:44:51 +0000 Subject: [PATCH 3/3] Update pyadjoint/tape.py Co-authored-by: Connor Ward --- pyadjoint/tape.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyadjoint/tape.py b/pyadjoint/tape.py index 2b423919..0774d260 100644 --- a/pyadjoint/tape.py +++ b/pyadjoint/tape.py @@ -775,7 +775,7 @@ class TimeStepSequence(list): or another TimeStepSequence to copy from. steps (list[TimeStep], optional): If provided, `steps` should be a list of :class:`TimeStep` to copy from. - Atributes: + Attributes: steps (list[TimeStep]): A list of timesteps. """