DEPR: allow options for using bottleneck/numexpr (#16157) · pandas-dev/pandas@075eca1 (original) (raw)

`@@ -8,7 +8,6 @@

`

8

8

`from distutils.version import LooseVersion

`

9

9

`# pylint: disable=W0141

`

10

10

``

11

``

`-

import sys

`

12

11

`from textwrap import dedent

`

13

12

``

14

13

`from pandas.core.dtypes.missing import isnull, notnull

`

`@@ -2290,82 +2289,6 @@ def _has_names(index):

`

2290

2289

`return index.name is not None

`

2291

2290

``

2292

2291

``

2293

``

`-

-----------------------------------------------------------------------------

`

2294

``

`-

Global formatting options

`

2295

``

`-

_initial_defencoding = None

`

2296

``

-

2297

``

-

2298

``

`-

def detect_console_encoding():

`

2299

``

`-

"""

`

2300

``

`-

Try to find the most capable encoding supported by the console.

`

2301

``

`-

slighly modified from the way IPython handles the same issue.

`

2302

``

`-

"""

`

2303

``

`-

import locale

`

2304

``

`-

global _initial_defencoding

`

2305

``

-

2306

``

`-

encoding = None

`

2307

``

`-

try:

`

2308

``

`-

encoding = sys.stdout.encoding or sys.stdin.encoding

`

2309

``

`-

except AttributeError:

`

2310

``

`-

pass

`

2311

``

-

2312

``

`-

try again for something better

`

2313

``

`-

if not encoding or 'ascii' in encoding.lower():

`

2314

``

`-

try:

`

2315

``

`-

encoding = locale.getpreferredencoding()

`

2316

``

`-

except Exception:

`

2317

``

`-

pass

`

2318

``

-

2319

``

`-

when all else fails. this will usually be "ascii"

`

2320

``

`-

if not encoding or 'ascii' in encoding.lower():

`

2321

``

`-

encoding = sys.getdefaultencoding()

`

2322

``

-

2323

``

`-

GH3360, save the reported defencoding at import time

`

2324

``

`-

MPL backends may change it. Make available for debugging.

`

2325

``

`-

if not _initial_defencoding:

`

2326

``

`-

_initial_defencoding = sys.getdefaultencoding()

`

2327

``

-

2328

``

`-

return encoding

`

2329

``

-

2330

``

-

2331

``

`-

def get_console_size():

`

2332

``

`-

"""Return console size as tuple = (width, height).

`

2333

``

-

2334

``

`-

Returns (None,None) in non-interactive session.

`

2335

``

`-

"""

`

2336

``

`-

display_width = get_option('display.width')

`

2337

``

`-

deprecated.

`

2338

``

`-

display_height = get_option('display.height', silent=True)

`

2339

``

-

2340

``

`-

Consider

`

2341

``

`-

interactive shell terminal, can detect term size

`

2342

``

`-

interactive non-shell terminal (ipnb/ipqtconsole), cannot detect term

`

2343

``

`-

size non-interactive script, should disregard term size

`

2344

``

-

2345

``

`-

in addition

`

2346

``

`-

width,height have default values, but setting to 'None' signals

`

2347

``

`-

should use Auto-Detection, But only in interactive shell-terminal.

`

2348

``

`-

Simple. yeah.

`

2349

``

-

2350

``

`-

if com.in_interactive_session():

`

2351

``

`-

if com.in_ipython_frontend():

`

2352

``

`-

sane defaults for interactive non-shell terminal

`

2353

``

`-

match default for width,height in config_init

`

2354

``

`-

from pandas.core.config import get_default_val

`

2355

``

`-

terminal_width = get_default_val('display.width')

`

2356

``

`-

terminal_height = get_default_val('display.height')

`

2357

``

`-

else:

`

2358

``

`-

pure terminal

`

2359

``

`-

terminal_width, terminal_height = get_terminal_size()

`

2360

``

`-

else:

`

2361

``

`-

terminal_width, terminal_height = None, None

`

2362

``

-

2363

``

`-

Note if the User sets width/Height to None (auto-detection)

`

2364

``

`-

and we're in a script (non-inter), this will return (None,None)

`

2365

``

`-

caller needs to deal.

`

2366

``

`-

return (display_width or terminal_width, display_height or terminal_height)

`

2367

``

-

2368

``

-

2369

2292

`class EngFormatter(object):

`

2370

2293

`"""

`

2371

2294

` Formats float values according to engineering format.

`