From 46b56a69ba0532d0e901ccf743e0aeaadb404076 Mon Sep 17 00:00:00 2001 From: Kauser Zulfiqar Date: Sun, 15 Dec 2024 21:35:15 +0100 Subject: [PATCH 1/3] removed_type_system --- discretisedfield/line.py | 32 ++++++++++++++++++++++---------- 1 file changed, 22 insertions(+), 10 deletions(-) diff --git a/discretisedfield/line.py b/discretisedfield/line.py index ce28022f..03b53213 100644 --- a/discretisedfield/line.py +++ b/discretisedfield/line.py @@ -4,14 +4,13 @@ import matplotlib.pyplot as plt import numpy as np import pandas as pd -import ubermagutil.typesystem as ts import ubermagutil.units as uu -@ts.typesystem( - dim=ts.Scalar(expected_type=int, positive=True, const=True), - n=ts.Scalar(expected_type=int, positive=True, const=True), -) +# @ts.typesystem( +# dim=ts.Scalar(expected_type=int, positive=True, const=True), +# n=ts.Scalar(expected_type=int, positive=True, const=True), +# ) class Line: """Line class. @@ -99,13 +98,18 @@ def __init__(self, points, values, point_columns, value_columns): raise ValueError(msg) # Set the dimension (const descriptor). - if isinstance(values[0], numbers.Complex): - self.dim = 1 - else: - self.dim = len(values[0]) + dim = 1 if isinstance(values[0], numbers.Complex) else len(values[0]) + + if not isinstance(dim, int) or dim <= 0: + raise ValueError(f"dim must be a positive integer, got {dim}.") # Set the number of values (const descriptor). - self.n = len(points) + n = len(points) + if not isinstance(n, int) or n <= 0: + raise ValueError(f"n must be a positive integer, got {n}.") + + self._dim = dim + self._n = n points = np.array(points) values = np.array(values).reshape((points.shape[0], -1)) @@ -121,6 +125,14 @@ def __init__(self, points, values, point_columns, value_columns): self._point_columns = list(point_columns) self._value_columns = list(value_columns) + @property + def dim(self): + return self._dim + + @property + def n(self): + return self._n + @property def point_columns(self): """The names of point columns. From 37f59caf8a52b35d8086c247248d6dc43f0ebcef Mon Sep 17 00:00:00 2001 From: Martin Lang <67915889+lang-m@users.noreply.github.com> Date: Sun, 2 Feb 2025 14:56:19 +0100 Subject: [PATCH 2/3] Update discretisedfield/line.py --- discretisedfield/line.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/discretisedfield/line.py b/discretisedfield/line.py index 03b53213..3802e4e7 100644 --- a/discretisedfield/line.py +++ b/discretisedfield/line.py @@ -7,10 +7,6 @@ import ubermagutil.units as uu -# @ts.typesystem( -# dim=ts.Scalar(expected_type=int, positive=True, const=True), -# n=ts.Scalar(expected_type=int, positive=True, const=True), -# ) class Line: """Line class. From cb4f3caf1d1a42bd5a4550259ba6e619c5bd512d Mon Sep 17 00:00:00 2001 From: Martin Lang Date: Sun, 2 Feb 2025 14:59:52 +0100 Subject: [PATCH 3/3] Bump version of pyvista/setup-headless-display action --- .github/workflows/workflow.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml index 96794396..1eab8cb1 100644 --- a/.github/workflows/workflow.yml +++ b/.github/workflows/workflow.yml @@ -28,7 +28,7 @@ jobs: uses: actions/checkout@v4 - name: Setup headless display - uses: pyvista/setup-headless-display-action@v2 + uses: pyvista/setup-headless-display-action@v3 - name: Set up conda uses: conda-incubator/setup-miniconda@v3