diff --git a/pelicun/base.py b/pelicun/base.py index 0de718307..6843448e7 100644 --- a/pelicun/base.py +++ b/pelicun/base.py @@ -1071,58 +1071,6 @@ def with_parsed_str_na_values(df: pd.DataFrame) -> pd.DataFrame: ) -def process_loc(string, stories): - """ - Parses the 'location' parameter from input to determine the - specific locations to be processed. This function interprets - various string formats to output a list of integers representing - locations. - - Parameters - ---------- - string : str - A string that describes the location or range of locations of - the asset. It can be a single number, a range (e.g., '3-7'), - 'all', 'top', 'roof', or 'last'. - stories : int - The total number of locations in the asset, used to interpret - relative terms like 'top' or 'roof', or to generate a range - for 'all'. - - Returns - ------- - list of int or None - A list of integers representing each floor specified by the - string. Returns None if the string does not conform to - expected formats. - - Raises - ------ - ValueError - Raises an exception if the string contains a range that is not - interpretable (e.g., non-integer values or logical - inconsistencies in the range). - """ - try: - res = int(string) - return [ - res, - ] - except ValueError as exc: - if "-" in string: - s_low, s_high = string.split('-') - s_low = process_loc(s_low, stories) - s_high = process_loc(s_high, stories) - return list(range(s_low[0], s_high[0] + 1)) - if string == "all": - return list(range(1, stories + 1)) - if string in {"top", "roof", "last"}: - return [ - stories, - ] - raise ValueError(f'Invalid string: {string}') from exc - - def dedupe_index(dataframe, dtype=str): """ Modifies the index of a DataFrame to ensure all index elements are diff --git a/pelicun/tests/test_base.py b/pelicun/tests/test_base.py index 31c96d3f0..113866fad 100644 --- a/pelicun/tests/test_base.py +++ b/pelicun/tests/test_base.py @@ -602,33 +602,6 @@ def test_with_parsed_str_na_values(): ) -def test_process_loc(): - # Test when string can be converted to an int - assert base.process_loc('5', 10) == [ - 5, - ] - - # Test when string is in the form 'low-high' - assert base.process_loc('2-5', 10) == [2, 3, 4, 5] - - # Test when string is 'all' - assert base.process_loc('all', 10) == list(range(1, 11)) - - # Test when string is 'top' - assert base.process_loc('top', 10) == [ - 10, - ] - - # Test when string is 'roof' - assert base.process_loc('roof', 10) == [ - 10, - ] - - # Test when string cannot be converted to an int or recognized - with pytest.raises(ValueError): - base.process_loc('abc', 10) - - def test_run_input_specs(): assert os.path.basename(base.pelicun_path) == 'pelicun'