Skip to content

Commit 51a6bf0

Browse files
committed
1 parent 4db4621 commit 51a6bf0

18 files changed

+6
-1300
lines changed

python/mxnet/_numpy_op_doc.py

-48
Original file line numberDiff line numberDiff line change
@@ -114,54 +114,6 @@ def _np_repeat(a, repeats, axis=None):
114114
pass
115115

116116

117-
def _np_cumsum(a, axis=None, dtype=None, out=None):
118-
"""cumsum(a, axis=None, dtype=None, out=None)
119-
120-
Return the cumulative sum of the elements along a given axis.
121-
122-
Parameters
123-
----------
124-
a : ndarray
125-
Input array.
126-
axis : int, optional
127-
Axis along which the cumulative sum is computed. The default
128-
(None) is to compute the cumsum over the flattened array.
129-
dtype : dtype, optional
130-
Type of the returned array and of the accumulator in which the
131-
elements are summed. If `dtype` is not specified, it defaults
132-
to the dtype of `a`.
133-
out : ndarray, optional
134-
Alternative output array in which to place the result. It must
135-
have the same shape, type and buffer length as the expected output.
136-
137-
Returns
138-
-------
139-
cumsum_along_axis : ndarray.
140-
A new array holding the result is returned unless `out` is
141-
specified, in which case a reference to `out` is returned. The
142-
result has the same size as `a`, and the same shape as `a` if
143-
`axis` is not None or `a` is a 1-d array.
144-
145-
Examples
146-
--------
147-
>>> a = np.array([[1,2,3], [4,5,6]])
148-
>>> a
149-
array([[1., 2., 3.],
150-
[4., 5., 6.]])
151-
>>> np.cumsum(a)
152-
array([ 1., 3., 6., 10., 15., 21.])
153-
>>> np.cumsum(a, dtype=float)
154-
array([ 1., 3., 6., 10., 15., 21.], dtype=float64)
155-
>>> np.cumsum(a,axis=0)
156-
array([[1., 2., 3.],
157-
[5., 7., 9.]])
158-
>>> np.cumsum(a,axis=1)
159-
array([[ 1., 3., 6.],
160-
[ 4., 9., 15.]])
161-
"""
162-
pass
163-
164-
165117
def _np_dot(a, b, out=None):
166118
"""dot(a, b, out=None)
167119

python/mxnet/ndarray/numpy/_op.py

+1-62
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
__all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
3030
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 'concatenate',
31-
'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
31+
'clip', 'split', 'swapaxes', 'expand_dims', 'tile',
3232
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 'arctan']
3333

3434

@@ -649,67 +649,6 @@ def tile(A, reps):
649649
return _npi.tile(A, reps)
650650

651651

652-
@set_module('mxnet.ndarray.numpy')
653-
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, **kwargs): # pylint: disable=too-many-arguments
654-
"""Return evenly spaced numbers over a specified interval.
655-
656-
Returns num evenly spaced samples, calculated over the interval [start, stop].
657-
The endpoint of the interval can optionally be excluded.
658-
659-
Parameters
660-
----------
661-
start : array_like
662-
The starting value of the sequence.
663-
stop : array_like
664-
The end value of the sequence, unless endpoint is set to False. In
665-
that case, the sequence consists of all but the last of num + 1
666-
evenly spaced samples, so that stop is excluded. Note that the step
667-
size changes when endpoint is False.
668-
num : int, optional
669-
Number of samples to generate. Default is 50. Must be non-negative.
670-
endpoint : bool, optional
671-
If True, stop is the last sample. Otherwise, it is not included.
672-
Default is True.
673-
retstep : bool, optional
674-
If True, return (samples, step), where step is the spacing between samples.
675-
dtype : dtype, optional
676-
The type of the output array. If dtype is not given, infer the data
677-
type from the other input arguments.
678-
axis : int, optional
679-
The axis in the result to store the samples. Relevant only if start or
680-
stop are array-like. By default (0), the samples will be along a new
681-
axis inserted at the beginning. Use -1 to get an axis at the end.
682-
683-
Returns
684-
-------
685-
samples : ndarray
686-
There are num equally spaced samples in the closed interval
687-
`[start, stop]` or the half-open interval `[start, stop)`
688-
(depending on whether endpoint is True or False).
689-
step : float, optional
690-
Only returned if retstep is True
691-
Size of spacing between samples.
692-
693-
Notes
694-
-----
695-
This function currently does not support ``start`` and ``stop`` as ndarrays and
696-
axis could only be 0 now.
697-
"""
698-
if isinstance(start, (list, _np.ndarray, NDArray)) or \
699-
isinstance(stop, (list, _np.ndarray, NDArray)):
700-
raise NotImplementedError('start and stop only support int')
701-
if axis != 0:
702-
raise NotImplementedError("the function only support axis 0")
703-
ctx = kwargs.pop('ctx', current_context())
704-
if ctx is None:
705-
ctx = current_context()
706-
if retstep:
707-
step = (stop - start) / (num - 1)
708-
return _npi.linspace(start=start, stop=stop, num=num, endpoint=endpoint, ctx=ctx, dtype=dtype), step
709-
else:
710-
return _npi.linspace(start=start, stop=stop, num=num, endpoint=endpoint, ctx=ctx, dtype=dtype)
711-
712-
713652
def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
714653
"""Helper function for unary operators.
715654

python/mxnet/ndarray/numpy/random.py

+1-53
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
from ..ndarray import NDArray
2424
from . import _internal as _npi
2525

26-
__all__ = ['uniform', 'normal', 'multinomial']
26+
__all__ = ['uniform', 'normal']
2727

2828

2929
def _random_helper(random, sampler, params, shape, dtype, ctx, out, kwargs):
@@ -137,55 +137,3 @@ def normal(loc=0.0, scale=1.0, size=None, **kwargs):
137137
out = kwargs.pop('out', None)
138138
return _random_helper(_npi.random_normal, None,
139139
[loc, scale], size, dtype, ctx, out, kwargs)
140-
141-
142-
def multinomial(n, pvals, size=None):
143-
"""multinomial(n, pvals, size=None)
144-
145-
Draw samples from a multinomial distribution.
146-
147-
The multinomial distribution is a multivariate generalisation of the binomial distribution.
148-
Take an experiment with one of ``p`` possible outcomes. An example of such an experiment is throwing a dice,
149-
where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments.
150-
Its values, ``X_i = [X_0, X_1, ..., X_p]``, represent the number of times the outcome was ``i``.
151-
152-
Parameters
153-
----------
154-
n : int
155-
Number of experiments.
156-
pvals : sequence of floats, length p
157-
Probabilities of each of the p different outcomes. These should sum to 1.
158-
size : int or tuple of ints, optional
159-
Output shape. If the given shape is, e.g., ``(m, n, k)``, then ``m * n * k`` samples
160-
are drawn. Default is None, in which case a single value is returned.
161-
162-
Returns
163-
-------
164-
out : ndarray
165-
The drawn samples, of shape size, if that was provided. If not, the shape is ``(N,)``.
166-
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution.
167-
168-
Examples
169-
--------
170-
Throw a dice 1000 times, and 1000 times again:
171-
172-
>>> np.random.multinomial(1000, [1/6.]*6, size=2)
173-
array([[164, 161, 179, 158, 150, 188],
174-
[178, 162, 177, 143, 163, 177]])
175-
176-
A loaded die is more likely to land on number 6:
177-
178-
>>> np.random.multinomial(100, [1/7.]*5 + [2/7.])
179-
array([19, 14, 12, 11, 21, 23])
180-
181-
>>> np.random.multinomial(100, [1.0 / 3, 2.0 / 3])
182-
array([32, 68])
183-
"""
184-
if isinstance(pvals, NDArray):
185-
return _npi.multinomial(pvals, pvals=None, n=n, size=size)
186-
else:
187-
if isinstance(pvals, np.ndarray):
188-
pvals = pvals.tolist()
189-
if any(isinstance(i, list) for i in pvals):
190-
raise ValueError('object too deep for desired array')
191-
return _npi.multinomial(n=n, pvals=pvals, size=size)

python/mxnet/numpy/multiarray.py

+2-45
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
__all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange',
4747
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 'concatenate',
48-
'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 'sin', 'cos',
48+
'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'sin', 'cos',
4949
'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 'arctan']
5050

5151

@@ -936,7 +936,7 @@ def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False): # pylin
936936

937937
def cumsum(self, axis=None, dtype=None, out=None):
938938
"""Return the cumulative sum of the elements along the given axis."""
939-
return _mx_np_op.cumsum(self, axis=axis, dtype=dtype, out=out)
939+
raise NotImplementedError
940940

941941
def tolist(self):
942942
return self.asnumpy().tolist()
@@ -1871,49 +1871,6 @@ def tile(A, reps):
18711871
return _npi.tile(A, reps)
18721872

18731873

1874-
@set_module('mxnet.numpy')
1875-
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, **kwargs):
1876-
"""Return evenly spaced numbers over a specified interval.
1877-
1878-
Returns num evenly spaced samples, calculated over the interval [start, stop].
1879-
The endpoint of the interval can optionally be excluded.
1880-
1881-
Parameters
1882-
----------
1883-
start : array_like
1884-
The starting value of the sequence.
1885-
stop : array_like
1886-
The end value of the sequence, unless endpoint is set to False. In
1887-
that case, the sequence consists of all but the last of num + 1
1888-
evenly spaced samples, so that stop is excluded. Note that the step
1889-
size changes when endpoint is False.
1890-
num : int, optional
1891-
Number of samples to generate. Default is 50. Must be non-negative.
1892-
endpoint : bool, optional
1893-
If True, stop is the last sample. Otherwise, it is not included.
1894-
Default is True.
1895-
retstep: bool, optional
1896-
If True, return (samples, step), where step is the spacing between samples.
1897-
dtype: dtype, optional
1898-
The type of the output array. If dtype is not given, infer the data
1899-
type from the other input arguments.
1900-
axis : int, optional
1901-
The axis in the result to store the samples. Relevant only if start or
1902-
stop are array-like. By default (0), the samples will be along a new
1903-
axis inserted at the beginning. Use -1 to get an axis at the end.
1904-
Returns
1905-
-------
1906-
samples : ndarray
1907-
There are num equally spaced samples in the closed interval
1908-
`[start, stop]` or the half-open interval `[start, stop)`
1909-
(depending on whether endpoint is True or False).
1910-
step : float, optional
1911-
Only returned if retstep is True
1912-
Size of spacing between samples.
1913-
"""
1914-
return _mx_nd_np.linspace(start, stop, num, endpoint, retstep, dtype, axis, **kwargs)
1915-
1916-
19171874
@set_module('mxnet.numpy')
19181875
def sin(x, out=None, **kwargs):
19191876
r"""Trigonometric sine, element-wise.

python/mxnet/numpy/random.py

-45
Original file line numberDiff line numberDiff line change
@@ -98,48 +98,3 @@ def normal(loc=0.0, scale=1.0, size=None, **kwargs):
9898
This function currently does not support ``loc`` and ``scale`` as ndarrays.
9999
"""
100100
return _mx_nd_np.random.normal(loc, scale, size, **kwargs)
101-
102-
103-
def multinomial(n, pvals, size=None, **kwargs):
104-
"""multinomial(n, pvals, size=None)
105-
106-
Draw samples from a multinomial distribution.
107-
108-
The multinomial distribution is a multivariate generalisation of the binomial distribution.
109-
Take an experiment with one of ``p`` possible outcomes. An example of such an experiment is throwing a dice,
110-
where the outcome can be 1 through 6. Each sample drawn from the distribution represents n such experiments.
111-
Its values, ``X_i = [X_0, X_1, ..., X_p]``, represent the number of times the outcome was ``i``.
112-
113-
Parameters
114-
----------
115-
n : int
116-
Number of experiments.
117-
pvals : sequence of floats, length p
118-
Probabilities of each of the p different outcomes. These should sum to 1.
119-
size : int or tuple of ints, optional
120-
Output shape. If the given shape is, e.g., ``(m, n, k)``, then ``m * n * k`` samples
121-
are drawn. Default is None, in which case a single value is returned.
122-
123-
Returns
124-
-------
125-
out : ndarray
126-
The drawn samples, of shape size, if that was provided. If not, the shape is ``(N,)``.
127-
In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution.
128-
129-
Examples
130-
--------
131-
Throw a dice 1000 times, and 1000 times again:
132-
133-
>>> np.random.multinomial(1000, [1/6.]*6, size=2)
134-
array([[164, 161, 179, 158, 150, 188],
135-
[178, 162, 177, 143, 163, 177]])
136-
137-
A loaded die is more likely to land on number 6:
138-
139-
>>> np.random.multinomial(100, [1/7.]*5 + [2/7.])
140-
array([19, 14, 12, 11, 21, 23])
141-
142-
>>> np.random.multinomial(100, [1.0 / 3, 2.0 / 3])
143-
array([32, 68])
144-
"""
145-
return _mx_nd_np.random.multinomial(n, pvals, size, **kwargs)

python/mxnet/symbol/numpy/_symbol.py

+2-62
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131

3232
__all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'concatenate', 'arange', 'argmax',
3333
'clip', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 'split', 'swapaxes',
34-
'expand_dims', 'tile', 'linspace', 'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt',
34+
'expand_dims', 'tile', 'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt',
3535
'abs', 'exp', 'arctan']
3636

3737

@@ -538,7 +538,7 @@ def mean(self, axis=None, dtype=None, out=None, keepdims=False): # pylint: disa
538538

539539
def cumsum(self, axis=None, dtype=None, out=None):
540540
"""Return the cumulative sum of the elements along the given axis."""
541-
return _mx_np_op.cumsum(self, axis=axis, dtype=dtype, out=out)
541+
raise NotImplementedError
542542

543543
def max(self, axis=None, out=None, keepdims=False): # pylint: disable=arguments-differ
544544
"""Return the maximum along a given axis."""
@@ -1327,66 +1327,6 @@ def tile(A, reps):
13271327
return _npi.tile(A, reps)
13281328

13291329

1330-
@set_module('mxnet.symbol.numpy')
1331-
def linspace(start, stop, num=50, endpoint=True, retstep=False, dtype=None, axis=0, **kwargs): # pylint: disable=too-many-arguments
1332-
"""Return evenly spaced numbers over a specified interval.
1333-
1334-
Returns num evenly spaced samples, calculated over the interval [start, stop].
1335-
The endpoint of the interval can optionally be excluded.
1336-
1337-
Parameters
1338-
----------
1339-
start : array_like
1340-
The starting value of the sequence.
1341-
stop : array_like
1342-
The end value of the sequence, unless endpoint is set to False. In
1343-
that case, the sequence consists of all but the last of num + 1
1344-
evenly spaced samples, so that stop is excluded. Note that the step
1345-
size changes when endpoint is False.
1346-
num : int, optional
1347-
Number of samples to generate. Default is 50. Must be non-negative.
1348-
endpoint : bool, optional
1349-
If True, stop is the last sample. Otherwise, it is not included.
1350-
Default is True.
1351-
retstep: bool, optional
1352-
If True, return (samples, step), where step is the spacing between samples.
1353-
dtype: dtype, optional
1354-
The type of the output array. If dtype is not given, infer the data
1355-
type from the other input arguments.
1356-
axis : int, optional
1357-
The axis in the result to store the samples. Relevant only if start or
1358-
stop are array-like. By default (0), the samples will be along a new
1359-
axis inserted at the beginning. Use -1 to get an axis at the end.
1360-
Returns
1361-
-------
1362-
samples : ndarray
1363-
There are num equally spaced samples in the closed interval
1364-
`[start, stop]` or the half-open interval `[start, stop)`
1365-
(depending on whether endpoint is True or False).
1366-
step : float, optional
1367-
Only returned if retstep is True
1368-
Size of spacing between samples.
1369-
1370-
Notes
1371-
-----
1372-
This function currently does not support ``start`` and ``stop`` as ndarrays and
1373-
axis could only be 0 now.
1374-
"""
1375-
if isinstance(start, (list, _np.ndarray)) or \
1376-
isinstance(stop, (list, _np.ndarray)):
1377-
raise NotImplementedError('start and stop only support int')
1378-
if axis != 0:
1379-
raise NotImplementedError("the function only support axis 0")
1380-
ctx = kwargs.pop('ctx', current_context())
1381-
if ctx is None:
1382-
ctx = current_context()
1383-
if retstep:
1384-
step = (stop - start) / (num - 1)
1385-
return (_npi.linspace(start=start, stop=stop, num=num, endpoint=endpoint, ctx=ctx, dtype=dtype), step)
1386-
else:
1387-
return _npi.linspace(start=start, stop=stop, num=num, endpoint=endpoint, ctx=ctx, dtype=dtype)
1388-
1389-
13901330
def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
13911331
"""Helper function for unary operators.
13921332

0 commit comments

Comments
 (0)