Mercurial > hg > tvii
diff tests/test_broadcasting.py @ 15:926c127305fa
[np] this is how broadcasting works
author | Jeff Hammel <k0scist@gmail.com> |
---|---|
date | Sun, 03 Sep 2017 12:11:03 -0700 |
parents | ec5f97abf8ed |
children |
line wrap: on
line diff
--- a/tests/test_broadcasting.py Sun Sep 03 12:07:49 2017 -0700 +++ b/tests/test_broadcasting.py Sun Sep 03 12:11:03 2017 -0700 @@ -15,7 +15,13 @@ class TestBroadcasting(unittest.TestCase): def test_basic(self): - """example of braodcasting""" + """example of broadcasting""" + + A = np.array(calories) + cal = A.sum(axis=0) + print (cal) + percentage = 100*A/cal.reshape(1,4) + print (percentage) if __name__ == '__main__': unittest.main()