code: def test_weights(self):
      v = np.random.rand(100)
      w = np.ones(100) * 5
      a, b = histogram(v)
      na, nb = histogram(v, density=True)
      wa, wb = histogram(v, weights=w)
      nwa, nwb = histogram(v, weights=w, density=True)
      assert_array_almost_equal(a * 5, wa)
      assert_array_almost_equal(na, nwa)
  
      # Check weights are properly applied.
      v = np.linspace(0, 10, 10)
      w = np.concatenate((np.zeros(5), np.ones(5)))
      wa, wb = histogram(v, bins=np.arange(11), weights=w)
      assert_array_almost_equal(wa, w)
  
      # Check with integer weights
      wa, wb = histogram([1, 2, 2, 4], bins=4, weights=[4, 3, 2, 1])
      assert_array_equal(wa, [4, 5, 0, 1])
      wa, wb = histogram(
          [1, 2, 2, 4], bins=4, weights=[4, 3, 2, 1], density=True
      )
      assert_array_almost_equal(
          wa, np.array([4, 5, 0, 1]) / 10.0 / 3.0 * 4
      )
  
      # Check weights with non-uniform bin widths
      a, b = histogram(
          np.arange(9),
          [0, 1, 3, 6, 10],
          weights=[2, 1, 1, 1, 1, 1, 1, 1, 1],
          density=True,
      )
      assert_almost_equal(a, [0.2, 0.1, 0.1, 0.075])
  
imports: import numpy
  from numpy.lib.histograms import histogram, histogramdd, histogram_bin_edges
  from numpy.testing import assert_, assert_equal, assert_array_equal, assert_almost_equal, assert_array_almost_equal, assert_raises, assert_allclose, assert_array_max_ulp, assert_raises_regex, suppress_warnings
  from numpy.testing._private.utils import requires_memory
  import pytest
label_desc: Use image node_id 11 for calling the TestHistogram obj's underlying member method code with example usage: obj.test_weights() without return types