Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix touchstone deepcopy issue #3892

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 _unittest/test_44_TouchstoneParser.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def test_02_read_ts_file(self):
ts1 = TouchstoneData(touchstone_file=os.path.join(test_T44_dir, "port_order_1234.s8p"))
assert ts1.get_mixed_mode_touchstone_data()
ts2 = TouchstoneData(touchstone_file=os.path.join(test_T44_dir, "port_order_1324.s8p"))
assert ts1.get_mixed_mode_touchstone_data(port_ordering="1324")
assert ts2.get_mixed_mode_touchstone_data(port_ordering="1324")

assert ts1.plot_insertion_losses(plot=False)
assert ts1.get_worst_curve(curve_list=ts1.get_return_loss_index(), plot=False)
16 changes: 14 additions & 2 deletions pyaedt/generic/touchstone_parser.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from copy import deepcopy as copy
from copy import deepcopy
Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved
Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved
import itertools
import os
import re
Expand Down Expand Up @@ -86,6 +86,18 @@
rf.Network.__init__(self, touchstone_file)
self.log_x = True

def __deepcopy__(self, memo):
cls = self.__class__
result = cls.__new__(cls)
memo[id(self)] = result

for key, value in self.__dict__.items():
if key == "solution_data":
setattr(result, key, value)

Check warning on line 96 in pyaedt/generic/touchstone_parser.py

View check run for this annotation

Codecov / codecov/patch

pyaedt/generic/touchstone_parser.py#L96

Added line #L96 was not covered by tests
else:
setattr(result, key, deepcopy(value, memo))
return result

Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved
@pyaedt_function_handler()
def get_insertion_loss_index(self, threshold=-3):
"""Get all insertion losses. The first frequency point is used to determine whether two
Expand Down Expand Up @@ -214,7 +226,7 @@
TouchstoneData
Samuelopez-ansys marked this conversation as resolved.
Show resolved Hide resolved

"""
ts_diff = copy(self)
ts_diff = deepcopy(self)
port_count = len(ts_diff.port_names)

if num_of_diff_ports is None:
Expand Down
Loading