code: def test_score():
      df = pd.DataFrame()
      df["x"] = np.random.uniform(-2, 2, 1000)
      df["error"] = np.random.uniform(-0.5, 0.5, 1000)
      df["y"] = df["x"] * df["x"] + df["error"]
  
      df["constant"] = 1
      df = df.reset_index()
      df["id"] = df["index"].astype(str)
  
      df["x_greater_0_boolean"] = df["x"] > 0
      # df["x_greater_0_string"] = df["x_greater_0_boolean"].astype(str)
      df["x_greater_0_string"] = pd.Series(
          df["x_greater_0_boolean"].apply(str),
          dtype="string" if check_pandas_version("1.1.0") else "object",
      )
      df["x_greater_0_string_object"] = df["x_greater_0_string"].astype(
          "object"
      )
      df["x_greater_0_string_category"] = df[
          "x_greater_0_string"
      ].astype("category")
  
      df["x_greater_0_boolean_object"] = df[
          "x_greater_0_boolean"
      ].astype("object")
      df["x_greater_0_boolean_category"] = df[
          "x_greater_0_boolean"
      ].astype("category")
  
      df["nan"] = np.nan
  
      duplicate_column_names_df = pd.DataFrame()
      duplicate_column_names_df["x1"] = np.random.uniform(-2, 2, 10)
      duplicate_column_names_df["x2"] = np.random.uniform(-2, 2, 10)
      duplicate_column_names_df[
          "unique_column_name"
      ] = np.random.uniform(-2, 2, 10)
      duplicate_column_names_df.columns = [
          "duplicate_column_name",
          "duplicate_column_name",
          "unique_column_name",
      ]
  
      dtypes_df = pd.read_csv(
          os.path.join(
              os.path.dirname(__file__), "..", "..", "data/titanic.csv"
          )
      )
      dtypes_df = dtypes_df.rename(
          columns={
              "Age": "Age_float",
              "Sex": "Sex_object",
              "Pclass": "Pclass_integer",
              "Survived": "Survived_integer",
              "Ticket": "Ticket_object",
              "Name": "Name_object_id",
          }
      )
      dtypes_df["Survived_Int64"] = dtypes_df[
          "Survived_integer"
      ].astype("Int64")
  
      # check input types
      with pytest.raises(TypeError):
          numpy_array = np.random.randn(10, 10)  # not a DataFrame
          pps.score(numpy_array, "x", "y")
  
      with pytest.raises(ValueError):
          pps.score(df, "x_column_that_does_not_exist", "y")
  
      with pytest.raises(ValueError):
          pps.score(df, "x", "y_column_that_does_not_exist")
  
      with pytest.raises(AttributeError):
          # the task argument is not supported any more
          pps.score(df, "x", "y", task="classification")
  
      with pytest.raises(AssertionError):
          # df shall not have duplicate column names
          pps.score(
              duplicate_column_names_df,
              "duplicate_column_name",
              "unique_column_name",
          )
  
      with pytest.raises(AssertionError):
          # df shall not have duplicate column names
          pps.score(
              duplicate_column_names_df,
              "unique_column_name",
              "duplicate_column_name",
          )
  
      if check_pandas_version("1.0.0"):
          # check cross_validation
          # if more folds than data, there is an error
          with pytest.raises(ValueError):
              assert pps.score(
                  df,
                  "x",
                  "y",
                  cross_validation=2000,
                  catch_errors=False,
              )
  
          # check random_seed
          assert pps.score(df, "x", "y", random_seed=1) == pps.score(
              df, "x", "y", random_seed=1
          )
          assert pps.score(df, "x", "y", random_seed=1) != pps.score(
              df, "x", "y", random_seed=2
          )
          # the random seed that is drawn automatically is smaller than <1000
          assert pps.score(df, "x", "y") != pps.score(
              df, "x", "y", random_seed=123456
          )
  
          # check invalid_score
          invalid_score = -99
          assert (
              pps.score(df, "nan", "y", invalid_score=invalid_score)[
                  "ppscore"
              ]
              == invalid_score
          )
  
          # check catch_errors using the cross_validation error from above
          assert (
              pps.score(
                  df,
                  "x",
                  "y",
                  cross_validation=2000,
                  invalid_score=invalid_score,
                  catch_errors=True,
              )["ppscore"]
              == invalid_score
          )
  
          # check case discrimination
          assert pps.score(df, "x", "y")["case"] == "regression"
          assert (
              pps.score(df, "x", "x_greater_0_string")["case"]
              == "classification"
          )
          assert (
              pps.score(df, "x", "constant")["case"]
              == "target_is_constant"
          )
          assert pps.score(df, "x", "x")["case"] == "predict_itself"
          assert pps.score(df, "x", "id")["case"] == "target_is_id"
          assert (
              pps.score(df, "nan", "y")["case"]
              == "empty_dataframe_after_dropping_na"
          )
  
          # check scores
          # feature is id
          assert pps.score(df, "id", "y")["ppscore"] == 0
  
          # numeric feature and target
          assert pps.score(df, "x", "y")["ppscore"] > 0.5
          assert pps.score(df, "y", "x")["ppscore"] < 0.05
  
          # boolean feature or target
          assert (
              pps.score(df, "x", "x_greater_0_boolean")["ppscore"] > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_boolean", "x")["ppscore"] < 0.6
          )
  
          # string feature or target
          assert (
              pps.score(df, "x", "x_greater_0_string")["ppscore"] > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_string", "x")["ppscore"] < 0.6
          )
  
          # object feature or target
          assert (
              pps.score(df, "x", "x_greater_0_string_object")["ppscore"]
              > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_string_object", "x")["ppscore"]
              < 0.6
          )
  
          # category feature or target
          assert (
              pps.score(df, "x", "x_greater_0_string_category")[
                  "ppscore"
              ]
              > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_string_category", "x")[
                  "ppscore"
              ]
              < 0.6
          )
  
          # object feature or target
          assert (
              pps.score(df, "x", "x_greater_0_boolean_object")[
                  "ppscore"
              ]
              > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_boolean_object", "x")[
                  "ppscore"
              ]
              < 0.6
          )
  
          # category feature or target
          assert (
              pps.score(df, "x", "x_greater_0_boolean_category")[
                  "ppscore"
              ]
              > 0.6
          )
          assert (
              pps.score(df, "x_greater_0_boolean_category", "x")[
                  "ppscore"
              ]
              < 0.6
          )
  
          # check special dtypes
          # pd.IntegerArray e.g. Int64, Int8, etc
          assert (
              pps.score(dtypes_df, "Survived_Int64", "Sex_object")[
                  "is_valid_score"
              ]
              is True
          )
          assert (
              pps.score(dtypes_df, "Sex_object", "Survived_Int64")[
                  "is_valid_score"
              ]
              is True
          )
  
file_path: dtale/tests/dtale/ppscore/test_calculation.py
imports: import os
  import pytest
  import pandas
  import numpy
  import sys
  import dtale.ppscore
  from dtale.pandas_util import check_pandas_version
label_desc: Use image node_id 5 for calling a global function with example usage: test_score() without return types