Skip to content

Commit

Permalink
empty
Browse files Browse the repository at this point in the history
  • Loading branch information
jpivarski committed Dec 27, 2023
1 parent 33eb9f5 commit efb61c9
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -173,4 +173,5 @@ messages_control.disable = [
"missing-class-docstring",
"missing-function-docstring",
"R1705", # I like my if (return) elif (return) else (return) pattern
"R0801", # Different files can have similar lines; that's okay
]
3 changes: 2 additions & 1 deletion src/ragged/common/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@

from __future__ import annotations

from ._creation import arange, asarray
from ._creation import arange, asarray, empty
from ._obj import array

__all__ = [
# _creation
"arange",
"asarray",
"empty",
# _obj
"array",
]
26 changes: 26 additions & 0 deletions src/ragged/common/_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,5 +106,31 @@ def asarray(
ValueError in case a copy would be necessary. If `None`, the
function reuses the existing memory buffer if possible and copies
otherwise.
https://data-apis.org/array-api/latest/API_specification/generated/array_api.asarray.html
"""
return array(obj, dtype=dtype, device=device, copy=copy)


def empty(
shape: int | tuple[int, ...],
*,
dtype: None | Dtype = None,
device: None | Device = None,
) -> array:
"""
Returns an uninitialized array having a specified shape.
Args:
shape: Output array shape.
dtype: Output array data type. If `dtype` is `None`, the output array
data type is `np.float64`.
device: Device on which to place the created array.
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"
3 changes: 2 additions & 1 deletion src/ragged/v202212/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,14 @@

from __future__ import annotations

from ._creation import arange, asarray
from ._creation import arange, asarray, empty
from ._obj import array

__all__ = [
# _creation
"arange",
"asarray",
"empty",
# _obj
"array",
]
4 changes: 2 additions & 2 deletions src/ragged/v202212/_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@

from __future__ import annotations

from ..common._creation import arange, asarray
from ..common._creation import arange, asarray, empty

__all__ = ["arange", "asarray"]
__all__ = ["arange", "asarray", "empty"]

0 comments on commit efb61c9

Please sign in to comment.