reminisce commented on a change in pull request #9681: Better Exception Handling for Operators URL: https://github.com/apache/incubator-mxnet/pull/9681#discussion_r165574890
########## File path: tests/python/unittest/test_exc_handling.py ########## @@ -0,0 +1,112 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +#Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +import mxnet as mx +import numpy as np +from mxnet import gluon +from mxnet.gluon import nn +from mxnet.base import MXNetError +from mxnet.test_utils import assert_exception, default_context, set_default_context +from nose.tools import assert_raises + +def test_exc_imperative(): + def imperative(exec_numpy=True): + a = mx.nd.random_normal(0, 1, (2, 2)) + b = mx.nd.random_normal(0, -1, (2, 2)) + c = mx.nd.dot(a, b) + if exec_numpy: + c.asnumpy() + + imperative(exec_numpy=False) + assert_raises(MXNetError, imperative, True) + +def test_exc_symbolic(): + def symbolic(exec_backward=True): + x = mx.sym.Variable('x') + y = mx.sym.Variable('y') + z = mx.sym.Variable('z') + x_shape = (2, 2) + z_shape = (3, 2) + inputs = [x, y] + out = mx.symbol.ElementWiseSum(*inputs, name="esum") + out = mx.sym.dot(z, out) + out2 = mx.sym.random_normal(0, -1, x_shape, ctx=default_context()) Review comment: random.normal as it's the preferred way now. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services