-
-
Notifications
You must be signed in to change notification settings - Fork 75
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
split core into smaller files #237
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #237 +/- ##
==========================================
+ Coverage 95.73% 95.79% +0.05%
==========================================
Files 12 15 +3
Lines 1901 1927 +26
==========================================
+ Hits 1820 1846 +26
Misses 81 81 ☔ View full report in Codecov by Sentry. |
@lmfit/uncertainties-admins This is ready for review now. This is mostly copy and paste, with some changes to prevent passing AffineScalarFunc and LinearCombination to the arithmetic/comparative op functions before they're defined.
|
@andrewgsavage sorry for the delay on this. I think this splitting up of the code is very helpful. +1 on merging. |
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.
This looks great (and, again, sorry for the delay). I might have kept "ops" and "parsing" together, but this is perfectly reasonable too.
I think the complaints from codecov are noise we can ignore here, and maybe try to address separately.
I also like this refactoring in principle. I had wanted to find time to go through and follow how things were moving around in the namespace, but I am fine with @newville's approval. One thing to note: a grep of the repo for So I would consider the following:
Outside of this PR, I think it would be good to get rid of the |
good question, I don't see any other ways to approach this other than what's in
It's not yet clear to me what I'd like uncertainties namespace to look like so I'd hold off on changing docs until we're happy with where things are located. For example I think it'd be worthwhile moving the code used to create the classes Variable, LinearCombination, AffineScalarFunc
Done
Absolutely, atm I'm implicitly taking it to be anything defined in |
can this be merged? |
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 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 found some time to look at this more closely. I think it looks good overall, but I noticed a few small things that I commented on in line.
I realized that my previous comment about __all__
was not completely accurate. There already is an __all__
in core.py that gets pulled up into uncertainties/__init__.py
. We should try to promote the two things in uncertainties.core
referenced in the documentation to uncertainties
and uncertainties.__all__
and then discourage use of anything not in uncertainties.__all__
. We don't have to do that here. I checked that this PR does remove anything that was already in uncertainties
or uncertainties.__all__
.
One side comment -- I am not sure I like the way this PR moves some of the logic of setting up AffineScalarFunc
out of core.py by moving it into functions of cls
in other files where cls
is intended to be only AffineScalarFunc
so that those functions can be defined before AffineScalarFunc
so they can be imported into core.py and called on AffineScalarFunc
.
uncertainties/core.py
Outdated
# Nicer name, for users: isinstance(ufloat(...), UFloat) is | ||
# True. Also: isinstance(..., UFloat) is the test for "is this a | ||
# number with uncertainties from the uncertainties package?": | ||
UFloat = AffineScalarFunc | ||
|
||
def wrap(*args, **kwargs): |
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.
wrap
is a public function and this change loses the docstring and signature that it currently has. It would be better to keep those here.
uncertainties/formatting.py
Outdated
|
||
|
||
def isinfinite(x): | ||
# TODO: Usages of this function should be replaced with not math.isfinite. |
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.
This came from a code block that was providing backwards compatibility for Python before 3.2. It could just be from math import isinfinite
now.
def format(*args, **kwargs): | ||
return args[0].__format__(*args[1:], **kwargs) | ||
|
||
return format_ufloat(self, format_spec) |
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.
This lost a big docstring (now in format_ufloat). The __format__
docstring is currently referenced by the format_num
docstring.
@wshanks Thanks. From a practical point of view, do you think you and @andrewgsavage should work these things out before merging, or do you think we can merge this work and then fix this once in master? I don't have a strong opinion on this. Having just released "solid, patched 3.2.2", I am okay with a master branch that may be a little messy and may be revised as we move toward 4.0. I suggest you merge this when you think it is close enough, and we can work from that point. |
Is there a better way to do this? |
The three comments I put in line should be easy to address, I think. The other comments I put in the summary don't need to be addressed here.
I have to think about it more. It might be something that is easier after more refactoring but we don't need to change it here. |
ok addressed those |
Looks good! |
the changes from #198