Skip to content

Commit

Permalink
Fix logical error in array item checks (#138)
Browse files Browse the repository at this point in the history
The logical error in the check within the __getitem__ and __setitem__ methods of src/segy/arrays.py has been rectified. The previous condition was not ensuring that the items or keys passed were actually in self.dtype.names.

Co-authored-by: Altay Sansal <altay.sansal@tgs.com>
  • Loading branch information
tasansal and Altay Sansal authored Jun 21, 2024
1 parent ec0ce02 commit 481fa7f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/segy/arrays.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def __getitem__(self, item: Any) -> Any: # noqa: ANN401
if isinstance(item, str):
item = self._normalize_and_validate_keys(item)
elif isinstance(item, list) and all(isinstance(i, str) for i in item):
if all(key in item in self.dtype.names for key in item):
if all(key in self.dtype.names for key in item):
return super().__getitem__(item)

item = self._normalize_and_validate_keys(item)
Expand All @@ -143,7 +143,7 @@ def __setitem__(self, key: Any, value: Any) -> None: # noqa: ANN401
key = self._normalize_and_validate_keys(key)

elif isinstance(key, list) and all(isinstance(i, str) for i in key):
if all(k in key in self.dtype.names for k in key):
if all(k in self.dtype.names for k in key):
super().__setitem__(key, value) # type: ignore[no-untyped-call]
return

Expand Down

0 comments on commit 481fa7f

Please sign in to comment.