class_docstr: Test behaviour of the from_numpy_lasso method
docstr: The optimisation in notears lasso involves reshaping the initial similarity matrix
  into two strictly positive matrixes (w+ and w-) and imposing a non negativity constraint
  to the solver. We test here if these two contraints are imposed.
  
  We check if:
  (1) bounds impose non negativity constraint
  (2) initial guess obeys non negativity constraint
  (3) most importantly: output of sopt obeys the constraint
docstr_tok: ["The","optimisation","in","notears","lasso","involves","reshaping","the","initial","similarity","matrix","into","two","strictly","positive","matrixes","(","w+","and","w-",")","and","imposing","a","non","negativity","constraint","to","the","solver",".","We","test","here","if","these","two","contraints","are","imposed",".","We","check","if",":","(","1",")","bounds","impose","non","negativity","constraint","(","2",")","initial","guess","obeys","non","negativity","constraint","(","3",")","most","importantly",":","output","of","sopt","obeys","the","constraint"]
code: def test_non_negativity_constraint(self, train_data_idx):
      """
      The optimisation in notears lasso involves reshaping the initial similarity matrix
      into two strictly positive matrixes (w+ and w-) and imposing a non negativity constraint
      to the solver. We test here if these two contraints are imposed.
  
      We check if:
      (1) bounds impose non negativity constraint
      (2) initial guess obeys non negativity constraint
      (3) most importantly: output of sopt obeys the constraint
      """
      # using `wraps` to **spy** on the function
      with patch(
          "causalnex.structure.pytorch.core.sopt.minimize",
          wraps=sopt.minimize,
      ) as mocked:
          from_numpy(
              train_data_idx.values, lasso_beta=0.1, w_threshold=0.25
          )
          # We iterate over each time `sopt.minimize` was called
          for called_arguments in list(mocked.call_args_list):
              # These are the arguments with which the `sopt.minimize` was called
              func_ = called_arguments[0][0]  # positional arg
              w_est = called_arguments[0][1]  # positional arg
              keyword_args = called_arguments[1]
  
              # check 1:
              assert [
                  (len(el) == 2) and (el[0] == 0)
                  for el in keyword_args["bounds"]
              ]
              # check 2:
              assert [el >= 0 for el in w_est]
              # check 3
              sol = sopt.minimize(func_, w_est, **keyword_args)
              assert [el >= 0 for el in sol.x]
  
imports: import logging
  import networkx
  import numpy
  import pandas
  import pytest
  import scipy.optimize
  from mock import patch
  from causalnex.structure import StructureModel
  from causalnex.structure.data_generators import generate_binary_data, generate_binary_dataframe, generate_continuous_dataframe, generate_count_dataframe, generate_structure
  from causalnex.structure.pytorch.notears import from_numpy, from_pandas
label_desc: Use image node_id 17 for calling the TestFromNumpy obj's underlying member method code with example usage: obj.test_non_negativity_constraint(train_data_idx) without return types