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

Importing pypesto hides all warnings #1252

Closed
dweindl opened this issue Dec 16, 2023 · 2 comments · Fixed by AMICI-dev/AMICI#2243
Closed

Importing pypesto hides all warnings #1252

dweindl opened this issue Dec 16, 2023 · 2 comments · Fixed by AMICI-dev/AMICI#2243
Assignees

Comments

@dweindl
Copy link
Member

dweindl commented Dec 16, 2023

$ python -c "import warnings; warnings.warn('bla');"
<string>:1: UserWarning: bla
$ python -c "import pypesto; import warnings; warnings.warn('bla');"
$

This can't be intentional. Not sure yet whether it's pypesto or any of its dependencies.

@dweindl
Copy link
Member Author

dweindl commented Dec 16, 2023

Turns out it's AMICI.

dweindl added a commit to AMICI-dev/AMICI that referenced this issue Dec 18, 2023
Previously, importing amici would result in all warnings of the program being hidden, due to `logging.captureWarnings(True)`:

```sh
$ python -c "import warnings; warnings.warn('bla');"
<string>:1: UserWarning: bla
$ python -c "import amici; import warnings; warnings.warn('bla');"
$
```

This can't be the desired default.

Changes:
* Default to not capturing warnings
* If warnings are to be captured, at least handle them by amici loggers

Closes ICB-DCM/pyPESTO#1252
dweindl added a commit to dweindl/AMICI that referenced this issue Dec 18, 2023
Previously, importing amici would result in all warnings of the program being hidden, due to `logging.captureWarnings(True)`:

```sh
$ python -c "import warnings; warnings.warn('bla');"
<string>:1: UserWarning: bla
$ python -c "import amici; import warnings; warnings.warn('bla');"
$
```

This can't be the desired default.

Changes:
* Default to not capturing warnings
* If warnings are to be captured, at least handle them by amici loggers

Closes ICB-DCM/pyPESTO#1252
dweindl added a commit to AMICI-dev/AMICI that referenced this issue Dec 18, 2023
Improves model code generation by collapsing cases with identical statements.

I.e.
```
switch(a)
 case b:
 case c:
  statements;
  break;
```
instead of

```
switch(a)
 case b:
  statements;
  break;
 case c:
  statements;
  break;
```

For my current model of interest, containing many events, this significantly reduces the generated code:

E.g.:
```
 16K my_model/deltasx.cpp
6,6M my_model_old/deltasx.cpp
```

Overall, for this model, I got from 204201 LOC down to 7936 LOC (i.e. -96%).

* ..

* Apply suggestions from code review

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

* GHA: test python3.12 (#2179)

Run nightly tests also on python3.12

* Deterministic order of event assignments (#2242)

Ensure event assignments targets are processed in deterministic order.
Otherwise the ordering of state variables may change between subsequent
model imports, which we'd like to avoid.

Closes #2241.

* Fix AMICI hiding all warnings (#2243)

Previously, importing amici would result in all warnings of the program being hidden, due to `logging.captureWarnings(True)`:

```sh
$ python -c "import warnings; warnings.warn('bla');"
<string>:1: UserWarning: bla
$ python -c "import amici; import warnings; warnings.warn('bla');"
$
```

This can't be the desired default.

Changes:
* Default to not capturing warnings
* If warnings are to be captured, at least handle them by amici loggers

Closes ICB-DCM/pyPESTO#1252


---------

Co-authored-by: Dilan Pathirana <[email protected]>
@PaulJonasJost
Copy link
Collaborator

as it is amici, will be closing it here.

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 a pull request may close this issue.

2 participants