MCPcopy Create free account
hub / github.com/boostorg/histogram / test_numpy_conversion_3

Method test_numpy_conversion_3

test/python_suite_test.py:818–841  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

816
817 @unittest.skipUnless(HAVE_NUMPY, "requires build with numpy-support")
818 def test_numpy_conversion_3(self):
819 a = histogram(integer(0, 2),
820 integer(0, 3),
821 integer(0, 4))
822 r = numpy.zeros((2, 4, 5, 6))
823 for i in range(len(a.axis(0))):
824 for j in range(len(a.axis(1))):
825 for k in range(len(a.axis(2))):
826 a(i, j, k, weight=i + j + k)
827 r[0, i, j, k] = i + j + k
828 r[1, i, j, k] = (i + j + k)**2
829 c = numpy.array(a) # a copy
830 v = numpy.asarray(a) # a view
831
832 c2 = numpy.zeros((2, 4, 5, 6))
833 for i in range(len(a.axis(0))):
834 for j in range(len(a.axis(1))):
835 for k in range(len(a.axis(2))):
836 c2[0, i, j, k] = a.at(i, j, k).value
837 c2[1, i, j, k] = a.at(i, j, k).variance
838
839 self.assertTrue(numpy.all(c == c2))
840 self.assertTrue(numpy.all(c == r))
841 self.assertTrue(numpy.all(v == r))
842
843 @unittest.skipUnless(HAVE_NUMPY, "requires build with numpy-support")
844 def test_numpy_conversion_4(self):

Callers

nothing calls this directly

Calls 4

integerClass · 0.90
axisMethod · 0.80
atMethod · 0.80
histogramClass · 0.50

Tested by

no test coverage detected