code: def test_detect_types():
      def random_str(length=7):
          return "".join(
              [
                  random.choice(string.ascii_letters)
                  for i in range(length)
              ]
          )
  
      near_constant_float = np.repeat(np.pi, repeats=100)
      near_constant_float[:2] = 0
  
      df_all = pd.DataFrame(
          {
              "categorical_string": ["a", "b"] * 50,
              "binary_int": np.random.randint(0, 2, size=100),
              "categorical_int": np.random.randint(0, 4, size=100),
              "low_card_float_int": np.random.randint(
                  0, 4, size=100
              ).astype(float),
              "low_card_float": np.random.randint(
                  0, 4, size=100
              ).astype(float)
              + 0.1,
              "binary_float": np.random.randint(0, 2, size=100).astype(
                  float
              ),
              "cont_int": np.repeat(np.arange(50), 2),
              "unique_string": [random_str() for i in range(100)],
              "continuous_float": np.random.normal(size=100),
              "constant_nan": np.repeat(np.NaN, repeats=100),
              "constant_string": ["every_day"] * 100,
              "constant_float": np.repeat(np.pi, repeats=100),
              "near_constant_float": near_constant_float,
              "index_0_based": np.arange(100),
              "index_1_based": np.arange(1, 101),
              "index_shuffled": np.random.permutation(100),
              "some_lists": [
                  [random_str() for i in range(3)] for j in range(100)
              ],
              "some_dicts": [
                  {random_str(): random_str() for i in range(3)}
                  for j in range(100)
              ],
          }
      )
      df_all.loc[0, "some_lists"] = np.NaN
      df_all["mixed_structured"] = df_all["some_lists"]
      df_all.loc[::2, "mixed_structured"] = df_all.loc[
          ::2, "some_dicts"
      ]
      res = detect_types(df_all)
      types = res.T.idxmax()
      assert types["categorical_string"] == "categorical"
      assert types["binary_int"] == "categorical"
      assert types["categorical_int"] == "categorical"
      # assert types['low_card_int_binomial'] == 'continuous'
      assert types["low_card_float_int"] == "categorical"
      # low card floats if they are not ints are continuous ?
      assert types["low_card_float"] == "continuous"
      assert types["binary_float"] == "categorical"
      assert types["cont_int"] == "continuous"
      assert types["unique_string"] == "free_string"
      assert types["continuous_float"] == "continuous"
      assert types["constant_nan"] == "useless"
      assert types["constant_string"] == "useless"
      assert types["constant_float"] == "useless"
      assert types["near_constant_float"] == "useless"
      assert types["index_0_based"] == "useless"
      assert types["index_1_based"] == "useless"
      # Not detecting a shuffled index right now :-/
      assert types["index_shuffled"] == "continuous"
      assert types["some_lists"] == "useless"
      assert types["some_dicts"] == "useless"
      assert types["mixed_structured"] == "useless"
  
      res = detect_types(X_cat)
      assert len(res) == 3
      assert res.categorical.a
      assert res.categorical.binary
      assert res.free_string.second
      assert ~res.continuous.any()
  
      iris = load_iris()
      res_iris = detect_types(pd.DataFrame(iris.data))
      assert (res_iris.sum(axis=1) == 1).all()
      assert res_iris.continuous.sum() == 4
  
      for col in df_all.columns:
          t = detect_type_series(df_all[col])
          if t in USELESS_TYPES:
              assert types[col] == "useless"
          else:
              assert t == types[col]
  
      assert detect_type_series(df_all["constant_nan"]) == "missing"
      assert detect_type_series(df_all["constant_string"]) == "constant"
      assert detect_type_series(df_all["constant_float"]) == "constant"
      assert (
          detect_type_series(df_all["near_constant_float"])
          == "near_constant"
      )
      assert detect_type_series(df_all["index_0_based"]) == "index"
      assert detect_type_series(df_all["index_1_based"]) == "index"
      assert detect_type_series(df_all["some_lists"]) == "list"
      assert detect_type_series(df_all["some_dicts"]) == "dict"
      assert (
          detect_type_series(df_all["mixed_structured"])
          == "mixed-unhashable"
      )
  
imports: import os
  import pytest
  import random
  import string
  import warnings
  import numpy
  import pandas
  from sklearn.datasets import load_iris, load_digits
  from sklearn.model_selection import train_test_split
  from sklearn.pipeline import make_pipeline
  from sklearn.linear_model import LogisticRegression
  from dabl.preprocessing import USELESS_TYPES, detect_types, EasyPreprocessor, DirtyFloatCleaner, clean, _FLOAT_REGEX, _float_matching, detect_type_series
  from dabl.utils import data_df_from_bunch
  from dabl.datasets import load_titanic
  from dabl import plot
label_desc: Use image node_id 11 for calling a global function with example usage: test_detect_types() and returns: str