Skip to content

Commit

Permalink
fix looseversion deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
sunt05 committed Aug 30, 2023
1 parent 885297d commit 9bbfa90
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 1 addition & 1 deletion env.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: suews-dev
channels:
- conda-forge
dependencies:
- python=3.10
- python=3.11
- geopandas
- geoplot
- pandas
Expand Down
11 changes: 8 additions & 3 deletions src/supy/supy/_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion src/supy/supy/test/test_SuPy.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down

0 comments on commit 9bbfa90

Please sign in to comment.