(a, axis)
| 1975 | |
| 1976 | @derived_from(np) |
| 1977 | def expand_dims(a, axis): |
| 1978 | if type(axis) not in (tuple, list): |
| 1979 | axis = (axis,) |
| 1980 | |
| 1981 | out_ndim = len(axis) + a.ndim |
| 1982 | axis = validate_axis(axis, out_ndim) |
| 1983 | |
| 1984 | shape_it = iter(a.shape) |
| 1985 | shape = [1 if ax in axis else next(shape_it) for ax in range(out_ndim)] |
| 1986 | |
| 1987 | return a.reshape(shape) |
| 1988 | |
| 1989 | |
| 1990 | @derived_from(np) |
nothing calls this directly
no test coverage detected
searching dependent graphs…