|
23 | 23 | nomask, ones, zeros, count
|
24 | 24 | )
|
25 | 25 | from numpy.ma.extras import (
|
26 |
| - atleast_2d, mr_, dot, polyfit, cov, corrcoef, median, average, unique, |
27 |
| - setxor1d, setdiff1d, union1d, intersect1d, in1d, ediff1d, |
28 |
| - apply_over_axes, apply_along_axis, compress_nd, compress_rowcols, |
| 26 | + atleast_1d, atleast_2d, atleast_3d, mr_, dot, polyfit, cov, corrcoef, |
| 27 | + median, average, unique, setxor1d, setdiff1d, union1d, intersect1d, in1d, |
| 28 | + ediff1d, apply_over_axes, apply_along_axis, compress_nd, compress_rowcols, |
29 | 29 | mask_rowcols, clump_masked, clump_unmasked, flatnotmasked_contiguous,
|
30 |
| - notmasked_contiguous, notmasked_edges, masked_all, masked_all_like |
| 30 | + notmasked_contiguous, notmasked_edges, masked_all, masked_all_like, |
| 31 | + diagflat |
31 | 32 | )
|
32 | 33 | import numpy.ma.extras as mae
|
33 | 34 |
|
@@ -1127,6 +1128,25 @@ def test_atleast2d(self):
|
1127 | 1128 | assert_equal(a.shape, (3,))
|
1128 | 1129 | assert_equal(a.mask.shape, a.data.shape)
|
1129 | 1130 |
|
| 1131 | + def test_shape_scalar(self): |
| 1132 | + # the atleast and diagflat function should work with scalars |
| 1133 | + # GitHub issue #3367 |
| 1134 | + b = atleast_1d(1.0) |
| 1135 | + assert_equal(b.shape, (1, )) |
| 1136 | + assert_equal(b.mask.shape, b.data.shape) |
| 1137 | + |
| 1138 | + b = atleast_2d(1.0) |
| 1139 | + assert_equal(b.shape, (1, 1)) |
| 1140 | + assert_equal(b.mask.shape, b.data.shape) |
| 1141 | + |
| 1142 | + b = atleast_3d(1.0) |
| 1143 | + assert_equal(b.shape, (1, 1, 1)) |
| 1144 | + assert_equal(b.mask.shape, b.data.shape) |
| 1145 | + |
| 1146 | + b = diagflat(1.0) |
| 1147 | + assert_equal(b.shape, (1, 1)) |
| 1148 | + assert_equal(b.mask.shape, b.data.shape) |
| 1149 | + |
1130 | 1150 |
|
1131 | 1151 | if __name__ == "__main__":
|
1132 | 1152 | run_module_suite()
|
0 commit comments