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

Method test_numpy_conversion_2

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

Source from the content-addressed store, hash-verified

789
790 @unittest.skipUnless(HAVE_NUMPY, "requires build with numpy-support")
791 def test_numpy_conversion_2(self):
792 a = histogram(integer(0, 2, uoflow=False),
793 integer(0, 3, uoflow=False),
794 integer(0, 4, uoflow=False))
795 r = numpy.zeros((2, 3, 4), dtype=numpy.int8)
796 for i in range(len(a.axis(0))):
797 for j in range(len(a.axis(1))):
798 for k in range(len(a.axis(2))):
799 for m in range(i + j + k):
800 a(i, j, k)
801 r[i, j, k] = i + j + k
802
803 d = numpy.zeros((2, 3, 4), dtype=numpy.int8)
804 for i in range(len(a.axis(0))):
805 for j in range(len(a.axis(1))):
806 for k in range(len(a.axis(2))):
807 d[i, j, k] = a.at(i, j, k).value
808
809 self.assertTrue(numpy.all(d == r))
810
811 c = numpy.array(a) # a copy
812 v = numpy.asarray(a) # a view
813
814 self.assertTrue(numpy.all(c == r))
815 self.assertTrue(numpy.all(v == r))
816
817 @unittest.skipUnless(HAVE_NUMPY, "requires build with numpy-support")
818 def test_numpy_conversion_3(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