Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Release v0.4.2 #1298

Merged
merged 50 commits into from
Feb 6, 2024
Merged

Release v0.4.2 #1298

merged 50 commits into from
Feb 6, 2024

Conversation

PaulJonasJost
Copy link
Collaborator

@PaulJonasJost PaulJonasJost commented Jan 30, 2024

dweindl and others added 30 commits December 6, 2023 12:14
Store traces of the best values/parameters for the ESSOptimizer and the best
values of each worker for the SacessOptimizer.
Adding type annotations, fixing some typos.

Co-authored-by: Dilan Pathirana <[email protected]>
Co-authored-by: Paul Jonas Jost <[email protected]>
* Initial, missing regularization grad

Initial commit with spline regularization.
The implementation of the gradient wrt theta is not completed (swapping to develop for some debugging of censored).

Additionally, small fixes of censored gradient (sigma related, not important usually).

* Complete gradient

Implemented the complete gradient, including the regularization term for the ds_dtheta

* Fix par plot, add reg to spline plot

FIxed the parameter plot issue (will be in a separate PR).
Added the linear regularization to the spline visualization.

* Some random changes TODO

Changes that I might have to revert for the Pull request. The ensemble one might've already been pushed by Polina. The solver one completely circumvents dsdtheta gradient calculation due to some "array cannot be inf or NaN" error which pops sometimes, but it's mostly always 0 so removing it makes it easier to deal with for now. This is a big TODO, do not forget.

* Fix par_sim_idx in spline solver

Fixed the par_sim_idx in the spline solver calculate gradient function. For all conditions, the rdata form is not managed by par_sim_idx, but with par_edata_indices. This is done such that if some parameters are not used in the condition (observable or noise parameters for instance) then the sensitivities wrt. them don't have to be calculated

* Fix par_sim_index, pass edata_indices

Added the passing of the edata indices from the calculator to the solver gradient calculation.
Additionally, fixed the inner calculator collector quantitative calculation with nansum instead of a regular one (sometimes it gave only nan values because of this...)

* Remove ds_dtheta_term calculation

Since I've proven that the ds_dtheta gradient contribution is always 0, we can remove all of the code that was calculating it

* Remove redundancy

* Small cleanup

* Remove a mistake

* Add regularization test

* Quality test fix

* Spline tests fix + obj fun fix

* Notebook update

- Updated the notebook for non-linear semi-quantitative data
- fixed the max_sensi_order problem
- changed default min_diff_factor
- fix quality

* Daniel review changes

* Dilan&Fabian review changes

* Improve test coverage

Added tests for untested lines in calculators

---------

Co-authored-by: Stephan Grein <[email protected]>
* Update misc.py

Add option for hierarchical models in model selection

* Update misc.py

Fix typo

* Update misc.py

import pandas

* Update pypesto/select/misc.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update pypesto/select/misc.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update pypesto/select/misc.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update pypesto/select/misc.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update pypesto/select/misc.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update misc.py

* Update misc.py

* Update misc.py

---------

Co-authored-by: Dilan Pathirana <[email protected]>
* test

* test2-changed

* Add simulation_edatas argument into the AmiciCalculator and Objective

* Implement set_simulation_edatas for the hierarchical calculator

* Update test for simulation edatas.

* Update set simulation edatas.

* Fix additional argument inserted before.

* Enable check of the simulation_edatas in the objective call.

* Update pypesto/hierarchical/problem.py

Co-authored-by: Daniel Weindl <[email protected]>

* Update pypesto/hierarchical/calculator.py

Co-authored-by: Daniel Weindl <[email protected]>

* Fix type checking

* Undo changes in objective and calculator. Instead fix it temporarily in the visualization routine.

* Update model_fit.py

Disable sensitivities to improve computation time.

* Outsource definition of simulation rdatas to a separate helper function.

* Update comments.

* Move helper function into model_fit script.

---------

Co-authored-by: Daniel Weindl <[email protected]>
* log space startpoint sampling

* Some updates

* Update pypesto/hierarchical/solver.py

Co-authored-by: Daniel Weindl <[email protected]>

* Update pypesto/hierarchical/solver.py

Co-authored-by: Daniel Weindl <[email protected]>

* Update solver.py

* Update pypesto/hierarchical/solver.py

Co-authored-by: Dilan Pathirana <[email protected]>

* Update pypesto/hierarchical/solver.py

Co-authored-by: Dilan Pathirana <[email protected]>

---------

Co-authored-by: Daniel Weindl <[email protected]>
Co-authored-by: Dilan Pathirana <[email protected]>
…scaling parameters (#1238)

* Initial working

Implemented scaling and offset bounds for the analytical and numerical solver of the hierarchical problem.

* Fix hierarchical test

* Add test_constrained_inner_solver

* Add tests for non coupled parameters

* intentional failure

* intentional failure

* intentional failure

* Test fix

It seems L-BFGS-B would not converge to optimum in some cases if it was provided with the big bounds [-1e20, 1e20]. It seems like it is a scipy issue? Not sure.
In any case, the numerical optimizer is better if the optimization is not provided with these dummy bounds. But in this case, we need to sample the bounds outside of the pypesto minimize function and provide it as x_guesses.

* Add notebook changes

* Update C.py

* Revert "Update C.py"

This reverts commit f099a2b.

* Fix sampling + test

* Cleanup

* Some updates

* Some more small updates

* Add inner bounds to parameter plot

* Fix import issues

* Fix hier test

* Fix parameter plot test

* Remove figures

* DIlan&Daniel review changes

* Update parameters.py

* Update solver.py
Fix return type documentation, cross references, typo, deprecated type annotations.
* Doc: enable linking to matplotlib docs

* petab-select

* link
#1248)

* Doc: Fix links, typos, grammer, punctuation in doc/example/amici.ipynb

* doc/example/petab_import.ipynb

* doc/example/getting_started.ipynb
So far, after updating amici, test.util.load_amici_objective would fail with AmiciVersionError.
In that case, we just want to re-import the model. That's what's achieved here.
* Hier. par. plotting for fides

* hierarchical 'hess' bug

* Fix storing of inner parameters in result

Inner parameters were not being stored when the result was stored. This was due to a problem with putting a dictionary into an HDF5 format. I've transformed it into 2 lists now: a INNER_PARAMETERS_VALUES and INNER_PARAMETER_NAMES list.

* adjusted documentation of hierarichal opt.

* Fix some type issues

* Small fix

* Save only values, not names

* Extend to all optimizers

* Remove redundant

* Small update

* Update parameters.py

* Small typo

* Fix some bugs, use lists for saving instead

* Fix tests

* Update hierarchical parameter plot test

* Daniel&Dilan review changes

* Small change

* More Dilan Review changes

* Fix testing

* Fix base test

* Move inner pars to decorator

* Collect decorators for minimize

* Maren review changes

---------

Co-authored-by: Lea@Mac <[email protected]>
Might resolve frequent cache misses for Julia tests.


Co-authored-by: Doresic <[email protected]>
We have limit cache size. Only cache what's really relevant.
Avoid such issues:
```
    fig = plt.figure()
.tox\windows\Lib\site-packages\matplotlib\pyplot.py:934: in figure
    manager = new_figure_manager(
.tox\windows\Lib\site-packages\matplotlib\pyplot.py:465: in new_figure_manager
    return _get_backend_mod().new_figure_manager(*args, **kwargs)
.tox\windows\Lib\site-packages\matplotlib\backend_bases.py:3402: in new_figure_manager
    return cls.new_figure_manager_given_figure(num, fig)
.tox\windows\Lib\site-packages\matplotlib\backend_bases.py:3407: in new_figure_manager_given_figure
    return cls.FigureCanvas.new_manager(figure, num)
.tox\windows\Lib\site-packages\matplotlib\backend_bases.py:1785: in new_manager
    return cls.manager_class.create_with_canvas(cls, figure, num)
.tox\windows\Lib\site-packages\matplotlib\backends\_backend_tk.py:486: in create_with_canvas
    window = tk.Tk(className="matplotlib")
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

self = <tkinter.Tk object .>, screenName = None, baseName = 'pytest.EXE'
className = 'matplotlib', useTk = True, sync = False, use = None

    def __init__(self, screenName=None, baseName=None, className='Tk',
                 useTk=True, sync=False, use=None):
        """Return a new top level widget on screen SCREENNAME. A new Tcl interpreter will
        be created. BASENAME will be used for the identification of the profile file (see
        readprofile).
        It is constructed from sys.argv[0] without extensions if None is given. CLASSNAME
        is the name of the widget class."""
        self.master = None
        self.children = {}
        self._tkloaded = False
        # to avoid recursions in the getattr code in case of failure, we
        # ensure that self.tk is always _something_.
        self.tk = None
        if baseName is None:
            import os
            baseName = os.path.basename(sys.argv[0])
            baseName, ext = os.path.splitext(baseName)
            if ext not in ('.py', '.pyc'):
                baseName = baseName + ext
        interactive = False
>       self.tk = _tkinter.create(screenName, baseName, className, interactive, wantobjects, useTk, sync, use)
E       _tkinter.TclError: Can't find a usable tk.tcl in the following directories: 
E           C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tcl8.6/tk8.6 C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6 C:/hostedtoolcache/windows/Python/3.11.7/lib/tk8.6 C:/hostedtoolcache/windows/Python/3.11.7/lib/tk8.6 C:/hostedtoolcache/windows/Python/lib/tk8.6 C:/hostedtoolcache/windows/Python/3.11.7/library
E       
E       C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/tk.tcl: couldn't read file "C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/ttk/scrollbar.tcl": no such file or directory
E       couldn't read file "C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/ttk/scrollbar.tcl": no such file or directory
E           while executing
E       "source -encoding utf-8 [file join $::ttk::library scrollbar.tcl]"
E           (file "C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/ttk/ttk.tcl" line 102)
E           invoked from within
E       "source -encoding utf-8 C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/ttk/ttk.tcl"
E           ("uplevel" body line 1)
E           invoked from within
E       "uplevel \#0 [list source -encoding utf-8 $::ttk::library/ttk.tcl]"
E           (file "C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/tk.tcl" line 706)
E           invoked from within
E       "source C:/hostedtoolcache/windows/Python/3.11.7/x64/tcl/tk8.6/tk.tcl"
E           ("uplevel" body line 1)
E           invoked from within
E       "uplevel #0 [list source $file]"
E       
E       
E       This probably means that tk wasn't installed properly.

C:\hostedtoolcache\windows\Python\3.11.7\x64\Lib\tkinter\__init__.py:2326: TclError
```
e.g. here https://github.com/ICB-DCM/pyPESTO/actions/runs/7261863194/job/19783894242?pr=1243
* delete_nan_inf can handle list input type

* handle case of single opt result

* get values as list per start

* move delete nan inf to outer parameters function

* update tests

---------

Co-authored-by: Daniel Weindl <[email protected]>
Fixes `.github/workflows/install_deps.sh: 13: [: Linux: unexpected operator`

https://github.com/ICB-DCM/pyPESTO/actions/runs/7265048086/job/19793906617
So far, the OptimizerResults from Ess/Cess/SacessOptimizer (incorrectly) contained only the estimated parameter values.
Now, fixed parameters are included as well, as done for the other Optimizers.
…0 is None (#1266)

Previously, this would fail if `full=False` and `x0=None` (`TypeError: 'NoneType' object is not subscriptable`).
Co-authored-by: Daniel Weindl <[email protected]>
Co-authored-by: Daniel Weindl <[email protected]>
Prerequisite for #1246:

* Ubuntu 22.04 on RTD
* Install all relevant deps on RTD
* GHA: More time for documentation job
Added `pypesto.visualize.optimizer_history.sacess_history` to visualize
SacessOptimizer histories. In principle, they could be plotted the same
as any other history, but here a step plot is usually preferable, and we
show the global best in addition to all workers.
* Enable create_objective to pass verbose to create_model

* Add verbose as argument

Added verbose as argument in all importer method which use `create_model` and passed it onto it.
tqdm progress bars are used in a couple of places. They don't play so well in
non-interactive jobs, testing, ... . They also cause trouble with nbspinx
(#1246, #1271).
Progress bars can be disabled for specific tasks, but not globally (or at
least not very conveniently).
Since recently, tqdm can be controlled via environment variables (e.g.,
disabling all progress bars or changing update frequency). However,
this works by changing the argument defaults, so it only works if we don't
pass explicit `disable=...`. Therefore, this PR introduces some wrapper that
checks whether the user explicitly enabled/disabled progress bars. If not,
we go with the tqdm default, which means showing all progress bars unless
globally disabled. An additional `enabled` argument is added for convenience.

---------

Co-authored-by: Dilan Pathirana <[email protected]>
Update SacessOptimizer documentation

---------

Co-authored-by: Paul Jonas Jost <[email protected]>
dweindl and others added 7 commits January 16, 2024 14:27
…1270)

Include results for all local searches in scatter search `OptimizeResult`. Those might be useful for creating ensembles or waterfall plots.
* add extended history for AmiciObjective

* convert ms to s

* no amici in pypesto.optimize

* Update test/base/test_history.py

Co-authored-by: Daniel Weindl <[email protected]>

* Update pypesto/optimize/optimizer.py

Co-authored-by: Daniel Weindl <[email protected]>

* Update pypesto/history/amici.py

Co-authored-by: Fabian Fröhlich <[email protected]>

* more compact code

---------

Co-authored-by: Maren Philipps <[email protected]>
Co-authored-by: Maren Philipps <[email protected]>
Co-authored-by: Daniel Weindl <[email protected]>
Co-authored-by: Fabian Fröhlich <[email protected]>
Use different directories for models from different amici versions
(e.g., `amici_models/0.20.0/{model_name}` instead of `amici_models/{model_name}`).
Allows switching between amici versions without version errors or re-importing the model.
* Add hierarchical to Problem

* Change to HierarchicalProblem class

* Add to importer

* Daniel review changes

* Daniel review change

* Paul review changes
…DF5 without an Objective (#1253)

Allows using warnings filter to get rid of this message.


```python
import warnings
warnings.filterwarnings("ignore", category=UserWarning, message=".*You are loading a problem.*", module="pypesto.store.read_from_hdf5")
```
It's unclear why `EnsemblePrediction.predictor` would be needed.
This PR removes a seemingly useless log message.
@codecov-commenter
Copy link

codecov-commenter commented Jan 30, 2024

Codecov Report

Attention: 210 lines in your changes are missing coverage. Please review.

Comparison is base (b4a187f) 84.24% compared to head (f46ca20) 84.40%.

Files Patch % Lines
pypesto/visualize/spline_approximation.py 11.11% 56 Missing ⚠️
pypesto/hierarchical/petab.py 45.83% 39 Missing ⚠️
pypesto/hierarchical/relative/calculator.py 77.92% 17 Missing ⚠️
pypesto/visualize/model_fit.py 46.66% 16 Missing ⚠️
pypesto/hierarchical/base_problem.py 83.69% 15 Missing ⚠️
pypesto/hierarchical/semiquantitative/solver.py 88.17% 11 Missing ⚠️
pypesto/hierarchical/relative/solver.py 93.86% 10 Missing ⚠️
pypesto/hierarchical/relative/problem.py 73.07% 7 Missing ⚠️
pypesto/petab/importer.py 84.44% 7 Missing ⚠️
pypesto/optimize/ess/ess.py 78.94% 4 Missing ⚠️
... and 15 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1298      +/-   ##
==========================================
+ Coverage   84.24%   84.40%   +0.15%     
==========================================
  Files         148      153       +5     
  Lines       11865    12456     +591     
==========================================
+ Hits         9996    10513     +517     
- Misses       1869     1943      +74     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

PaulJonasJost and others added 3 commits February 1, 2024 11:33
* Updated version and Changelog.

* Added other commits.

* Small typo

---------

Co-authored-by: Doresic <[email protected]>
@PaulJonasJost PaulJonasJost marked this pull request as ready for review February 5, 2024 09:46
dilpath and others added 2 commits February 5, 2024 15:52
* Remove flake8-black due to no updates and running black separately already.

* Solved B038 error on flake8

* Added to CHANGELOG.rst

* Updated Changelog
@PaulJonasJost PaulJonasJost merged commit 34e89b3 into main Feb 6, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants