Skip to content

Commit 71c18e9

Browse files
committed
MAINT: Tweak documentation of broadcast.nd and broadcast.ndim.
Note that the newly added `ndim` property is an alias for `nd` and not available in numpy versions earlier than 1.12. Add back the tests for `nd`. They can be removed if/when `nd` is dropped.
1 parent e224923 commit 71c18e9

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

numpy/add_newdocs.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ def luf(lamdaexpr, *args, **kwargs):
554554

555555
add_newdoc('numpy.core', 'broadcast', ('ndim',
556556
"""
557-
Number of dimensions of broadcasted result.
557+
Number of dimensions of broadcasted result. Alias for `nd`.
558558
559559
.. versionadded:: 1.12.0
560560
@@ -570,7 +570,8 @@ def luf(lamdaexpr, *args, **kwargs):
570570

571571
add_newdoc('numpy.core', 'broadcast', ('nd',
572572
"""
573-
Number of dimensions of broadcasted result. Alias for `ndim`.
573+
Number of dimensions of broadcasted result. For code intended for Numpy
574+
1.12.0 and later the more consistent `ndim` is preferred.
574575
575576
Examples
576577
--------

numpy/core/tests/test_numeric.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2496,6 +2496,7 @@ def test_broadcast_in_args(self):
24962496
for mit in mits:
24972497
assert_equal(mit.shape, (5, 6, 7))
24982498
assert_equal(mit.ndim, 3)
2499+
assert_equal(mit.nd, 3)
24992500
assert_equal(mit.numiter, 4)
25002501
for a, ia in zip(arrs, mit.iters):
25012502
assert_(a is ia.base)
@@ -2506,6 +2507,7 @@ def test_broadcast_single_arg(self):
25062507
mit = np.broadcast(*arrs)
25072508
assert_equal(mit.shape, (5, 6, 7))
25082509
assert_equal(mit.ndim, 3)
2510+
assert_equal(mit.nd, 3)
25092511
assert_equal(mit.numiter, 1)
25102512
assert_(arrs[0] is mit.iters[0].base)
25112513

0 commit comments

Comments
 (0)