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
Some general cleanups #6573
Some general cleanups #6573
Conversation
- Remove some very old compatibility layers (sets module, md5 module, etc.) - Use `astype(float)` instead of `astype(np.float)` and `astype(np.float_)` - Use `isinstance(..., MaskedArray)` instead of `isMaskedArray` / `isMA`.
On 2016/06/10 8:56 PM, Antony Lee wrote:
What is the advantage of this change? |
|
||
from .path import Path | ||
|
||
DEBUG = False | ||
# we need this later, but this is very expensive to set up | ||
MINFLOAT = np.MachAr(float).xmin |
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.
Have you benchmarked this change. It was done like this for performance reasons. See
2d0cc7d
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.
Ok read the docs it seems like finfo is a cached version of MachAr so it is probably fine
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.
It is a slower than just reading off a global but still much faster than MachAr and even than allocating a new array of size 1.
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 am also mildly concerned about this, but this is almost certainly not the bottle neck any more.
re: |
On 2016/06/11 5:48 AM, Antony Lee wrote:
I have no objection to making the change; your rationale is fine. |
@@ -2344,7 +2343,7 @@ def pts_to_poststep(x, *args): | |||
# do normalization | |||
vertices = _step_validation(x, *args) | |||
# create the output array | |||
steps = ma.zeros((vertices.shape[0], 2 * len(x) - 1), np.float) | |||
steps = np.zeros((vertices.shape[0], 2 * len(x) - 1), np.float) |
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.
These got missed in the np.float
-> float
conversion.
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.
It's also not the masked array zeros
, if that makes a difference.
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's quite a few np.float
left; this one is safe to replace but I'd need to do some more research to figure out how this changes calls to np.issubdtype
and others.
WRT to np.zeros
vs ma.zeros
, see below.
Moving to use |
@@ -126,6 +126,7 @@ | |||
cycler) | |||
|
|||
import numpy | |||
import numpy.ma |
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.
What effect does this have?
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.
Ensure that everyone can directly use np.ma.<xyz>
without importing numpy.ma
.
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.
Actually, it doesn't do anything at all. It's superfluous.
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.
Indeed, removed.
plus other comments on the PR.
👍 if @efiring is happy with the way the MA stuff ended up. |
astype(float)
instead ofastype(np.float)
andastype(np.float_)
isinstance(..., MaskedArray)
instead ofisMaskedArray
/isMA
.Some other cleanup ideas:
if debug
prints (mostly present in backend implementations just to indicate that a method has been called): I think that a tool such as https://pypi.python.org/pypi/hunter is typically more appropriate anyways.logging
and read off an environment variable such asMPLVERBOSITY
instead of command-line arguments which are likely to be set for other purposes.