def test_explore_pos(): d0, X, y = et.loadboston() # Adding NA and inf values to dataframe d0.at[0, 'town'] = None d0.at[0, 'lon'] = float('inf') d1 = pd.read_pickle(path + "/data/explore.pkl") assert et.explore(d0).equals(d1)
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Generated data for pytest """ import os.path path = '/Users/bxp151/ml/000_special_projects/01_exploretransform/exploretransform' os.chdir(path) # import inspect, os.path # filename = inspect.getframeinfo(inspect.currentframe()).filename # path = os.path.dirname(os.path.abspath(filename)) import exploretransform as et import plotnine as pn import pandas as pd df, X, y = et.loadboston() # loadboston() # df.to_pickle(path + "/data/loadboston.pkl", compression = None) # explore() # df.at[0, 'town'] = None # df.at[0,'lon'] = float('inf') # df = et.explore(df) # df.to_pickle(path + "/data/explore.pkl", compression = None) # peek et.peek(df).to_pickle(path + "/data/peek.pkl", compression=None) # freq # f = et.freq(X['rad'])
def test_peek_pos(): d0, X, y = et.loadboston() d1 = pd.read_pickle(path + "/data/peek.pkl") assert et.peek(d0).equals(d1)
def test_loadboston_df(): d0, X, y = et.loadboston() d1 = pd.read_pickle(path + '/data/loadboston.pkl') assert d0.equals(d1)
def test_CategoricalOtherLevel_pos(): df, d0, y = et.loadboston() d1 = pd.read_pickle(path + "/data/categoricalotherlevel.pkl") assert et.CategoricalOtherLevel('town', 0.015).fit_transform(d0).equals(d1)
def test_CorrelationFilter_pos(): df, d0, y = et.loadboston() d1 = pd.read_pickle(path + "/data/correlationfilter.pkl") assert et.CorrelationFilter(cut=0.7).fit_transform(d0).equals(d1)
def test_ascores_pos(): df, d0, d1 = et.loadboston() d0 = d0.select_dtypes('number') d2 = pd.read_pickle(path + "/data/ascores.pkl") assert et.ascores(d0, d1).equals(d2)
def test_ColumnSelect_pos(): df, d0, y = et.loadboston() assert et.ColumnSelect('lon').fit_transform(d0).equals(d0['lon'])
def test_skewstats_pos(): df, d0, y = et.loadboston() d1 = pd.read_pickle(path + "/data/skewstats.pkl") assert et.skewstats(d0).equals(d1)
def test_skewstats_nonum(): df, d0, y = et.loadboston() d0 = d0[['town', 'rad']] assert et.skewstats(d0) == "Dataframe has no numeric columns"
def test_calcdrop_pos(): df, d0, y = et.loadboston() d1 = et.corrtable(d0, cut=0.7, full=True) d2 = et.calcdrop(d1) d3 = ['nox', 'indus', 'dis', 'crim'] assert set(d2) == set(d3)
def test_corrtable(): df, d0, y = et.loadboston() d1 = pd.read_pickle(path + "/data/corrtable.pkl") assert et.corrtable(d0, cut=0.5).equals(d1)
def test_freq(): d0, X, y = et.loadboston() d1 = pd.read_pickle(path + "/data/freq.pkl") d2 = et.freq(d0['rad']) assert d1.equals(d2)