diff --git a/climate_categories/_conversions.py b/climate_categories/_conversions.py index 77a2a54..2fa4a55 100644 --- a/climate_categories/_conversions.py +++ b/climate_categories/_conversions.py @@ -901,24 +901,25 @@ def __init__( @classmethod def from_csv(cls, filepath): - conv = ConversionSpec.from_csv(filepath) + return ConversionSpec.from_csv(filepath) + + # def get_cats(cat_names): + # import climate_categories + # + # return { + # cat_name: climate_categories.cats[cat_name] for cat_name in cat_names + # } + # + # cat_names = [ + # conv.categorization_a_name, + # conv.categorization_b_name, + # *conv.auxiliary_categorizations_names, + # ] + # + # cats = get_cats(cat_names) + # + # return conv.hydrate(cats=cats) - def get_cats(cat_names): - import climate_categories - - return { - cat_name: climate_categories.cats[cat_name] for cat_name in cat_names - } - - cat_names = [ - conv.categorization_a_name, - conv.categorization_b_name, - *conv.auxiliary_categorizations_names, - ] - - cats = get_cats(cat_names) - - return conv.hydrate(cats=cats) def reversed(self) -> "Conversion": """Returns the Conversion with categorization_a and categorization_b swapped.""" diff --git a/climate_categories/tests/test_conversions.py b/climate_categories/tests/test_conversions.py index 560db2c..9ee59c2 100644 --- a/climate_categories/tests/test_conversions.py +++ b/climate_categories/tests/test_conversions.py @@ -429,13 +429,9 @@ def test_relevant_rules(): def test_read_csv_in_conversion_class(): - filepath = importlib.resources.files("climate_categories.data").joinpath( - "conversion.IPCC1996.IPCC2006.csv" - ) - conv = conversions.Conversion.from_csv(filepath) - assert conv.categorization_a_name == "IPCC1996" - assert conv.categorization_b_name == "IPCC2006" + conv_from_conversion = conversions.Conversion.from_csv("data/good_conversion.csv") + + conv_from_conversion_spec = conversions.ConversionSpec.from_csv("data/good_conversion.csv") - # make sure hydrate() added all the rules - assert len(conv.rules) == 153 + assert vars(conv_from_conversion_spec) == vars(conv_from_conversion)