-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
DEPR: allow options for using bottleneck/numexpr #16157
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
049be52
DEPR: allow options for using bottleneck/numexpr
jreback aad3846
DEPR: pandas.types.concat.union_categoricals in favor of pandas.api.t…
jreback c7d7d36
fix for comments & test for compute.use_* options
jreback 6e12bfc
typo
jreback 629467a
remove warnings
jreback bb5af81
add back use_bottleneck test
jreback File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import warnings | ||
|
||
|
||
def set_use_numexpr(v=True): | ||
warnings.warn("pandas.computation.expressions.set_use_numexpr is " | ||
"deprecated and will be removed in a future version.\n" | ||
"you can toggle usage of numexpr via " | ||
"pandas.get_option('compute.use_numexpr')", | ||
FutureWarning, stacklevel=2) | ||
from pandas import set_option | ||
set_option('compute.use_numexpr', v) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,9 @@ | ||
import itertools | ||
import functools | ||
import numpy as np | ||
import operator | ||
import warnings | ||
|
||
try: | ||
import bottleneck as bn | ||
_USE_BOTTLENECK = True | ||
except ImportError: # pragma: no cover | ||
_USE_BOTTLENECK = False | ||
|
||
import numpy as np | ||
from pandas import compat | ||
from pandas._libs import tslib, algos, lib | ||
from pandas.core.dtypes.common import ( | ||
|
@@ -23,9 +18,30 @@ | |
is_int_or_datetime_dtype, is_any_int_dtype) | ||
from pandas.core.dtypes.cast import _int64_max, maybe_upcast_putmask | ||
from pandas.core.dtypes.missing import isnull, notnull | ||
|
||
from pandas.core.config import get_option | ||
from pandas.core.common import _values_from_object | ||
|
||
try: | ||
import bottleneck as bn | ||
_BOTTLENECK_INSTALLED = True | ||
except ImportError: # pragma: no cover | ||
_BOTTLENECK_INSTALLED = False | ||
|
||
_USE_BOTTLENECK = False | ||
|
||
|
||
def set_use_bottleneck(v=True): | ||
# set/unset to use bottleneck | ||
global _USE_BOTTLENECK | ||
if _BOTTLENECK_INSTALLED: | ||
_USE_BOTTLENECK = v | ||
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. Should we warn here if |
||
elif v: | ||
warnings.warn("trying to set the option to use bottleneck, " | ||
"but it is not installed!") | ||
|
||
|
||
set_use_bottleneck(get_option('compute.use_bottleneck')) | ||
|
||
|
||
class disallow(object): | ||
|
||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
""" | ||
Internal module for console introspection | ||
""" | ||
|
||
import sys | ||
import locale | ||
from pandas.util.terminal import get_terminal_size | ||
|
||
# ----------------------------------------------------------------------------- | ||
# Global formatting options | ||
_initial_defencoding = None | ||
|
||
|
||
def detect_console_encoding(): | ||
""" | ||
Try to find the most capable encoding supported by the console. | ||
slighly modified from the way IPython handles the same issue. | ||
""" | ||
global _initial_defencoding | ||
|
||
encoding = None | ||
try: | ||
encoding = sys.stdout.encoding or sys.stdin.encoding | ||
except AttributeError: | ||
pass | ||
|
||
# try again for something better | ||
if not encoding or 'ascii' in encoding.lower(): | ||
try: | ||
encoding = locale.getpreferredencoding() | ||
except Exception: | ||
pass | ||
|
||
# when all else fails. this will usually be "ascii" | ||
if not encoding or 'ascii' in encoding.lower(): | ||
encoding = sys.getdefaultencoding() | ||
|
||
# GH3360, save the reported defencoding at import time | ||
# MPL backends may change it. Make available for debugging. | ||
if not _initial_defencoding: | ||
_initial_defencoding = sys.getdefaultencoding() | ||
|
||
return encoding | ||
|
||
|
||
def get_console_size(): | ||
"""Return console size as tuple = (width, height). | ||
|
||
Returns (None,None) in non-interactive session. | ||
""" | ||
from pandas import get_option | ||
from pandas.core import common as com | ||
|
||
display_width = get_option('display.width') | ||
# deprecated. | ||
display_height = get_option('display.height', silent=True) | ||
|
||
# Consider | ||
# interactive shell terminal, can detect term size | ||
# interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term | ||
# size non-interactive script, should disregard term size | ||
|
||
# in addition | ||
# width,height have default values, but setting to 'None' signals | ||
# should use Auto-Detection, But only in interactive shell-terminal. | ||
# Simple. yeah. | ||
|
||
if com.in_interactive_session(): | ||
if com.in_ipython_frontend(): | ||
# sane defaults for interactive non-shell terminal | ||
# match default for width,height in config_init | ||
from pandas.core.config import get_default_val | ||
terminal_width = get_default_val('display.width') | ||
terminal_height = get_default_val('display.height') | ||
else: | ||
# pure terminal | ||
terminal_width, terminal_height = get_terminal_size() | ||
else: | ||
terminal_width, terminal_height = None, None | ||
|
||
# Note if the User sets width/Height to None (auto-detection) | ||
# and we're in a script (non-inter), this will return (None,None) | ||
# caller needs to deal. | ||
return (display_width or terminal_width, display_height or terminal_height) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 know I suggested this, but, I think this one will be triggered by default if you don't have numexpr installed? (just by importing pandas, I mean, not only when setting the option manually when you don't have it installed)
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.
yep, just noticed that. going to take this out.