Skip to content

Commit 6ca0380

Browse files
committed
Rename methods making the names consistent with existing methods
1 parent d43dfed commit 6ca0380

3 files changed

Lines changed: 11 additions & 11 deletions

File tree

eitprocessing/datahandling/continuousdata.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def __setattr__(self, attr: str, value: Any): # noqa: ANN401
5757
except AttributeError:
5858
pass
5959
else:
60-
if self.is_lockable(attr) and self.is_locked(attr):
60+
if self.islockable(attr) and self.islocked(attr):
6161
msg = f"Attribute '{attr}' is locked and can't be overwritten."
6262
raise AttributeError(msg)
6363
super().__setattr__(attr, value)

eitprocessing/datahandling/mixins/locking.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
class Lockable:
88
"""Adds locking functionality to subclass.
99
10-
This class provides the methods lock(), unlock(), lock_all(), unlock_all(), is_locked() and is_lockable(), and the
10+
This class provides the methods lock(), unlock(), lock_all(), unlock_all(), islocked() and islockable(), and the
1111
property _lock_action_defaults.
1212
"""
1313

@@ -29,7 +29,7 @@ def lock(self, *attr: str) -> None:
2929
# default values are not allowed when using *attr, so set a default here if none is supplied
3030
attr = tuple(self._lock_action_defaults)
3131
for attr_ in attr:
32-
if not self.is_lockable(attr_):
32+
if not self.islockable(attr_):
3333
msg = f"Attribute {attr_} is not lockable."
3434
raise ValueError(msg)
3535
getattr(self, attr_).flags["WRITEABLE"] = False
@@ -59,7 +59,7 @@ def unlock(self, *attr: str) -> None:
5959
# default values are not allowed when using *attr, so set a default here if none is supplied
6060
attr = tuple(self._lock_action_defaults)
6161
for attr_ in attr:
62-
if not self.is_lockable(attr_):
62+
if not self.islockable(attr_):
6363
msg = f"Attribute {attr_} is not (un)lockable."
6464
raise ValueError(msg)
6565
getattr(self, attr_).flags["WRITEABLE"] = True
@@ -70,7 +70,7 @@ def lock_all(self) -> None:
7070
See lock().
7171
"""
7272
for attr in vars(self):
73-
if self.is_lockable(attr):
73+
if self.islockable(attr):
7474
self.lock(attr)
7575

7676
def unlock_all(self) -> None:
@@ -79,17 +79,17 @@ def unlock_all(self) -> None:
7979
See unlock().
8080
"""
8181
for attr in vars(self):
82-
if self.is_lockable(attr):
82+
if self.islockable(attr):
8383
self.unlock(attr)
8484

85-
def is_locked(self, attr: str = "values") -> bool:
85+
def islocked(self, attr: str = "values") -> bool:
8686
"""Return whether an attribute is locked.
8787
8888
See lock().
8989
"""
9090
return not getattr(self, attr).flags["WRITEABLE"]
9191

92-
def is_lockable(self, attr: str = "values") -> bool:
92+
def islockable(self, attr: str = "values") -> bool:
9393
"""Return whether an attribute is lockable.
9494
9595
See lock().

tests/test_locking.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,13 @@ def test_lock_continuousdata_values(draeger1: Sequence):
1313
pytest.fail("No continuous data available in sequence")
1414

1515
assert isinstance(cd, ContinuousData)
16-
assert cd.is_lockable("values")
17-
assert cd.is_locked("values")
16+
assert cd.islockable("values")
17+
assert cd.islocked("values")
1818
try:
1919
cd.unlock("values")
2020
except:
2121
pytest.fail("Can't unlock attribute")
22-
assert not cd.is_locked("values")
22+
assert not cd.islocked("values")
2323
try:
2424
cd.lock("values")
2525
except:

0 commit comments

Comments
 (0)