Skip to content

Commit

Permalink
fix bug where it assumed the flags array has a shape big enough to se…
Browse files Browse the repository at this point in the history
…t all bits (reported by Amy Rankine)
  • Loading branch information
andycasey committed Jan 25, 2024
1 parent 2e63e23 commit 6dab20a
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions python/sdss_semaphore/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ def is_attribute_set(self, key, value) -> np.array:
if len(bits) == 0:
raise ValueError(f"No bits found with attribute {key}={value}")
num, offset = np.divmod(bits, self.n_bits)
return np.any(self.array[:, num] & (1 << offset), axis=1)
N, B = self.array.shape
can_be_set = B > num
return np.any(self.array[:, num[can_be_set]] & (1 << offset[can_be_set]), axis=1)


def get_bits_with_attribute(self, key, value) -> List[int]:
"""
Expand Down Expand Up @@ -342,7 +345,4 @@ def __repr__(self):

def __len__(self):
N, B = self.array.shape
return N



return N

0 comments on commit 6dab20a

Please sign in to comment.