code: def test_get_correlations_ts(unittest, rolling_data):
      import dtale.views as views
  
      test_data = pd.DataFrame(
          build_ts_data(size=50),
          columns=["date", "security_id", "foo", "bar"],
      )
      test_data.loc[:, "baz"] = "baz"
  
      no_pps = parse_version(platform.python_version()) < parse_version(
          "3.6.0"
      )
  
      with app.test_client() as c:
          build_data_inst({c.port: test_data})
          params = dict(dateCol="date", cols=json.dumps(["foo", "bar"]))
          response = c.get(
              "/dtale/correlations-ts/{}".format(c.port),
              query_string=params,
          )
          response_data = response.get_json()
          expected = {
              "data": {
                  "all": {
                      "x": [
                          "2000-01-01",
                          "2000-01-02",
                          "2000-01-03",
                          "2000-01-04",
                          "2000-01-05",
                      ],
                      "corr": [1.0, 1.0, 1.0, 1.0, 1.0],
                  }
              },
              "max": {"corr": 1.0, "x": "2000-01-05"},
              "min": {"corr": 1.0, "x": "2000-01-01"},
              "pps": None
              if no_pps
              else {
                  "baseline_score": 12.5,
                  "case": "regression",
                  "is_valid_score": True,
                  "metric": "mean absolute error",
                  "model": "DecisionTreeRegressor()",
                  "model_score": 0.0,
                  "ppscore": 1.0,
                  "x": "foo",
                  "y": "bar",
              },
              "success": True,
          }
          unittest.assertEqual(
              {k: v for k, v in response_data.items() if k != "code"},
              expected,
              "should return timeseries correlation",
          )
          unittest.assertEqual(
              response_data["code"], CORRELATIONS_TS_CODE
          )
  
          params["cols"] = json.dumps(["foo", "baz_baz"])
          params["dummyCols"] = json.dumps(["baz"])
          response = c.get(
              "/dtale/correlations-ts/{}".format(c.port),
              query_string=params,
          )
          response_data = response.get_json()
          assert response_data["success"]
  
          params["cols"] = json.dumps(["foo", "bar"])
          del params["dummyCols"]
          params["rolling"] = False
          params["rollingWindow"] = 4
          params["minPeriods"] = 4
          response = c.get(
              "/dtale/correlations-ts/{}".format(c.port),
              query_string=params,
          )
          response_data = response.get_json()
          unittest.assertEqual(
              response_data["data"]["all"]["x"],
              ["2000-01-04", "2000-01-05"],
          )
  
      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"]),
              rolling=True,
              rollingWindow="4",
          )
          response = c.get(
              "/dtale/correlations-ts/{}".format(c.port),
              query_string=params,
          )
          response_data = response.get_json()
          unittest.assertEqual(
              response_data["success"],
              True,
              "should return rolling correlation",
          )
  
      with app.test_client() as c:
          build_data_inst({c.port: test_data})
          settings = {c.port: {"query": "missing_col == 'blah'"}}
          build_settings(settings)
          response = c.get("/dtale/correlations-ts/{}".format(c.port))
          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 4 for calling a global function with example usage: test_get_correlations_ts(unittest, rolling_data) without return types