def test_require_variable_year_list(test_df): # drop first data point df = IamDataFrame(test_df.data[1:]) # checking for variables that have data for ANY of the years in the list obs = df.require_variable(variable="Primary Energy", year=[2005, 2010]) assert obs is None # checking for variables that have data for ALL of the years in the list df = IamDataFrame(test_df.data[1:]) exp = pd.DataFrame([["model_a", "scen_a"]], columns=META_IDX) obs = df.require_variable(variable="Primary Energy", year=[2005]) pdt.assert_frame_equal(obs, exp)
def test_require_variable_year_list(test_df): years = [2005, 2010] # checking for variables that have ANY of the years in the list df = IamDataFrame(test_df.data[1:]) df.require_variable(variable='Primary Energy', year=years, exclude_on_fail=True) df.filter(exclude=False, inplace=True) assert len(df.variables()) == 2 assert len(df.scenarios()) == 2 # checking for variables that have ALL of the years in the list df = IamDataFrame(test_df.data[1:]) for y in years: df.require_variable(variable='Primary Energy', year=y, exclude_on_fail=True) df.filter(exclude=False, inplace=True) assert len(df.variables()) == 1 assert len(df.scenarios()) == 1