Skip to content

Commit

Permalink
update type stub to include indexing with np.integer (#36)
Browse files Browse the repository at this point in the history
  • Loading branch information
NoureldinYosri authored Feb 12, 2025
2 parents 27f1bed + 74b45c5 commit 05d5eb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 3 additions & 0 deletions test/test_value_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,9 @@ def test_multi_index() -> None:
with pytest.raises(IndexError):
_ = (m * [[2, 3, 4], [5, 6, 7], [8, 9, 10]])[1:3, 25483]

idx = np.argmax([1, 4, -1])
assert (m * [1, 2, 4])[idx] == m * 2


def test_predicate_index() -> None:
from tunits.units import m
Expand Down
2 changes: 1 addition & 1 deletion tunits/core/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ class ValueArray(Generic[ValueType2], WithUnit):
@overload
def __getitem__(self, key: str | Value) -> NDArray[Any]: ...
@overload
def __getitem__(self, key: int) -> ValueType2: ...
def __getitem__(self, key: int | np.integer) -> ValueType2: ...
@overload
def __getitem__(self: ArrayType, key: slice | tuple[Any, ...] | NDArray[Any]) -> ArrayType: ...
def value_in_base_units(self) -> NDArray[Any]: ...
Expand Down

0 comments on commit 05d5eb4

Please sign in to comment.