xidulu commented on a change in pull request #18403:
URL: https://github.com/apache/incubator-mxnet/pull/18403#discussion_r432805217



##########
File path: tests/python/unittest/test_gluon_probability.py
##########
@@ -0,0 +1,2326 @@
+# 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 os
+import tempfile
+
+import mxnet as mx
+from mxnet import np, npx, autograd
+from mxnet import gluon
+import mxnet.gluon.probability as mgp
+from mxnet.gluon.probability import StochasticBlock, StochasticSequential
+from mxnet.gluon import HybridBlock
+from mxnet.test_utils import use_np, assert_almost_equal, set_default_context
+import numpy as _np
+from common import (setup_module, with_seed, assertRaises,
+                    assert_raises_cudnn_not_satisfied)
+from numpy.testing import assert_array_equal
+import pytest
+import scipy.stats as ss
+import scipy.special as scipy_special
+import warnings
+import json
+import unittest
+import random
+import itertools
+from numbers import Number
+
+# set_default_context(mx.gpu(0))
+
+def prob_to_logit(prob):
+    return np.log(prob) - np.log1p(-prob)
+
+def _distribution_method_invoker(dist, func, *args):
+    """Wrapper for invoking different types of class methods with one unified
+    interface.
+
+    Parameters
+    ----------
+    dist : Distribution
+    func : method
+    """
+    if (len(args) == 0):
+        out = getattr(dist, func)
+        if callable(out):
+            return out()
+        else:
+            return out
+    return getattr(dist, func)(*args)
+
+
+def test_mgp_getF():
+    # Test getF
+    getF = mgp.utils.getF
+    nd = mx.nd
+    sym = mx.sym
+    assert getF(nd.ones((2,2)), nd.ones((2,2))) == nd
+    assert getF(sym.ones((2,2)), sym.ones((2,2))) == sym
+    assert getF(1.0, 2.0) == nd
+
+    # Test exception
+    try:
+        getF(nd.ones((2,2)), sym.ones((2,2)))
+    except TypeError as e:
+        pass

Review comment:
       You are right, this test is problematic.




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to