Thanks to visit codestin.com
Credit goes to github.com

Skip to content

some problem in build random array #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
xichaoqiang opened this issue Jun 30, 2019 · 1 comment
Closed

some problem in build random array #6

xichaoqiang opened this issue Jun 30, 2019 · 1 comment

Comments

@xichaoqiang
Copy link

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'”

@henon
Copy link
Contributor

henon commented Jun 30, 2019

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants