diff --git a/env.yml b/env.yml index a7af26a7..b5983af3 100644 --- a/env.yml +++ b/env.yml @@ -2,7 +2,7 @@ name: suews-dev channels: - conda-forge dependencies: - - python=3.10 + - python=3.11 - geopandas - geoplot - pandas diff --git a/src/supy/supy/_post.py b/src/supy/supy/_post.py index 5a54bc75..44cddbc6 100644 --- a/src/supy/supy/_post.py +++ b/src/supy/supy/_post.py @@ -7,16 +7,21 @@ # post-processing part # get variable information from Fortran def get_output_info_df(): + from packaging.version import parse as LooseVersion + size_var_list = sd.output_size() var_list_x = [np.array(sd.output_name_n(i)) for i in np.arange(size_var_list) + 1] df_var_list = pd.DataFrame(var_list_x, columns=["var", "group", "aggm", "outlevel"]) - if pd.__version__ >= "2.1.0": + + # strip leading and trailing spaces + fun_strip = lambda x: x.decode().strip() + if LooseVersion(pd.__version__) >= LooseVersion("2.1.0"): # if pandas version is 2.1.0 or above, we can use `df.map` - df_var_list = df_var_list.map(lambda x: x.strip()) + df_var_list = df_var_list.map(fun_strip) else: # otherwise, we need to use `df.applymap` - df_var_list = df_var_list.applymap(lambda x: x.decode().strip()) + df_var_list = df_var_list.applymap(fun_strip) df_var_list_x = df_var_list.replace(r"^\s*$", np.nan, regex=True).dropna() var_dfm = df_var_list_x.set_index(["group", "var"]) diff --git a/src/supy/supy/test/test_SuPy.py b/src/supy/supy/test/test_SuPy.py index f673e8ab..45477aac 100644 --- a/src/supy/supy/test/test_SuPy.py +++ b/src/supy/supy/test/test_SuPy.py @@ -23,7 +23,7 @@ p_df_sample = Path(test_data_dir) / 'sample_output.pkl' # if platform is macOS and python version is 3.9, set flag_full_test to True -flag_full_test = (sys.version_info[0] == 3 and sys.version_info[1] == 10 and platform.system() == "Darwin") +flag_full_test = (sys.version_info[0] == 3 and sys.version_info[1] == 11 and platform.system() == "Darwin") class TestSuPy(TestCase): def setUp(self):