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

Allow parameter value to be changed even if parameter is not enabled #85

Merged
merged 1 commit into from
Nov 11, 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
4 changes: 0 additions & 4 deletions src/easyscience/Objects/Variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -304,10 +304,6 @@ def value(self, value: Any):
:param value: New value of self
:return: None
"""
if not self.enabled:
if global_object.debug:
raise CoreSetException(f'{str(self)} is not enabled.')
return
self.__deepValueSetter(value)
if self._callback.fset is not None:
try:
Expand Down
27 changes: 7 additions & 20 deletions tests/unit_tests/Objects/test_Descriptor_Parameter.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,32 +134,19 @@ def test_Parameter_value_get(element, expected):
def test_item_value_set(instance, enabled, debug):
global_object.debug = debug
set_value = 2

d = instance("test", 1)
if enabled is not None:
d.enabled = enabled
else:
enabled = True
if enabled:
d.value = set_value
assert d.raw_value == set_value
else:
if debug:
with pytest.raises(CoreSetException):
d.value = set_value
d.value = set_value
assert d.raw_value == set_value

d = instance("test", 1, units="kelvin")
if enabled is not None:
d.enabled = enabled
else:
enabled = True

if enabled:
d.value = set_value
assert d.raw_value == set_value
assert str(d.unit) == "kelvin"
else:
if debug:
with pytest.raises(CoreSetException):
d.value = set_value
d.value = set_value
assert d.raw_value == set_value
assert str(d.unit) == "kelvin"


@pytest.mark.parametrize("instance", (Descriptor, Parameter), indirect=True)
Expand Down
Loading