Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion LICENCE.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steer-core - Dual Licensed

Copyright (c) 2024-2026 Nicholas Siemons
Copyright (c) 2024-2026 Stanford University

1. Open-source license: GNU Affero General Public License v3.0 (AGPL-3.0)
See the full AGPL-3.0 license text below.
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Constants/Format.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

## DateTime format strings
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Constants/Units.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

## Unit conversions
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Constants/Universal.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

## Constants
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Constants/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later
2 changes: 1 addition & 1 deletion steer_core/Data/DataManager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Data/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import os
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Decorators/Coordinates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from steer_core.Decorators.General import recalculate
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Decorators/General.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from functools import wraps
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Decorators/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later
2 changes: 1 addition & 1 deletion steer_core/Mixins/Colors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/Coordinates.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import numpy as np
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/Data.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from copy import deepcopy
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/DateTime.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

# steer_core/Mixins/DateTime.py
Expand Down
15 changes: 7 additions & 8 deletions steer_core/Mixins/Datum.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Mixin providing standard datum property interface with mm/m unit conversion."""

from typing import Tuple
import numpy as np

from steer_core.Constants.Units import M_TO_MM, MM_TO_M

Expand Down Expand Up @@ -60,9 +59,9 @@ def datum(self) -> Tuple[float, float, float]:
"""Datum position in millimeters."""
self._ensure_datum_exists()
return (
np.round(self._datum[0] * M_TO_MM, 2),
np.round(self._datum[1] * M_TO_MM, 2),
np.round(self._datum[2] * M_TO_MM, 2),
self._datum[0] * M_TO_MM,
self._datum[1] * M_TO_MM,
self._datum[2] * M_TO_MM,
)

@datum.setter
Expand Down Expand Up @@ -104,7 +103,7 @@ def _compute_datum_translation(self, new_datum_mm: Tuple[float, float, float]) -
def datum_x(self) -> float:
"""X-coordinate of datum in millimeters."""
self._ensure_datum_exists()
return np.round(self._datum[0] * M_TO_MM, 2)
return self._datum[0] * M_TO_MM

@datum_x.setter
def datum_x(self, x: float) -> None:
Expand All @@ -115,7 +114,7 @@ def datum_x(self, x: float) -> None:
def datum_y(self) -> float:
"""Y-coordinate of datum in millimeters."""
self._ensure_datum_exists()
return np.round(self._datum[1] * M_TO_MM, 2)
return self._datum[1] * M_TO_MM

@datum_y.setter
def datum_y(self, y: float) -> None:
Expand All @@ -126,7 +125,7 @@ def datum_y(self, y: float) -> None:
def datum_z(self) -> float:
"""Z-coordinate of datum in millimeters."""
self._ensure_datum_exists()
return np.round(self._datum[2] * M_TO_MM, 2)
return self._datum[2] * M_TO_MM

@datum_z.setter
def datum_z(self, z: float) -> None:
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/Dunder.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@


# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import typing
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/Plotter.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from __future__ import annotations
Expand Down
22 changes: 20 additions & 2 deletions steer_core/Mixins/Propagation.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Mixin for update propagation through hierarchical object trees."""
Expand Down Expand Up @@ -368,4 +368,22 @@ def __deepcopy__(self, memo):
return result






















2 changes: 1 addition & 1 deletion steer_core/Mixins/Serializer.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import importlib
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/TypeChecker.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

from __future__ import annotations
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Mixins/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@

# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later
2 changes: 1 addition & 1 deletion steer_core/Utils/ControlModes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Generic utilities for multi-mode dependent property dispatch.
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Utils/CurveComposition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Generic utilities for composing paired directional curves.
Expand Down
2 changes: 1 addition & 1 deletion steer_core/Utils/CurveProcessing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Generic utilities for processing paired directional curves.
Expand Down
16 changes: 10 additions & 6 deletions steer_core/Utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Utility functions for the steer-core package."""

from typing import Any
from typing import Any, Optional

import numpy as np

Expand Down Expand Up @@ -39,21 +39,25 @@ def is_plotly_trace(obj: object) -> bool:


def round_dict_recursive(
obj: Any, precision: int = 2, unit_conversion: float = 1.0
obj: Any, precision: Optional[int] = 2, unit_conversion: float = 1.0
) -> Any:
"""Recursively round values in a nested dictionary.

Args:
obj: Dictionary or numeric value to round.
precision: Number of decimal places, by default 2.
precision: Number of decimal places, by default 2. If ``None``, apply
``unit_conversion`` only and do not round.
unit_conversion: Multiplicative factor applied before rounding, by default 1.0.

Returns:
Rounded dictionary or value.
Rounded dictionary or value (scaled if ``precision`` is ``None``).
"""
if isinstance(obj, dict):
return {
k: round_dict_recursive(v, precision, unit_conversion)
for k, v in obj.items()
}
return np.round(obj * unit_conversion, precision)
scaled = obj * unit_conversion
if precision is None:
return scaled
return np.round(scaled, precision)
4 changes: 2 additions & 2 deletions steer_core/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

__version__ = "0.2.12"
__version__ = "0.2.15"

from .Mixins.Colors import ColorMixin
from .Mixins.Coordinates import CoordinateMixin
Expand Down
2 changes: 1 addition & 1 deletion test/conftest.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Shared fixtures for steer-core tests."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_color_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Colors.ColorMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Constants modules."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_control_modes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Utils.ControlModes."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_coordinate_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Coordinates.CoordinateMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_curve_composition.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Utils.CurveComposition — generic paired curve composition."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_curve_processing.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Utils.CurveProcessing — generic paired curve utilities."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_data_manager.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Data.DataManager (mocked HTTP)."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_data_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Data.DataMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_datetime_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.DateTime.DateTimeMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_datum_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Datum.DatumMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_decorators.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Decorators."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_dunder_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Dunder.DunderMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_plotter_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Plotter.PlotterMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_propagation_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Propagation."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_serializer_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.Serializer.SerializerMixin."""
Expand Down
2 changes: 1 addition & 1 deletion test/test_typechecker_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Mixins.TypeChecker.ValidationMixin (beyond plotly trace tests)."""
Expand Down
11 changes: 10 additions & 1 deletion test/test_utils.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

"""Tests for steer_core.Utils."""
Expand Down Expand Up @@ -70,3 +70,12 @@ def test_integer_input(self):

def test_empty_dict(self):
assert round_dict_recursive({}) == {}

def test_precision_none_scales_without_rounding(self):
assert round_dict_recursive(3.14159265, precision=None) == pytest.approx(
3.14159265
)
result = round_dict_recursive(
{"a": 0.001}, precision=None, unit_conversion=1000.0
)
assert result["a"] == pytest.approx(1.0)
2 changes: 1 addition & 1 deletion test/test_validation_mixin.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# SPDX-FileCopyrightText: 2024-2026 Nicholas Siemons
# SPDX-FileCopyrightText: 2024-2026 Stanford University
# SPDX-License-Identifier: AGPL-3.0-or-later

import unittest
Expand Down
Loading