gyshi commented on a change in pull request #15461: Numpy logspace
URL: https://github.com/apache/incubator-mxnet/pull/15461#discussion_r303288974
##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -1162,6 +1162,70 @@ def test_np_broadcast_arrays():
pass
+@with_seed()
[email protected]_np_shape
+def test_np_logspace():
+ configs = [
+ (0.0, 1.0, 20),
+ (2, 8, 0),
+ (22, 11, 1),
+ (2.22, 9.99, 11),
+ (4.99999, 12.11111111, 111)
+ ]
+ exception_configs = [
+ (0, 10, -1),
+ (0, 1, 2.5),
+ ]
+ base_configs = [0, 1, 5, 8, 10, 33]
+ dtypes = ['float32', 'float64', None]
+ for config in configs:
+ for dtype in dtypes:
+ for endpoint in [False, True]:
+ for base in base_configs:
+ if isinstance(config, tuple):
+ mx_ret = np.logspace(*config, endpoint=endpoint,
base=base, dtype=dtype)
+ np_ret = _np.logspace(*config, endpoint=endpoint,
base=base, dtype=dtype)
+ else:
+ mx_ret = np.logspace(config, endpoint=endpoint,
base=base, dtype=dtype)
+ np_ret = _np.logspace(config, endpoint=endpoint,
base=base, dtype=dtype)
+ assert_almost_equal(mx_ret.asnumpy(), np_ret, atol=1e-3,
rtol=1e-5)
+ # check for exception input
+ for config in exception_configs:
+ assertRaises(MXNetError, np.logspace, *config)
+
+ @npx.use_np
+ class TestLogspace(HybridBlock):
+ def __init__(self, start, stop, num=50, endpoint=None, base=50.0,
dtype=None, axis=0):
+ super(TestLogspace, self).__init__()
+ self._start = start
+ self._stop = stop
+ self._num = num
+ self._endpoint = endpoint
+ self._base = base
+ self._dtype = dtype
+
+ def hybrid_forward(self, F, x):
+ return x + F.np.logspace(self._start, self._stop, self._num, \
+ self._endpoint, self._base,
self._dtype)
Review comment:
resolved
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services