code: def test_get_scatter(unittest, rolling_data):
      import dtale.views as views
  
      no_pps = parse_version(platform.python_version()) < parse_version(
          "3.6.0"
      )
      test_data = pd.DataFrame(
          build_ts_data(), columns=["date", "security_id", "foo", "bar"]
      )
      test_data.loc[:, "baz"] = "baz"
      test_data, _ = views.format_data(test_data)
      with app.test_client() as c:
          build_data_inst({c.port: test_data})
          build_dtypes({c.port: views.build_dtypes_state(test_data)})
          params = dict(
              dateCol="date", cols=json.dumps(["foo", "bar"]), index=0
          )
          response = c.get(
              "/dtale/scatter/{}".format(c.port), query_string=params
          )
          response_data = response.get_json()
          expected = dict(
              y="bar",
              stats={
                  "pearson": 0.9999999999999999,
                  "correlated": 5,
                  "only_in_s0": 0,
                  "only_in_s1": 0,
                  "spearman": 0.9999999999999999,
                  "pps": None
                  if no_pps
                  else {
                      "baseline_score": 1.2,
                      "case": "regression",
                      "is_valid_score": True,
                      "metric": "mean absolute error",
                      "model": "DecisionTreeRegressor()",
                      "model_score": 1.0,
                      "ppscore": 0.16666666666666663,
                      "x": "foo",
                      "y": "bar",
                  },
              },
              data={
                  "all": {
                      "bar": [0, 1, 2, 3, 4],
                      "_corr_index": [0, 1, 2, 3, 4],
                      "x": [0, 1, 2, 3, 4],
                  }
              },
              max={"bar": 4, "_corr_index": 4, "x": 4},
              min={"bar": 0, "_corr_index": 0, "x": 0},
              x="foo",
              date=" for 2000-01-01",
          )
          unittest.assertEqual(
              {k: v for k, v in response_data.items() if k != "code"},
              expected,
              "should return scatter",
          )
          unittest.assertEqual(response_data["code"], SCATTER_CODE)
  
          params["cols"] = json.dumps(["foo", "baz_baz"])
          params["dummyCols"] = json.dumps(["baz"])
          response = c.get(
              "/dtale/scatter/{}".format(c.port), query_string=params
          )
          response_data = response.get_json()
          expected_data = (
              [1] if pandas_util.is_pandas2() else ["1"]
          ) * len(response_data["data"]["all"]["baz_baz"])
          unittest.assertEqual(
              response_data["data"]["all"]["baz_baz"], expected_data
          )
  
      df, _ = views.format_data(rolling_data)
      with app.test_client() as c:
          build_data_inst({c.port: df})
          build_dtypes({c.port: views.build_dtypes_state(df)})
          params = dict(
              dateCol="date",
              cols=json.dumps(["0", "1"]),
              index=699,
              rolling=True,
              window="4",
          )
          response = c.get(
              "/dtale/scatter/{}".format(c.port), query_string=params
          )
          response_data = response.get_json()
          assert len(response_data["data"]["all"]["1"]) == 4
          assert sorted(response_data["data"]["all"]) == [
              "1",
              "_corr_index",
              "date",
              "x",
          ]
          unittest.assertEqual(
              sorted(response_data["data"]["all"]["date"]),
              ["2019-11-28", "2019-11-29", "2019-11-30", "2019-12-01"],
              "should return scatter",
          )
  
      test_data = pd.DataFrame(
          build_ts_data(size=15001, days=1),
          columns=["date", "security_id", "foo", "bar"],
      )
  
      with app.test_client() as c:
          build_data_inst({c.port: test_data})
          build_dtypes({c.port: views.build_dtypes_state(test_data)})
          params = dict(
              dateCol="date",
              cols=json.dumps(["foo", "bar"]),
              date="20000101",
          )
          response = c.get(
              "/dtale/scatter/{}".format(c.port), query_string=params
          )
          response_data = response.get_json()
          expected = dict(
              stats={
                  "correlated": 15001,
                  "only_in_s0": 0,
                  "only_in_s1": 0,
                  "pearson": 1.0,
                  "pps": None
                  if no_pps
                  else {
                      "baseline_score": 3736.0678,
                      "case": "regression",
                      "is_valid_score": True,
                      "metric": "mean absolute error",
                      "model": "DecisionTreeRegressor()",
                      "model_score": 2.2682,
                      "ppscore": 0.9993928911033145,
                      "x": "foo",
                      "y": "bar",
                  },
                  "spearman": 1.0,
              },
              error="Dataset exceeds 15,000 records, cannot render scatter. Please apply filter...",
              traceback=CHART_POINTS_LIMIT,
          )
          unittest.assertEqual(
              {k: v for k, v in response_data.items() if k != "code"},
              expected,
              "should return scatter",
          )
  
      with app.test_client() as c:
          build_data_inst({c.port: test_data})
          build_dtypes({c.port: views.build_dtypes_state(test_data)})
          settings = {c.port: {"query": "missing_col == 'blah'"}}
          build_settings(settings)
          params = dict(
              dateCol="date",
              cols=json.dumps(["foo", "bar"]),
              date="20000101",
          )
          response = c.get(
              "/dtale/scatter/{}".format(c.port), query_string=params
          )
          response_data = response.get_json()
          unittest.assertEqual(
              response_data["error"],
              "name 'missing_col' is not defined",
              "should handle correlations exception",
          )
  
file_path: dtale/tests/dtale/correlations/test_views.py
imports: import numpy
  import pandas
  import json
  import platform
  import pytest
  from pkg_resources import parse_version
  import dtale.pandas_util
  from dtale.charts.utils import CHART_POINTS_LIMIT
  from tests.dtale.test_views import app, build_ts_data
  from tests.dtale import build_data_inst, build_settings, build_dtypes
label_desc: Use image node_id 5 for calling a global function with example usage: test_get_scatter(unittest, rolling_data) without return types