You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
When initializing an FMModel with empty paths (""), these are upgraded to pathlib.Path("."), which results in a . in the mdu file instead of an empty value.
To Reproduce
The following code fails with AssertionError since mdu.output.outputdir=WindowsPath("."). When generating a mdu file from scratch (mdu_clean), the value is according to expectations.
fromhydrolib.core.dflowfmimportFMModel# this succeedsmdu_clean=FMModel()
assertmdu_clean.output.outputdir==""# this failsmdu_clean=FMModel()
mdu_clean.output.outputdir=""assertmdu_clean.output.outputdir==""# AssertionError, since it is a pathlib.Path(".")# this fails (comparable as above, but the hydromt_delft3dfm approach for initializing an FMModel)cf_dict= {"output": {"outputdir":""}}
mdu=FMModel(**cf_dict)
assertmdu.output.outputdir==""# AssertionError, since it is a pathlib.Path(".")
Investigation by @tim-vd-aardweg:
Volgens mij is het met Path alléén niet mogelijk om onderscheid te maken tussen een lege string en een ., want Path("") == Path("."). Ik heb naar de internals gekeken van Path en kon ook niets vinden.. Dus ik denk dat er iets van een custom class gemaakt moet worden hiervoor. Iets als:
Describe the bug
When initializing an FMModel with empty paths (
""
), these are upgraded topathlib.Path(".")
, which results in a.
in the mdu file instead of an empty value.To Reproduce
The following code fails with
AssertionError
sincemdu.output.outputdir=WindowsPath(".")
. When generating a mdu file from scratch (mdu_clean
), the value is according to expectations.Related issues:
-999
: feat: Don't write keywords with None values #663.
: Don't write keywords with a None value to the files #661 (comment)Expected behavior
mdu.output.outputdir
to be an emtpy string (""
)Version info (please complete the following information):
The text was updated successfully, but these errors were encountered: