-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
👌 Improve Project API data handling (#1257)
This PR improves the data handling of the Project API in notebook workflows. Since notebooks are often executed as a whole (`Run All`) the default of `ignore_existing=False` in `project.import_data` leads to using `ignore_existing=True` each time calling it in an actual case study, which makes the code less readable and adds a lot of redundancy and a default of `ignore_existing=True` is more sensible (IMHO `ignore_existing=False` only makes sense in a CLI or GUI context). Having to import each dataset one by one also clutters the code quite a lot. ```py project.import_data("measured_data/Npq2_220219_800target3fasea.ascii", dataset_name="TA") project.import_data(guide_s1, dataset_name="guide_s1") project.import_data(guide_s2, dataset_name="guide_s2") project.import_data(guide_s3, dataset_name="guide_s3") project.import_data(guide_s4, dataset_name="guide_s4") project.import_data(guide_s5, dataset_name="guide_s5") project.import_data(guide_s6, dataset_name="guide_s6") project.import_data(guide_s7, dataset_name="guide_s7") project.import_data(guide_s8, dataset_name="guide_s8") ``` This is why it is a lot more convenient to allow the use of a mapping (especially since that mapping could have been defined and used for plotting even before importing glotaran at all) ```py my_datasets ={ "TA":"measured_data/Npq2_220219_800target3fasea.ascii" "guide_s1":guide_s1, "guide_s2":guide_s2, "guide_s3":guide_s3, "guide_s4":guide_s4, "guide_s5":guide_s5, "guide_s6":guide_s6, "guide_s7":guide_s7, "guide_s8":guide_s8, } project.import_data(my_datasets) ``` Lastly, users might want to switch out datasets in the optimization without touching the model definition for example to use an averaged dataset to have a quicker feedback loop or to use some other kind of preprocessing/correcting on the data and compare results with the exact same model. ```py project.optimize("my_model", "my_parameters", data_lookup_overwrite={"TA": averaged_data}) ``` * 👌 Change default of ignore_existing in import_data to True This allow using a notbook workflow w/o cluttering it with 'ignore_existing=True' all over the place * 👌 Allow importing data from a mapping * 👌 Add data_overwrite option to Result.optimize and Result.create_scheme * 👌 Changed data_overwrite to data_lookup_overwrite to clarify that data are not overwritten * 🚧📚 Added change to changelog * 🩹 Fix allow_overwrite=True not having any effect if ignore_existing=True * 🧹 Renamed data_lookup_overwrite to data_lookup_override * 👌 Apply suggestions from code review Co-authored-by: Joris Snellenburg <[email protected]> --------- Co-authored-by: Joris Snellenburg <[email protected]>
- Loading branch information
Showing
4 changed files
with
113 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters