diff --git a/tests/profiler/plot_memory_timeline.py b/tests/profiler/plot_memory_timeline.py index 8eb161ab..3c6a9e9a 100644 --- a/tests/profiler/plot_memory_timeline.py +++ b/tests/profiler/plot_memory_timeline.py @@ -3,6 +3,8 @@ Reads memory traces from json files and plots them on a single graph. """ +from __future__ import annotations + import argparse import json from dataclasses import dataclass @@ -24,7 +26,7 @@ class MemoryFrame: device_id: int # -1 for CPU, 0+ for CUDA devices @staticmethod - def from_event(event: dict) -> "MemoryFrame": + def from_event(event: dict) -> MemoryFrame: args = event["args"] return MemoryFrame( timestamp=event["ts"], diff --git a/tests/trajectories/_objectives.py b/tests/trajectories/_objectives.py index c6497552..939f7e25 100644 --- a/tests/trajectories/_objectives.py +++ b/tests/trajectories/_objectives.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from abc import ABC, abstractmethod import torch @@ -77,7 +79,7 @@ def quad(x: Tensor, A: Tensor, u: Tensor) -> Tensor: return x_minus_u @ A @ x_minus_u @property - def sps_mapping(self) -> "QuadraticSPSMapping": + def sps_mapping(self) -> QuadraticSPSMapping: return QuadraticSPSMapping(self.As, self.us) @@ -118,7 +120,7 @@ def jacobian(self, x: Tensor) -> Tensor: return torch.diag(torch.stack([2 * x[0], 2 * x[1]])) @property - def sps_mapping(self) -> "ElementWiseQuadraticSPSMapping": + def sps_mapping(self) -> ElementWiseQuadraticSPSMapping: return ElementWiseQuadraticSPSMapping(self.n_values) diff --git a/tests/trajectories/_plotters.py b/tests/trajectories/_plotters.py index 82f18377..47078da4 100644 --- a/tests/trajectories/_plotters.py +++ b/tests/trajectories/_plotters.py @@ -1,3 +1,5 @@ +from __future__ import annotations + from abc import ABC, abstractmethod from typing import TypeAlias @@ -16,7 +18,7 @@ class Plotter(ABC): def __call__(self, ax: plt.Axes) -> None: pass - def __add__(self, other: "Plotter") -> "Plotter": + def __add__(self, other: Plotter) -> Plotter: return MultiPlotter((self, other)) @@ -30,7 +32,7 @@ def __call__(self, ax: plt.Axes) -> None: class MultiPlotter(Plotter): """Plotter applying several plotters.""" - def __init__(self, plotters: tuple["Plotter", ...]) -> None: + def __init__(self, plotters: tuple[Plotter, ...]) -> None: self.plotters = plotters def __call__(self, ax: plt.Axes) -> None: