# Buggy code
def basic_computations(df: dd.DataFrame) -> Tuple[Dict[str, Any], Dict[str, Any]]:
    """Computations for the basic version.

    Parameters
    ----------
    df
        The DataFrame for which data are calculated.
    """
    data: Dict[str, Any] = {}
    df = DataArray(df)

    df_num = df.select_num_columns()
    data["num_cols"] = df_num.columns
    first_rows = df.select_dtypes(CATEGORICAL_DTYPES).head

    # variables
    for col in df.columns:
        if is_dtype(detect_dtype(df.frame[col]), Continuous()):
            data[col] = cont_comps(df.frame[col], 20)
        elif is_dtype(detect_dtype(df.frame[col]), Nominal()):
            # cast the column as string type if it contains a mutable type
            try:
                first_rows[col].apply(hash)
            except TypeError:
                df.frame[col] = df.frame[col].astype(str)
            data[col] = nom_comps(
                df.frame[col], first_rows[col], 10, True, 10, 20, True, False, False
            )
    # overview
    data["ov"] = calc_stats(df.frame, None)
    # interactions
    data["scat"] = df_num.frame.map_partitions(
        lambda x: x.sample(min(1000, x.shape[0])), meta=df_num.frame
    )
    # correlations
    data.update(zip(("cordx", "cordy", "corrs"), correlation_nxn(df_num)))
    # missing values
    (
        delayed,
        completion,
    ) = compute_missing_nullivariate(  # pylint: disable=unexpected-keyword-arg
        df, 30, _staged=True
    )
    data["miss"] = delayed
    completions = {"miss": completion}

    return data, completions


# Traceback (UnboundLocalError)
---------------------------------------------------------------------------
UnboundLocalError                         Traceback (most recent call last)
<ipython-input-10-c4d17e3c9e92> in <module>
----> 1 report = eda.create_report(dist_df, title="Distribution Report")

/usr/local/lib/python3.8/site-packages/dataprep/eda/create_report/__init__.py in create_report(df, title, mode, progress)
52         "resources": INLINE.render(),
53         "title": title,
---> 54         "components": format_report(df, mode, progress),
55     }
56     template_base = ENV_LOADER.get_template("base.html")

/usr/local/lib/python3.8/site-packages/dataprep/eda/create_report/formatter.py in format_report(df, mode, progress)
61         df = string_dtype_to_object(df)
62         if mode == "basic":
---> 63             comps = format_basic(df)
64         # elif mode == "full":
65         #     comps = format_full(df)

/usr/local/lib/python3.8/site-packages/dataprep/eda/create_report/formatter.py in format_basic(df)
121             )
122         figs: List[Figure] = []
--> 123         for tab in rndrd:
124             try:
125                 fig = tab.children[0]

UnboundLocalError: local variable 'rndrd' referenced before assignment

# Fixed code
def basic_computations(df: dd.DataFrame) -> Tuple[Dict[str, Any], Dict[str, Any]]:
    """Computations for the basic version.

    Parameters
    ----------
    df
        The DataFrame for which data are calculated.
    """
    data: Dict[str, Any] = {}
    df = DataArray(df)

    df_num = df.select_num_columns()
    data["num_cols"] = df_num.columns
    first_rows = df.select_dtypes(CATEGORICAL_DTYPES).head

    # variables
    for col in df.columns:
        if is_dtype(detect_dtype(df.frame[col]), Continuous()):
            data[col] = cont_comps(df.frame[col], 20)
        elif is_dtype(detect_dtype(df.frame[col]), Nominal()):
            # cast the column as string type if it contains a mutable type
            try:
                first_rows[col].apply(hash)
            except TypeError:
                df.frame[col] = df.frame[col].astype(str)
            data[col] = nom_comps(
                df.frame[col], first_rows[col], 10, True, 10, 20, True, False, False
            )
        elif is_dtype(detect_dtype(df.frame[col]), DateTime()):
            data[col] = {}
            data[col]["stats"] = calc_stats_dt(df.frame[col])
            data[col]["line"] = dask.delayed(_calc_line_dt)(df.frame[[col]], "auto")

    # overview
    data["ov"] = calc_stats(df.frame, None)
    # interactions
    data["scat"] = df_num.frame.map_partitions(
        lambda x: x.sample(min(1000, x.shape[0])), meta=df_num.frame
    )
    # correlations
    data.update(zip(("cordx", "cordy", "corrs"), correlation_nxn(df_num)))
    # missing values
    (
        delayed,
        completion,
    ) = compute_missing_nullivariate(  # pylint: disable=unexpected-keyword-arg
        df, 30, _staged=True
    )
    data["miss"] = delayed
    completions = {"miss": completion}

    return data, completions