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

Covmodel arg bugfix: Always convert nugget to float #157

Merged
merged 5 commits into from
Apr 8, 2021

Conversation

MuellerSeb
Copy link
Member

This line of code generated an Error with gstools==1.3.0rc2:

import gstools as gs
print(gs.Matern(nugget=0))
ValueError: Precision not allowed in integer format specifier

Reason: nugget was never converted to float internally and is stored as int (which is totally fine for all calculations), but the printing routine tries to format it as float.

This PR solves this problem and adds some minor additions:

  • rescale was not setable after the model was instantiated: added rescale.setter
  • rescale didn't show up in the repr string: fixed if rescale is not the default value
  • anis and angles where always showing up also for isotropic and unrotated models: fixed

This means, the repr is the exact init sequence to create a model:

from gstools import Matern
exec(f"m={Matern()}")
print(m)
Matern(dim=3, var=1.0, len_scale=1.0, nugget=0.0, nu=1.0)

The conditional repr looks like the following:

from gstools import Matern
print(Matern(rescale=2))
print(Matern(anis=2))
print(Matern(angles=1))
print(Matern(rescale=2, anis=2, angles=1))
Matern(dim=3, var=1.0, len_scale=1.0, nugget=0.0, rescale=2.0, nu=1.0)
Matern(dim=3, var=1.0, len_scale=1.0, nugget=0.0, anis=[1.0, 2.0], nu=1.0)
Matern(dim=3, var=1.0, len_scale=1.0, nugget=0.0, angles=[1.0, 0.0, 0.0], nu=1.0)
Matern(dim=3, var=1.0, len_scale=1.0, nugget=0.0, anis=[1.0, 2.0], angles=[1.0, 0.0, 0.0], rescale=2.0, nu=1.0)

@MuellerSeb MuellerSeb requested a review from LSchueler April 8, 2021 09:59
@MuellerSeb MuellerSeb self-assigned this Apr 8, 2021
@MuellerSeb MuellerSeb added the bug Something isn't working label Apr 8, 2021
@MuellerSeb MuellerSeb added this to the 1.3 milestone Apr 8, 2021
@MuellerSeb MuellerSeb linked an issue Apr 8, 2021 that may be closed by this pull request
Copy link
Member

@LSchueler LSchueler left a comment

Choose a reason for hiding this comment

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

Funny little bug :-)
Thanks for taking a look it.
Check the f-strings and then you can happily merge!

gstools/covmodel/tools.py Outdated Show resolved Hide resolved
gstools/covmodel/tools.py Outdated Show resolved Hide resolved
@MuellerSeb MuellerSeb merged commit 79e7b60 into develop Apr 8, 2021
@MuellerSeb MuellerSeb deleted the covmodel_arg_bugfix branch April 8, 2021 19:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Printing model not possible with nugget=0 (int)
2 participants