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

deep_copy_value() to accept None #383

Merged
merged 1 commit into from
Apr 5, 2024
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 spinedb_api/parameter_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -1745,7 +1745,7 @@ def deep_copy_value(value):
Returns:
Any: deep-copied value
"""
if isinstance(value, (Number, str)):
if isinstance(value, (Number, str)) or value is None:
return value
if isinstance(value, Array):
return Array(value.values, value.value_type, value.index_name)
Expand Down
3 changes: 3 additions & 0 deletions tests/test_parameter_value.py
Original file line number Diff line number Diff line change
Expand Up @@ -1005,6 +1005,9 @@ def convert_map_to_dict(self):
self.assertEqual(nested_map, {"A": {"a": -3.2, "b": -2.3}, "B": {"c": 3.2, "d": 2.3}})

def test_deep_copy_value_for_scalars(self):
x = None
copy_of_x = deep_copy_value(x)
self.assertIsNone(copy_of_x)
x = 1.0
copy_of_x = deep_copy_value(x)
self.assertEqual(x, copy_of_x)
Expand Down