# ### Sampling date # %% sampling_date = dt.datetime(year=2019, month=12, day=31) # %% sampling_date = dt.datetime(year=2021, month=12, day=31) # %% [markdown] # ### Data # %% option = "logvar_capm_resid" # "spy_capm_decomp" # %% data = DataMap("../data") df_idio_var = data.load_historic(sampling_date=sampling_date, column="var_idio") df_logvar_resid = data.load_historic(sampling_date=sampling_date, column="logvar_capm_resid") df_var = data.load_historic(sampling_date=sampling_date, column="var") df_spy_var = data.load_spy_data(series="var").loc[df_idio_var.index] df_info = data.load_asset_estimates( sampling_date=sampling_date, columns=["ticker", "comnam", "last_size", "mean_size"]) # %% [markdown] # ### Tickers # %% ticker_list = (data.load_historic(
# import pytest import numpy as np import pandas as pd from pandas.testing import assert_frame_equal from euraculus.data import DataMap datamap = DataMap(datapath="/home/rubelrennfix/projects/euraculus/data") class TestPrepareLogVariances: """This class serves to test various cases of preparing log variance data.""" def test_full_column(self): df_var = pd.DataFrame(data=[[1], [1], [1]]) df_noisevar = pd.DataFrame(data=[[2], [2], [2]]) output = datamap.prepare_log_variances(df_var=df_var, df_noisevar=df_noisevar) expected = np.log(pd.DataFrame(data=[[1], [1], [1]])) assert_frame_equal(output, expected) def test_empty_column(self): _ = np.nan df_var = pd.DataFrame(data=[[_], [_], [_]]) df_noisevar = pd.DataFrame(data=[[_], [_], [_]]) output = datamap.prepare_log_variances(df_var=df_var, df_noisevar=df_noisevar) expected = np.log(pd.DataFrame(data=[[_], [_], [_]])) assert_frame_equal(output, expected) def test_zero_column(self): df_var = pd.DataFrame(data=[[0], [0], [0]])