code: def test_random_weights():
      n = 10
      bounds = (0.0, 1.0)
      tot = 1.0000
      low = bounds[0]
      high = bounds[1]
  
      df = pd.DataFrame(index=range(1000), columns=range(n))
      for i in df.index:
          df.loc[i] = ffn.random_weights(n, bounds, tot)
      assert df.sum(axis=1).apply(lambda x: np.round(x, 4) == tot).all()
      assert df.applymap(lambda x: (x >= low and x <= high)).all().all()
  
      n = 4
      bounds = (0.0, 0.25)
      tot = 1.0000
      low = bounds[0]
      high = bounds[1]
  
      df = pd.DataFrame(index=range(1000), columns=range(n))
      for i in df.index:
          df.loc[i] = ffn.random_weights(n, bounds, tot)
      assert df.sum(axis=1).apply(lambda x: np.round(x, 4) == tot).all()
      assert (
          df.applymap(
              lambda x: (
                  np.round(x, 2) >= low and np.round(x, 2) <= high
              )
          )
          .all()
          .all()
      )
  
      n = 7
      bounds = (0.0, 0.25)
      tot = 0.8000
      low = bounds[0]
      high = bounds[1]
  
      df = pd.DataFrame(index=range(1000), columns=range(n))
      for i in df.index:
          df.loc[i] = ffn.random_weights(n, bounds, tot)
      assert df.sum(axis=1).apply(lambda x: np.round(x, 4) == tot).all()
      assert (
          df.applymap(
              lambda x: (
                  np.round(x, 2) >= low and np.round(x, 2) <= high
              )
          )
          .all()
          .all()
      )
  
      n = 10
      bounds = (-0.25, 0.25)
      tot = 0.0
      low = bounds[0]
      high = bounds[1]
  
      df = pd.DataFrame(index=range(1000), columns=range(n))
      for i in df.index:
          df.loc[i] = ffn.random_weights(n, bounds, tot)
      assert df.sum(axis=1).apply(lambda x: np.round(x, 4) == tot).all()
      assert (
          df.applymap(
              lambda x: (
                  np.round(x, 2) >= low and np.round(x, 2) <= high
              )
          )
          .all()
          .all()
      )
  
imports: import ffn
  import pandas
  import numpy
  from pytest import fixture
  from numpy.testing import assert_almost_equal
label_desc: Use image node_id 28 for calling a global function with example usage: test_random_weights() without return types