code: def test_hpfilter(custom_data, ts_analysis_data, unittest):
      import dtale.views as views
  
      df, _ = views.format_data(ts_analysis_data)
      with build_app(url=URL).test_client() as c:
          build_data_inst({c.port: df})
  
          resp = c.get(
              "/dtale/timeseries-analysis/{}".format(c.port),
              query_string=dict(
                  type="not_implemented", cfg=json.dumps({})
              ),
          )
          assert not resp.json["success"]
  
          cfg = dict(index="date", col="realgdp", lamb=1600)
          resp = c.get(
              "/dtale/timeseries-analysis/{}".format(c.port),
              query_string=dict(type="hpfilter", cfg=json.dumps(cfg)),
          )
          unittest.assertEqual(
              sorted(resp.json["data"]["all"].keys()),
              ["cycle", "realgdp", "trend", "x"],
          )
  
      df, _ = views.format_data(custom_data)
      with build_app(url=URL).test_client() as c:
          build_data_inst({c.port: df})
  
          cfg = dict(index="date", col="Col1", lamb=1600)
          resp = c.get(
              "/dtale/timeseries-analysis/{}".format(c.port),
              query_string=dict(type="hpfilter", cfg=json.dumps(cfg)),
          )
          assert not resp.json["success"]
  
          cfg["agg"] = "mean"
          resp = c.get(
              "/dtale/timeseries-analysis/{}".format(c.port),
              query_string=dict(type="hpfilter", cfg=json.dumps(cfg)),
          )
          unittest.assertEqual(
              sorted(resp.json["data"]["all"].keys()),
              ["Col1", "cycle", "trend", "x"],
          )
  
file_path: dtale/tests/dtale/test_timeseries_analysis.py
imports: import json
  import pytest
  from six import PY3
  from dtale.app import build_app
  from tests.dtale.test_views import URL
  from tests.dtale import build_data_inst
label_desc: Use image node_id 1 for calling a global function with example usage: test_hpfilter(custom_data, ts_analysis_data, unittest) without return types