-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
move late imports to top #26750
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
move late imports to top #26750
Changes from 4 commits
830cf25
e352331
256a536
2caafc8
a0a1d2a
fcdc2d5
c3863d5
d95a9bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,12 @@ | ||
# being a bit too dynamic | ||
from math import pi, sqrt | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You can delete the comment, I guess it refers to how we were importing before. But doesn't seem to add much value in any case. @jreback do you want to avoid loading There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. change these to be np.pi and np.sqrt; we don't use math generally |
||
import random | ||
|
||
import matplotlib.lines as mlines | ||
import matplotlib.patches as patches | ||
import matplotlib.pyplot as plt | ||
import numpy as np | ||
from scipy.stats import gaussian_kde | ||
|
||
from pandas.core.dtypes.missing import notna | ||
|
||
|
@@ -50,7 +56,6 @@ def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False, | |
ax.hist(values, **hist_kwds) | ||
|
||
elif diagonal in ('kde', 'density'): | ||
from scipy.stats import gaussian_kde | ||
y = values | ||
gkde = gaussian_kde(y) | ||
ind = np.linspace(y.min(), y.max(), 1000) | ||
|
@@ -96,14 +101,12 @@ def scatter_matrix(frame, alpha=0.5, figsize=None, ax=None, grid=False, | |
|
||
|
||
def _get_marker_compat(marker): | ||
import matplotlib.lines as mlines | ||
if marker not in mlines.lineMarkers: | ||
return 'o' | ||
return marker | ||
|
||
|
||
def radviz(frame, class_column, ax=None, color=None, colormap=None, **kwds): | ||
import matplotlib.patches as patches | ||
|
||
def normalize(series): | ||
a = min(series) | ||
|
@@ -168,7 +171,6 @@ def normalize(series): | |
|
||
def andrews_curves(frame, class_column, ax=None, samples=200, color=None, | ||
colormap=None, **kwds): | ||
from math import sqrt, pi | ||
|
||
def function(amplitudes): | ||
def f(t): | ||
|
@@ -223,7 +225,6 @@ def f(t): | |
|
||
|
||
def bootstrap_plot(series, fig=None, size=50, samples=500, **kwds): | ||
import random | ||
|
||
# random.sample(ndarray, int) fails on python 3.3, sigh | ||
data = list(series.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.
The
scipy
ones should be moved. It's the same case as with matplotlib, we don't require it unless you call a function that uses it. In this case, if you call a plot (like the line plot), you'll need matplotlib, but not scipy, which you only need if you call the kde plot.This is why the tests are failing (not sure if you've seen the CI is in red). Can you restore the scipy ones please?
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.
Got it! Thanks!