Skip to content

Commit

Permalink
chore: use NotImplementedError instead of 'TODO' (#9)
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski authored Jan 9, 2024
1 parent dda1f9d commit 19ddd26
Show file tree
Hide file tree
Showing 10 changed files with 166 additions and 166 deletions.
3 changes: 0 additions & 3 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,6 @@ ignore = [
"ISC001", # Conflicts with formatter
"RET505", # I like my if (return) elif (return) else (return) pattern
"PLR5501", # I like my if (return) elif (return) else (return) pattern

"PT015", # I'm using `assert False` for not-implemented FIXMEs
"B011", # (can't use NotImplementedError because it's used to incidate abstract methods)
]
isort.required-imports = ["from __future__ import annotations"]
# Uncomment if using a _compat.typing backport
Expand Down
24 changes: 13 additions & 11 deletions src/ragged/_spec_array_object.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ def __init__(
cp = _import.cupy()
self._impl = cp.array(self._impl)

assert copy is None, "TODO"
if copy is not None:
raise NotImplementedError("TODO 1") # noqa: EM101

def __str__(self) -> str:
"""
Expand Down Expand Up @@ -289,7 +290,7 @@ def mT(self) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.mT.html
"""

assert False, "TODO 1"
raise NotImplementedError("TODO 2") # noqa: EM101

@property
def ndim(self) -> int:
Expand Down Expand Up @@ -352,7 +353,7 @@ def T(self) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.T.html
"""

assert False, "TODO 2"
raise NotImplementedError("TODO 3") # noqa: EM101

# methods: https://data-apis.org/array-api/latest/API_specification/array_object.html#methods

Expand Down Expand Up @@ -451,8 +452,7 @@ def __dlpack__(self, *, stream: None | int | Any = None) -> PyCapsule:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack__.html
"""

assert stream, "TODO"
assert False, "TODO 9"
raise NotImplementedError("TODO 4") # noqa: EM101

def __dlpack_device__(self) -> tuple[enum.Enum, int]:
"""
Expand All @@ -464,7 +464,7 @@ def __dlpack_device__(self) -> tuple[enum.Enum, int]:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__dlpack_device__.html
"""

assert False, "TODO 10"
raise NotImplementedError("TODO 10") # noqa: EM101

def __eq__(self, other: int | float | bool | array, /) -> array: # type: ignore[override]
"""
Expand Down Expand Up @@ -533,7 +533,7 @@ def __getitem__(self, key: GetSliceKey, /) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__getitem__.html
"""

assert False, "TODO 15"
raise NotImplementedError("TODO 15") # noqa: EM101

def __gt__(self, other: int | float | array, /) -> array:
"""
Expand Down Expand Up @@ -641,7 +641,7 @@ def __matmul__(self, other: array, /) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__matmul__.html
"""

assert False, "TODO 22"
raise NotImplementedError("TODO 22") # noqa: EM101

def __mod__(self, other: int | float | array, /) -> array:
"""
Expand Down Expand Up @@ -782,7 +782,7 @@ def __setitem__(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.array.__setitem__.html
"""

assert False, "TODO 31"
raise NotImplementedError("TODO 31") # noqa: EM101

def __sub__(self, other: int | float | array, /) -> array:
"""
Expand Down Expand Up @@ -852,15 +852,17 @@ def to_device(self, device: Device, /, *, stream: None | int | Any = None) -> ar

if isinstance(self._impl, ak.Array):
if device != ak.backend(self._impl):
assert stream is None, "TODO"
if stream is not None:
raise NotImplementedError("TODO 124") # noqa: EM101
impl = ak.to_backend(self._impl, device)
else:
impl = self._impl

elif isinstance(self._impl, np.ndarray):
# self._impl is a NumPy 0-dimensional array
if device == "cuda":
assert stream is None, "TODO"
if stream is not None:
raise NotImplementedError("TODO 125") # noqa: EM101
cp = _import.cupy()
impl = cp.array(self._impl)
else:
Expand Down
129 changes: 65 additions & 64 deletions src/ragged/_spec_creation_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,12 @@ def arange(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.arange.html
"""

assert start, "TODO"
assert stop, "TODO"
assert step, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 35"
start # noqa: B018, pylint: disable=W0104
stop # noqa: B018, pylint: disable=W0104
step # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 35") # noqa: EM101


def asarray(
Expand Down Expand Up @@ -112,6 +112,7 @@ def asarray(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.asarray.html
"""

return array(obj, dtype=dtype, device=device, copy=copy)


Expand All @@ -136,10 +137,10 @@ def empty(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.empty.html
"""

assert shape, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 36"
shape # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 36") # noqa: EM101


def empty_like(
Expand All @@ -161,10 +162,10 @@ def empty_like(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.empty_like.html
"""

assert x, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 37"
x # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 37") # noqa: EM101


def eye(
Expand Down Expand Up @@ -196,12 +197,12 @@ def eye(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.eye.html
"""

assert n_rows, "TODO"
assert n_cols, "TODO"
assert k, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 38"
n_rows # noqa: B018, pylint: disable=W0104
n_cols # noqa: B018, pylint: disable=W0104
k # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 38") # noqa: EM101


def from_dlpack(x: object, /) -> array:
Expand All @@ -217,8 +218,8 @@ def from_dlpack(x: object, /) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.from_dlpack.html
"""

assert x, "TODO"
assert False, "TODO 39"
x # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 39") # noqa: EM101


def full(
Expand Down Expand Up @@ -253,11 +254,11 @@ def full(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.full.html
"""

assert shape, "TODO"
assert fill_value, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 40"
shape # noqa: B018, pylint: disable=W0104
fill_value # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 40") # noqa: EM101


def full_like(
Expand Down Expand Up @@ -286,11 +287,11 @@ def full_like(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.full_like.html
"""

assert x, "TODO"
assert fill_value, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 41"
x # noqa: B018, pylint: disable=W0104
fill_value # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 41") # noqa: EM101


def linspace(
Expand Down Expand Up @@ -343,13 +344,13 @@ def linspace(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.linspace.html
"""

assert start, "TODO"
assert stop, "TODO"
assert num, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert endpoint, "TODO"
assert False, "TODO 42"
start # noqa: B018, pylint: disable=W0104
stop # noqa: B018, pylint: disable=W0104
num # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
endpoint # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 42") # noqa: EM101


def meshgrid(*arrays: array, indexing: str = "xy") -> list[array]:
Expand Down Expand Up @@ -388,9 +389,9 @@ def meshgrid(*arrays: array, indexing: str = "xy") -> list[array]:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.meshgrid.html
"""

assert arrays, "TODO"
assert indexing, "TODO"
assert False, "TODO 43"
arrays # noqa: B018, pylint: disable=W0104
indexing # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 43") # noqa: EM101


def ones(
Expand All @@ -414,10 +415,10 @@ def ones(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.ones.html
"""

assert shape, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 44"
shape # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 44") # noqa: EM101


def ones_like(
Expand All @@ -440,10 +441,10 @@ def ones_like(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.ones_like.html
"""

assert x, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 45"
x # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 45") # noqa: EM101


def tril(x: array, /, *, k: int = 0) -> array:
Expand All @@ -466,9 +467,9 @@ def tril(x: array, /, *, k: int = 0) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.tril.html
"""

assert x, "TODO"
assert k, "TODO"
assert False, "TODO 46"
x # noqa: B018, pylint: disable=W0104
k # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 46") # noqa: EM101


def triu(x: array, /, *, k: int = 0) -> array:
Expand All @@ -491,9 +492,9 @@ def triu(x: array, /, *, k: int = 0) -> array:
https://data-apis.org/array-api/latest/API_specification/generated/array_api.triu.html
"""

assert x, "TODO"
assert k, "TODO"
assert False, "TODO 47"
x # noqa: B018, pylint: disable=W0104
k # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 47") # noqa: EM101


def zeros(
Expand All @@ -517,10 +518,10 @@ def zeros(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.zeros.html
"""

assert shape, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 48"
shape # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 48") # noqa: EM101


def zeros_like(
Expand All @@ -543,7 +544,7 @@ def zeros_like(
https://data-apis.org/array-api/latest/API_specification/generated/array_api.zeros_like.html
"""

assert x, "TODO"
assert dtype, "TODO"
assert device, "TODO"
assert False, "TODO 49"
x # noqa: B018, pylint: disable=W0104
dtype # noqa: B018, pylint: disable=W0104
device # noqa: B018, pylint: disable=W0104
raise NotImplementedError("TODO 49") # noqa: EM101
Loading

0 comments on commit 19ddd26

Please sign in to comment.