-
Notifications
You must be signed in to change notification settings - Fork 9
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
Fix type hints #255
Fix type hints #255
Conversation
$ mypy modelskill/comparison/
Success: no issues found in 6 source files |
$ mypy modelskill/
Success: no issues found in 29 source files Which translates to no unknown issues, there are still plenty of lines with a This PR allows us to use type hints with more confidence, since future changes can be verified with |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see the tests are failing but I went through the changes anyway - here are my comments
@@ -20,7 +20,7 @@ def scatter( | |||
self, | |||
*, | |||
model=None, | |||
bins: Union[int, float, List[int], List[float]] = 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why are these removed - matplotlib allows to give edges as a list - (actually str also works) https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There were no tests with bins as a list of values. And when I tried it failed to produce a scatter plot
The type hints should reflect working functionality (== tested).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@daniel-caichac-DHI can you help here - are the bins as a list of edges needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to have automatic bins but sometimes someone might want to reproduce an old plot or a plot with given bins (eg, bins that are not equidistant, logarithmic bins (for whatever reason?)
I'll try to see if if works with bins= list of values
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess also when you want consistent plots with the same bins across many plots?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TRUE
def scatter( | ||
self, | ||
*, | ||
model=None, | ||
bins: Union[int, float, List[int], List[float]] = 20, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see above - and actually "float" is not allowed?? https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.hist.html
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's fix this in a separate PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by: Union[str, List[str]] = None, | ||
metrics: list = None, | ||
by: Optional[Union[str, List[str]]] = None, | ||
metrics: Optional[list] = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Allow Sequence?
# TODO does this work as intended? Mutable default values, e.g. dict, list, are usually not recommended | ||
register_option( | ||
key="plot.rcParams", defval={}, validator=settings.is_dict | ||
) # still have to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...to what?
|
||
if not isinstance(quantiles, (int, Sequence)): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You removed this - but what if quantiles is float or str?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's go!
which in some cases, means removing the type hints or muting it with
# type : ignore
.