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:821–846  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

819 assert_equal(hist[0, 0], 1)
820
821 def test_density_non_uniform_2d(self):
822 # Defines the following grid:
823 #
824 # 0 2 8
825 # 0+-+-----+
826 # + | +
827 # + | +
828 # 6+-+-----+
829 # 8+-+-----+
830 x_edges = np.array([0, 2, 8])
831 y_edges = np.array([0, 6, 8])
832 relative_areas = np.array([
833 [3, 9],
834 [1, 3]])
835
836 # ensure the number of points in each region is proportional to its area
837 x = np.array([1] + [1] * 3 + [7] * 3 + [7] * 9)
838 y = np.array([7] + [1] * 3 + [7] * 3 + [1] * 9)
839
840 # sanity check that the above worked as intended
841 hist, edges = histogramdd((y, x), bins=(y_edges, x_edges))
842 assert_equal(hist, relative_areas)
843
844 # resulting histogram should be uniform, since counts and areas are proportional
845 hist, edges = histogramdd((y, x), bins=(y_edges, x_edges), density=True)
846 assert_equal(hist, 1 / (8 * 8))
847
848 def test_density_non_uniform_1d(self):
849 # 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