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

Do not add NoiseModel to Model-class by default anymore #678

Merged
merged 52 commits into from
Apr 15, 2024

Conversation

rubencalje
Copy link
Collaborator

@rubencalje rubencalje commented Jan 19, 2024

Short Description

This Pull Request does not add a noisemodel to the Model class by default anymore.

See issue #735 for more information.

Checklist before PR can be merged:

@rubencalje rubencalje changed the base branch from master to dev January 19, 2024 09:19
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.13% (target: +0.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9c76689) 5833 4358 74.71%
Head commit (6ceb401) 5859 (+26) 4385 (+27) 74.84% (+0.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#678) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Copy link

codacy-production bot commented Jan 19, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.13% (target: +0.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (9c76689) 5833 4358 74.71%
Head commit (183c542) 5859 (+26) 4385 (+27) 74.84% (+0.13%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#678) 3 3 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

where necessary to get same output
@raoulcollenteur
Copy link
Member

Should we merge this for 1.4 or wait one version? Giving a warning early about this future change might be good?

@rubencalje
Copy link
Collaborator Author

Should we merge this for 1.4 or wait one version? Giving a warning early about this future change might be good?

I agree, an early warning is good. I am in favor of merging before the next version.

@mbakker7
Copy link
Collaborator

This is a big change (although I am all for it). As this will give different results with the default values for many models, I think it warrants a major version number change. Should we go to 2.0 for this?
Regarding a warning, what warning would you like to give. Every time ml.solve is called warn the user that in the future (2.0) the default will be noise=False? That would surely get annoying and we shouldn't do that for too many versions.

@dbrakenhoff
Copy link
Member

Perhaps a global "I got it, don't keep warning me" option would be nice to include, to avoid repeating the warning so often people stop reading it?

@mbakker7
Copy link
Collaborator

Perhaps a global "I got it, don't keep warning me" option would be nice to include, to avoid repeating the warning so often people stop reading it?

Any thought on how to implement this? You want to give this warning once after the first solve after a Pastas import?
I am mostly worried that people will turn warnings off. Which is what I would do in their case as well.

@dbrakenhoff
Copy link
Member

Any thought on how to implement this? You want to give this warning once after the first solve after a Pastas import?
I am mostly worried that people will turn warnings off. Which is what I would do in their case as well.

Maybe a global boolean setting that is flipped after one solve call? And can be turned off manually as well? And turning it off would then mean your code includes something like ps.turn_off_default_noise_false_warning() which indicates some awareness of the future change in default behavior? But I haven't completely thought it through yet, it was just an idea that popped up as I read the previous comments.

@rubencalje
Copy link
Collaborator Author

People can just set noise=True in their code, which is what we want them to do. Implementing a global boolean or something else to bypass this warning will make them not set noise=True in their code, which will then give different results in the future. So I am not in favor of hiding the warning.

@martinvonk
Copy link
Collaborator

I found this on stackoverflow so that you can raise warnings and log them without duplicating the message: logging.captureWarnings(True)

@martinvonk
Copy link
Collaborator

martinvonk commented Mar 7, 2024

Related to the comment above: this works for me in #700 to raise a FutureWarning in the logger:

from logging import captureWarnings, getLogger
from warnings import warn

captureWarnings(True)
logger = getLogger(__name__)
warnings_logger = getLogger("py.warnings")
logger.addHandler(warnings_logger)

warn(
    "Type Your Message Here",
    category=FutureWarning,
)

@rubencalje rubencalje marked this pull request as ready for review March 15, 2024 09:30
Copy link

codacy-production bot commented Mar 15, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.33% (target: +0.00%) 100.00%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (a2e178b) 6084 4580 75.28%
Head commit (e6b5266) 6137 (+53) 4640 (+60) 75.61% (+0.33%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#678) 10 10 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@raoulcollenteur raoulcollenteur added this to the 1.5 milestone Mar 19, 2024
pastas/model.py Outdated Show resolved Hide resolved
pastas/model.py Outdated Show resolved Hide resolved
@raoulcollenteur raoulcollenteur added enhancement Indicates improvement of existing features development Indicates development of new features labels Mar 19, 2024
@mbakker7
Copy link
Collaborator

For version 2.0, I think the default should be to add a NoiseModel like adding a stress model. That way different noise models can be added. So my suggestion for version 2.0 is that ml.solve can not add a noise model. Come to think of it, this may have been the original implementation of a noise model in the first versions of pastas.

@raoulcollenteur
Copy link
Member

@rubencalje, can you implement the same for ml = Model(noisemodel=True) and set the default to False? Then no noisemodel is silently added by default anymore and users have to be explicit there as well.

@rubencalje
Copy link
Collaborator Author

@rubencalje, can you implement the same for ml = Model(noisemodel=True) and set the default to False? Then no noisemodel is silently added by default anymore and users have to be explicit there as well.

I can do that, but I think we then need to change the default behavior of the noise-parameter in ml.solve() to: if you have added a noisemodel, solve with noise = True, and if you have not added a noisemodel, solve with noise = False.

We then remove the warning implemented now, and add a similar warning to the __init__ of the Model-class.

Copy link

codacy-production bot commented Apr 11, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.01% (target: +0.00%) 68.97%
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (bf64e28) 6163 4647 75.40%
Head commit (a7b4223) 6242 (+79) 4707 (+60) 75.41% (+0.01%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#678) 87 60 68.97%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

@raoulcollenteur
Copy link
Member

This PR is ready for review again.

@rubencalje
Copy link
Collaborator Author

I made some changes to the messages that I think will inform the user a bit better.

@rubencalje
Copy link
Collaborator Author

Made a change so that loading of pas-files from versions before 1.5 that were solved with ml.solve(noise=False) can be loaded and will give the same results, by removing the noisemodel from these models. PR can be merged.

I added a few words and the Github issue with clarification.
@mbakker7
Copy link
Collaborator

mbakker7 commented Apr 12, 2024

Before putting this in dev, I think @martinvonk and @OnnoEbbens should merge their PRs (#732 and #729) in this PR first.

mbakker7 and others added 8 commits April 12, 2024 11:32
change capslock to only capital for first letter
Changes 
NoiseModel -> ArNoiseModel
ArmaModel -> ArmaNoiseModel
Co-authored-by: Raoul Collenteur <raoulcollenteur@gmail.com>
Co-authored-by: Davíd Brakenhoff <d.brakenhoff@artesia-water.nl>
Copy link
Collaborator

@mbakker7 mbakker7 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is ready to go.
Big but important step forward.

@raoulcollenteur raoulcollenteur removed the request for review from dbrakenhoff April 15, 2024 05:14
@raoulcollenteur raoulcollenteur merged commit 8ec2944 into dev Apr 15, 2024
11 of 12 checks passed
@raoulcollenteur raoulcollenteur deleted the prepare_noise_is_false branch April 15, 2024 05:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
development Indicates development of new features enhancement Indicates improvement of existing features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants