#1092 Normalize dataframe dtypes

Open Ari Hartikainen ahartikainen
Coverage Reach
plots/backends/bokeh/forestplot.py plots/backends/bokeh/kdeplot.py plots/backends/bokeh/traceplot.py plots/backends/bokeh/ppcplot.py plots/backends/bokeh/posteriorplot.py plots/backends/bokeh/pairplot.py plots/backends/bokeh/elpdplot.py plots/backends/bokeh/densityplot.py plots/backends/bokeh/essplot.py plots/backends/bokeh/mcseplot.py plots/backends/bokeh/rankplot.py plots/backends/bokeh/violinplot.py plots/backends/bokeh/distplot.py plots/backends/bokeh/compareplot.py plots/backends/bokeh/energyplot.py plots/backends/bokeh/khatplot.py plots/backends/bokeh/jointplot.py plots/backends/bokeh/__init__.py plots/backends/bokeh/autocorrplot.py plots/backends/bokeh/loopitplot.py plots/backends/bokeh/parallelplot.py plots/backends/bokeh/hpdplot.py plots/backends/matplotlib/forestplot.py plots/backends/matplotlib/ppcplot.py plots/backends/matplotlib/posteriorplot.py plots/backends/matplotlib/traceplot.py plots/backends/matplotlib/khatplot.py plots/backends/matplotlib/kdeplot.py plots/backends/matplotlib/elpdplot.py plots/backends/matplotlib/pairplot.py plots/backends/matplotlib/mcseplot.py plots/backends/matplotlib/essplot.py plots/backends/matplotlib/densityplot.py plots/backends/matplotlib/violinplot.py plots/backends/matplotlib/rankplot.py plots/backends/matplotlib/jointplot.py plots/backends/matplotlib/__init__.py plots/backends/matplotlib/energyplot.py plots/backends/matplotlib/distplot.py plots/backends/matplotlib/compareplot.py plots/backends/matplotlib/loopitplot.py plots/backends/matplotlib/autocorrplot.py plots/backends/matplotlib/parallelplot.py plots/backends/matplotlib/hpdplot.py plots/backends/__init__.py plots/plot_utils.py plots/loopitplot.py plots/essplot.py plots/ppcplot.py plots/khatplot.py plots/elpdplot.py plots/mcseplot.py plots/densityplot.py plots/traceplot.py plots/pairplot.py plots/hpdplot.py plots/parallelplot.py plots/violinplot.py plots/rankplot.py plots/posteriorplot.py plots/jointplot.py plots/forestplot.py plots/energyplot.py plots/kdeplot.py plots/compareplot.py plots/distplot.py plots/__init__.py plots/autocorrplot.py data/io_cmdstan.py data/io_pystan.py data/inference_data.py data/io_pymc3.py data/io_cmdstanpy.py data/io_emcee.py data/io_tfp.py data/io_pyro.py data/io_numpyro.py data/io_dict.py data/base.py data/converters.py data/datasets.py data/__init__.py data/io_netcdf.py stats/stats.py stats/diagnostics.py stats/stats_utils.py stats/stats_refitting.py stats/__init__.py rcparams.py utils.py wrappers/base.py wrappers/wrap_pystan.py wrappers/__init__.py

No flags found

Use flags to group coverage reports by test type, project and/or folders.
Then setup custom commit statuses and notifications for each flag.

e.g., #unittest #integration

#production #enterprise

#frontend #backend

Learn more about Codecov Flags here.

Showing 2 of 4 files from the diff.

@@ -561,3 +561,17 @@
Loading
561 561
    c_c = np.cos(ang).mean(axis=axis)
562 562
    r_r = np.hypot(s_s, c_c)
563 563
    return ((high - low) / 2.0 / np.pi) * np.sqrt(-2 * np.log(r_r))
564 +
565 +
566 +
def normalize_dataframe_dtypes(dataframe):
567 +
    """Normalize dataframe dtypes for common cases."""
568 +
    columns = dataframe.columns
569 +
    for column in columns:
570 +
        dtype = dataframe[column].dtype
571 +
        if np.issubdtype(dtype, np.floating):
572 +
            if dtype != np.dtype("float64"):
573 +
                dataframe[column] = dataframe[column].astype("float64")
574 +
        elif np.issubdtype(dtype, np.integer):
575 +
            if dtype != np.dtype("int64"):
576 +
                dataframe[column] = dataframe[column].astype("int64")
577 +
    return dataframe

@@ -20,6 +20,7 @@
Loading
20 20
    wrap_xarray_ufunc as _wrap_xarray_ufunc,
21 21
    logsumexp as _logsumexp,
22 22
    ELPDData,
23 +
    normalize_dataframe_dtypes as _normalize_dataframe_dtypes,
23 24
    stats_variance_2d as svar,
24 25
    histogram,
25 26
    _circular_standard_deviation,
@@ -285,6 +286,8 @@
Loading
285 286
                res[scale_col],
286 287
            )
287 288
289 +
    df_comp = _normalize_dataframe_dtypes(df_comp)
290 +
288 291
    return df_comp.sort_values(by=ic, ascending=ascending)
289 292
290 293
@@ -1094,11 +1097,11 @@
Loading
1094 1097
                df.index = list(df.index)
1095 1098
                df = df.T
1096 1099
            dfs.append(df)
1097 -
        summary_df = pd.concat(dfs, sort=False)
1100 +
        summary_df = _normalize_dataframe_dtypes(pd.concat(dfs, sort=False))
1098 1101
    elif fmt.lower() == "long":
1099 1102
        df = joined.to_dataframe().reset_index().set_index("metric")
1100 1103
        df.index = list(df.index)
1101 -
        summary_df = df
1104 +
        summary_df = _normalize_dataframe_dtypes(df)
1102 1105
    else:
1103 1106
        # format is 'xarray'
1104 1107
        summary_df = joined

Learn more Showing 14 files with coverage changes found.

Changes in arviz/data/io_dict.py
-9
Loading file...
Changes in arviz/data/io_numpyro.py
-5
Loading file...
Changes in arviz/data/io_pymc3.py
-8
Loading file...
Changes in arviz/data/io_cmdstan.py
-13
Loading file...
Changes in arviz/utils.py
-3
Loading file...
Changes in arviz/data/io_pyro.py
-5
Loading file...
Changes in arviz/data/inference_data.py
-1
Loading file...
Changes in arviz/stats/stats_utils.py
-1
Loading file...
Changes in arviz/plots/backends/bokeh/forestplot.py
-1
Loading file...
Changes in arviz/plots/plot_utils.py
-1
Loading file...
Changes in arviz/plots/backends/matplotlib/forestplot.py
-1
Loading file...
Changes in arviz/data/io_cmdstanpy.py
-11
Loading file...
Changes in arviz/data/io_emcee.py
-3
+3
Loading file...
Changes in arviz/data/io_pystan.py
-155
+135
Loading file...
Files Coverage
arviz +1.76% 93.35%
Project Totals (93 files) 93.35%
Loading