MCPcopy Create free account
hub / github.com/numpy/numpy / test_density_non_uniform_2d

Method test_density_non_uniform_2d

numpy/lib/tests/test_histograms.py:782–807  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

780 assert_equal(hist[0, 0], 1)
781
782 def test_density_non_uniform_2d(self):
783 # Defines the following grid:
784 #
785 # 0 2 8
786 # 0+-+-----+
787 # + | +
788 # + | +
789 # 6+-+-----+
790 # 8+-+-----+
791 x_edges = np.array([0, 2, 8])
792 y_edges = np.array([0, 6, 8])
793 relative_areas = np.array([
794 [3, 9],
795 [1, 3]])
796
797 # ensure the number of points in each region is proportional to its area
798 x = np.array([1] + [1]*3 + [7]*3 + [7]*9)
799 y = np.array([7] + [1]*3 + [7]*3 + [1]*9)
800
801 # sanity check that the above worked as intended
802 hist, edges = histogramdd((y, x), bins=(y_edges, x_edges))
803 assert_equal(hist, relative_areas)
804
805 # resulting histogram should be uniform, since counts and areas are proportional
806 hist, edges = histogramdd((y, x), bins=(y_edges, x_edges), density=True)
807 assert_equal(hist, 1 / (8*8))
808
809 def test_density_non_uniform_1d(self):
810 # compare to histogram to show the results are the same

Callers

nothing calls this directly

Calls 2

histogramddFunction · 0.90
assert_equalFunction · 0.90

Tested by

no test coverage detected