Skip to content

some problem in build random array #6

Closed

Description

@xichaoqiang

var a1 = np.random.rand(300, 200);
Python.Runtime.PythonException:“TypeError : rand() got an unexpected keyword argument 'd0'”

var a1 = np.random.randn(300, 200);
Python.Runtime.PythonException:“TypeError : randn() got an unexpected keyword argument 'd0'”

Activity

  1. henon commented on Jun 30, 2019

    @henon
    Contributor

    fixed. these tests run through now:

            [TestMethod]
            public void randTest()
            {
                // >>> np.random.rand(3,2)
                // array([[ 0.14022471,  0.96360618],  #random
                //        [ 0.37601032,  0.25528411],  #random
                //        [ 0.49313049,  0.94909878]]) #random
                // 
    
                np.random.seed(0);
                var given=  np.random.rand(1,2);
                var expected = "array([[0.5488135 , 0.71518937]])";
    
                Assert.AreEqual(expected, given.repr);
                np.random.seed(0);
                float x = np.random.rand();
                Assert.AreEqual(0.5488135039273248f, x);
            }
    
    
            [TestMethod]
            public void randnTest()
            {
                // >>> np.random.randn()
                // 2.1923875335537315 #random
                // 
    
                np.random.seed(0);
                var given =  np.random.randn();
                Assert.AreEqual(1.76405239f, given);
                // Two-by-four array of samples from N(3, 6.25):
    
                // >>> 2.5 * np.random.randn(2, 4) + 3
                // array([[-4.49401501,  4.00950034, -1.81814867,  7.29718677],  #random
                //        [ 0.39924804,  4.68456316,  4.99394529,  4.84057254]]) #random
                // 
    
                np.random.seed(0);
                var a =  2.5 * np.random.randn(1, 2) + 3;
                 var expected= "array([[7.41013086, 4.00039302]])";
                Assert.AreEqual(expected, a.repr);
    
            }

    the fix is gonna be released shortly. thanks for the bug reports!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions