Skip to content

Commit ca64ab2

Browse files
committed
MAINT: atleast_nd: tweaks
1 parent 7ce7e2a commit ca64ab2

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

pixi.lock

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

+4-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pre-commit = { cmd = "pre-commit install && pre-commit run -v --all-files --show
7979
pylint = "*"
8080

8181
[tool.pixi.feature.lint.tasks]
82-
pylint = { cmd = ["pylint", "array_api_extra"], cwd = "src" }
82+
pylint = { cmd = "pylint", cwd = "src" }
8383
lint = { depends-on = ["pre-commit", "pylint"] }
8484

8585
[tool.pixi.feature.test.dependencies]
@@ -108,6 +108,9 @@ myst_parser = ">=0.13"
108108
sphinx_copybutton = "*"
109109
sphinx_autodoc_typehints = "*"
110110

111+
[tool.pixi.feature.docs.tasks]
112+
docs = { cmd = "sphinx-build . build/", cwd = "docs" }
113+
111114
[tool.pixi.feature.py309.dependencies]
112115
python = "~=3.9.0"
113116

src/array_api_extra/_funcs.py

+3-6
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,13 @@
1010

1111
def atleast_nd(x: Array, *, ndim: int, xp: ModuleType) -> Array:
1212
"""
13-
Recursively expand the dimension of an array to have at least `ndim`.
13+
Recursively expand the dimension of an array to at least `ndim`.
1414
1515
Parameters
1616
----------
1717
x: array
18-
An array.
19-
2018
ndim: int
2119
The minimum number of dimensions for the result.
22-
2320
xp: array_namespace
2421
The array namespace for `x`.
2522
@@ -28,9 +25,9 @@ def atleast_nd(x: Array, *, ndim: int, xp: ModuleType) -> Array:
2825
res: array
2926
An array with ``res.ndim`` >= `ndim`.
3027
If ``x.ndim`` >= `ndim`, `x` is returned.
31-
If ``x.ndim`` < `ndim`, ``res.ndim`` will equal `ndim`.
28+
If ``x.ndim`` < `ndim`, `x` is expanded by prepending new axes
29+
until ``res.ndim`` equals `ndim`.
3230
"""
33-
x = xp.asarray(x)
3431
if x.ndim < ndim:
3532
x = xp.expand_dims(x, axis=0)
3633
x = atleast_nd(x, ndim=ndim, xp=xp)

0 commit comments

Comments
 (0)