Skip to content
Open
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
4 changes: 2 additions & 2 deletions piel/analysis/metrics/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ def rename_metrics_collection(
# Create a new list of metrics with updated names
updated_metrics = []
for metric, new_name in zip(collection.metrics, new_names):
updated_metric = metric.copy(update={"name": new_name})
updated_metric = metric.model_copy(update={"name": new_name})
updated_metrics.append(updated_metric)

# Return a new ScalarMetricCollection with the updated metrics
return collection.copy(update={"metrics": updated_metrics})
return collection.model_copy(update={"metrics": updated_metrics})
4 changes: 2 additions & 2 deletions piel/types/digital.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def dataframe(self) -> pd.DataFrame:
"""
data = {
k: v
for k, v in self.dict().items()
for k, v in self.model_dump().items()
if k not in {"input_ports", "output_ports"}
}
return pd.DataFrame(data)
Expand All @@ -117,7 +117,7 @@ def implementation_dictionary(self) -> dict:
dict: A dictionary with keys that are part of the input and output connection.
"""
selected_ports = set(self.input_ports + self.output_ports)
filtered_dict = {k: v for k, v in self.dict().items() if k in selected_ports}
filtered_dict = {k: v for k, v in self.model_dump().items() if k in selected_ports}
return filtered_dict


Expand Down
2 changes: 1 addition & 1 deletion piel/types/digital_electro_optic.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def dataframe(self) -> pd.DataFrame:
Returns:
pd.DataFrame: A DataFrame containing the bits and their corresponding phases.
"""
return pd.DataFrame(self.dict())
return pd.DataFrame(self.model_dump())


"""
Expand Down
8 changes: 4 additions & 4 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,19 @@ jaxlib = ">=0.4.14,<0.5.0"
jaxtyping = "*"
matplotlib = "*"
networkx = ">=3.1,<4.0"
numpy = ">=1.24.4,<2.0.0"
numpy = "==2.2"
pandas = ">=1.5.3,<2.0.0"
pydantic = ">=2.0,<3.0"
scipy = ">=1.11.4,<2.0.0"
setuptools = "*"
xarray = ">=2024.1.0,<2024.10.0"
xarray = "==2025.1.2"

# TOOLS
amaranth = { version = ">=0.4.0,<0.5.0", optional = true }
amaranth-yosys = { version = ">=0.40.0.0.post94,<0.41.0", optional = true }
cocotb = { version = "==1.9.1", optional = true }
gdsfactory = { version = "==7.27.2", optional = true }
gplugins = { version = ">=0.14.0,<0.15.0", extras = ["schematic"], optional = true }
gdsfactory = { version = ">=9.3.5", optional = true }
gplugins = { version = ">=1.4.0", extras = ["schematic"], optional = true }
hdl21 = { version = ">=6.0.0,<7.0.0", optional = true }
qutip = { version = ">=4.7,<5.0", optional = true }
sax = { version = "==0.12.2", optional = true } # Pinned for pydantic <v2 compatibility
Expand Down
2 changes: 1 addition & 1 deletion tests/analysis/metrics/test_units.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def test_convert_scalar_metric_unit_incompatible_units():
# Call function and expect ValueError
with pytest.raises(
ValueError,
match="Cannot convert from unit 'volt' \(datum: voltage\) to unit 'ampere' \(datum: ampere\). Units are incompatible.",
match=r"Cannot convert from unit 'volt' \(datum: voltage\) to unit 'ampere' \(datum: ampere\). Units are incompatible.",
):
convert_scalar_metric_unit(metric, target_unit)

Expand Down
4 changes: 2 additions & 2 deletions tests/analysis/signals/time/core/test_dimension.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ def create_scalar_metric(
standard_deviation=std_dev,
count=count,
unit=unit,
).copy(update={"name": name})
).model_copy(update={"name": name})


# Helper function to create ScalarMetricCollection
Expand Down Expand Up @@ -108,7 +108,7 @@ def test_rename_metrics_collection_length_mismatch():

new_names = ["New Metric1", "Extra Metric"]

with pytest.raises(ValueError, match="Number of new names \(2\) does not match"):
with pytest.raises(ValueError, match=r"Number of new names \(2\) does not match"):
rename_metrics_collection(collection, new_names)


Expand Down
8 changes: 4 additions & 4 deletions tests/analysis/signals/time/core/test_transiton.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def test_offset_time_signals_empty_time_s():
multi_signal = [signal]

with pytest.raises(
ValueError, match="Signal 'EmptySignal' has an empty time_s array\."
ValueError, match=r"Signal 'EmptySignal' has an empty time_s array\."
):
offset_time_signals(multi_signal)

Expand Down Expand Up @@ -329,7 +329,7 @@ def test_extract_rising_edges_empty_data():
)

with pytest.raises(
ValueError, match="time_s and data must be of the same length\."
ValueError, match=r"time_s and data must be of the same length\."
):
extract_rising_edges(
signal, lower_threshold_ratio=0.1, upper_threshold_ratio=0.9
Expand Down Expand Up @@ -571,7 +571,7 @@ def test_extract_rising_edges_mismatched_time_data_lengths():
)

with pytest.raises(
ValueError, match="time_s and data must be of the same length\."
ValueError, match=r"time_s and data must be of the same length\."
):
extract_rising_edges(
signal, lower_threshold_ratio=0.1, upper_threshold_ratio=0.9
Expand Down Expand Up @@ -623,7 +623,7 @@ def test_extract_rising_edges_signal_with_no_data():
)

with pytest.raises(
ValueError, match="time_s and data must be of the same length\."
ValueError, match=r"time_s and data must be of the same length\."
):
extract_rising_edges(
signal, lower_threshold_ratio=0.1, upper_threshold_ratio=0.9
Expand Down
2 changes: 2 additions & 0 deletions tests/integration/signal/frequency/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# test_network_conversion.py

import pytest

pytest.importorskip("skrf")
import skrf
import numpy as np

Expand Down
2 changes: 2 additions & 0 deletions tests/tools/amaranth/test_construct.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest

pytest.importorskip("amaranth")
import amaranth as am
from piel.tools.amaranth import (
construct_amaranth_module_from_truth_table,
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/amaranth/test_export.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest

pytest.importorskip("amaranth")
import amaranth as am
from piel.tools.amaranth import generate_verilog_from_amaranth_truth_table
from piel.types import TruthTable
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/amaranth/test_verify.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import pytest

pytest.importorskip("amaranth")
import amaranth as am
from piel.tools.amaranth import verify_amaranth_truth_table
from piel.types import TruthTable # Adjust the import based on your actual module path
Expand Down
2 changes: 2 additions & 0 deletions tests/tools/skrf/test_convert.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import pytest
import numpy as np

pytest.importorskip("skrf")
import skrf as rf

# Import the function to be tested
Expand Down
2 changes: 2 additions & 0 deletions tests/types/test_type_conversion.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import numpy as np
import jax.numpy as jnp
import pandas as pd

pytest.importorskip("qutip")
import qutip

import piel.types
Expand Down
Loading