Skip to content

Commit 2f67650

Browse files
author
y-p
committed
CLN: rename "print_config.X" to "print.X"
1 parent 6cf2a7e commit 2f67650

File tree

10 files changed

+49
-51
lines changed

10 files changed

+49
-51
lines changed

doc/source/v0.10.0.txt

+2-2
Original file line numberDiff line numberDiff line change
@@ -122,13 +122,13 @@ API changes
122122
- ``reset_option`` - reset one or more options to their default value. Partial names are accepted.
123123
- ``describe_option`` - print a description of one or more options. When called with no arguments. print all registered options.
124124

125-
Note: ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but functioning), the print options now live under "print_config.XYZ". For example:
125+
Note: ``set_printoptions``/ ``reset_printoptions`` are now deprecated (but functioning), the print options now live under "print.XYZ". For example:
126126

127127

128128
.. ipython:: python
129129

130130
import pandas as pd
131-
pd.get_option("print_config.max_rows")
131+
pd.get_option("print.max_rows")
132132

133133

134134
- to_string() methods now always return unicode strings (GH2224_).

pandas/core/common.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1128,7 +1128,7 @@ def in_qtconsole():
11281128
# 2) If you need to send something to the console, use console_encode().
11291129
#
11301130
# console_encode() should (hopefully) choose the right encoding for you
1131-
# based on the encoding set in option "print_config.encoding"
1131+
# based on the encoding set in option "print.encoding"
11321132
#
11331133
# 3) if you need to write something out to file, use
11341134
# pprint_thing_encoded(encoding).
@@ -1187,10 +1187,10 @@ def pprint_thing(thing, _nest_lvl=0):
11871187
hasattr(thing,'next'):
11881188
return unicode(thing)
11891189
elif (isinstance(thing, dict) and
1190-
_nest_lvl < get_option("print_config.pprint_nest_depth")):
1190+
_nest_lvl < get_option("print.pprint_nest_depth")):
11911191
result = _pprint_dict(thing, _nest_lvl)
11921192
elif _is_sequence(thing) and _nest_lvl < \
1193-
get_option("print_config.pprint_nest_depth"):
1193+
get_option("print.pprint_nest_depth"):
11941194
result = _pprint_seq(thing, _nest_lvl)
11951195
else:
11961196
# when used internally in the package, everything
@@ -1222,8 +1222,8 @@ def console_encode(object):
12221222
this is the sanctioned way to prepare something for
12231223
sending *to the console*, it delegates to pprint_thing() to get
12241224
a unicode representation of the object relies on the global encoding
1225-
set in print_config.encoding. Use this everywhere
1225+
set in print.encoding. Use this everywhere
12261226
where you output to the console.
12271227
"""
12281228
return pprint_thing_encoded(object,
1229-
get_option("print_config.encoding"))
1229+
get_option("print.encoding"))

pandas/core/config.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ def __doc__(self):
201201
full option name (e.g. x.y.z.option_name), your code may break in future
202202
versions if new options with similar names are introduced.
203203
204-
value - new value of function.
204+
value - new value of option.
205205
206206
Returns
207207
-------

pandas/core/config_init.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
from __future__ import with_statement # support python 2.5
2-
31
import pandas.core.config as cf
42
from pandas.core.config import is_int,is_bool,is_text,is_float
53
from pandas.core.format import detect_console_encoding
@@ -18,7 +16,7 @@
1816

1917

2018
###########################################
21-
# options from the "print_config" namespace
19+
# options from the "print" namespace
2220

2321
pc_precision_doc="""
2422
: int
@@ -79,7 +77,7 @@
7977
these are generally strings meant to be displayed on the console.
8078
"""
8179

82-
with cf.config_prefix('print_config'):
80+
with cf.config_prefix('print'):
8381
cf.register_option('precision', 7, pc_precision_doc, validator=is_int)
8482
cf.register_option('digits', 7, validator=is_int)
8583
cf.register_option('float_format', None)

pandas/core/format.py

+26-26
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def __init__(self, series, buf=None, header=True, length=True,
7373
self.header = header
7474

7575
if float_format is None:
76-
float_format = get_option("print_config.float_format")
76+
float_format = get_option("print.float_format")
7777
self.float_format = float_format
7878

7979
def _get_footer(self):
@@ -148,7 +148,7 @@ def _encode_diff_func():
148148
if py3compat.PY3: # pragma: no cover
149149
_encode_diff = lambda x: 0
150150
else:
151-
encoding = get_option("print_config.encoding")
151+
encoding = get_option("print.encoding")
152152
def _encode_diff(x):
153153
return len(x) - len(x.decode(encoding))
154154

@@ -159,7 +159,7 @@ def _strlen_func():
159159
if py3compat.PY3: # pragma: no cover
160160
_strlen = len
161161
else:
162-
encoding = get_option("print_config.encoding")
162+
encoding = get_option("print.encoding")
163163
def _strlen(x):
164164
try:
165165
return len(x.decode(encoding))
@@ -191,7 +191,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
191191
self.show_index_names = index_names
192192

193193
if sparsify is None:
194-
sparsify = get_option("print_config.multi_sparse")
194+
sparsify = get_option("print.multi_sparse")
195195

196196
self.sparsify = sparsify
197197

@@ -203,7 +203,7 @@ def __init__(self, frame, buf=None, columns=None, col_space=None,
203203
self.index = index
204204

205205
if justify is None:
206-
self.justify = get_option("print_config.colheader_justify")
206+
self.justify = get_option("print.colheader_justify")
207207
else:
208208
self.justify = justify
209209

@@ -930,13 +930,13 @@ def format_array(values, formatter, float_format=None, na_rep='NaN',
930930
fmt_klass = GenericArrayFormatter
931931

932932
if space is None:
933-
space = get_option("print_config.column_space")
933+
space = get_option("print.column_space")
934934

935935
if float_format is None:
936-
float_format = get_option("print_config.float_format")
936+
float_format = get_option("print.float_format")
937937

938938
if digits is None:
939-
digits = get_option("print_config.precision")
939+
digits = get_option("print.precision")
940940

941941
fmt_obj = fmt_klass(values, digits, na_rep=na_rep,
942942
float_format=float_format,
@@ -964,9 +964,9 @@ def get_result(self):
964964

965965
def _format_strings(self):
966966
if self.float_format is None:
967-
float_format = get_option("print_config.float_format")
967+
float_format = get_option("print.float_format")
968968
if float_format is None:
969-
fmt_str = '%% .%dg' % get_option("print_config.precision")
969+
fmt_str = '%% .%dg' % get_option("print.precision")
970970
float_format = lambda x: fmt_str % x
971971
else:
972972
float_format = self.float_format
@@ -1091,7 +1091,7 @@ def _make_fixed_width(strings, justify='right', minimum=None):
10911091
if minimum is not None:
10921092
max_len = max(minimum, max_len)
10931093

1094-
conf_max = get_option("print_config.max_colwidth")
1094+
conf_max = get_option("print.max_colwidth")
10951095
if conf_max is not None and max_len > conf_max:
10961096
max_len = conf_max
10971097

@@ -1205,35 +1205,35 @@ def set_printoptions(precision=None, column_space=None, max_rows=None,
12051205
warnings.warn("set_printoptions is deprecated, use set_option instead",
12061206
FutureWarning)
12071207
if precision is not None:
1208-
set_option("print_config.precision", precision)
1208+
set_option("print.precision", precision)
12091209
if column_space is not None:
1210-
set_option("print_config.column_space", column_space)
1210+
set_option("print.column_space", column_space)
12111211
if max_rows is not None:
1212-
set_option("print_config.max_rows", max_rows)
1212+
set_option("print.max_rows", max_rows)
12131213
if max_colwidth is not None:
1214-
set_option("print_config.max_colwidth", max_colwidth)
1214+
set_option("print.max_colwidth", max_colwidth)
12151215
if max_columns is not None:
1216-
set_option("print_config.max_columns", max_columns)
1216+
set_option("print.max_columns", max_columns)
12171217
if colheader_justify is not None:
1218-
set_option("print_config.colheader_justify", colheader_justify)
1218+
set_option("print.colheader_justify", colheader_justify)
12191219
if notebook_repr_html is not None:
1220-
set_option("print_config.notebook_repr_html", notebook_repr_html)
1220+
set_option("print.notebook_repr_html", notebook_repr_html)
12211221
if date_dayfirst is not None:
1222-
set_option("print_config.date_dayfirst", date_dayfirst)
1222+
set_option("print.date_dayfirst", date_dayfirst)
12231223
if date_yearfirst is not None:
1224-
set_option("print_config.date_yearfirst", date_yearfirst)
1224+
set_option("print.date_yearfirst", date_yearfirst)
12251225
if pprint_nest_depth is not None:
1226-
set_option("print_config.pprint_nest_depth", pprint_nest_depth)
1226+
set_option("print.pprint_nest_depth", pprint_nest_depth)
12271227
if multi_sparse is not None:
1228-
set_option("print_config.multi_sparse", multi_sparse)
1228+
set_option("print.multi_sparse", multi_sparse)
12291229
if encoding is not None:
1230-
set_option("print_config.encoding", encoding)
1230+
set_option("print.encoding", encoding)
12311231

12321232
def reset_printoptions():
12331233
import warnings
12341234
warnings.warn("reset_printoptions is deprecated, use reset_option instead",
12351235
FutureWarning)
1236-
reset_option("^print_config\.")
1236+
reset_option("^print\.")
12371237

12381238
def detect_console_encoding():
12391239
"""
@@ -1365,8 +1365,8 @@ def set_eng_float_format(precision=None, accuracy=3, use_eng_prefix=False):
13651365
"being renamed to 'accuracy'", FutureWarning)
13661366
accuracy = precision
13671367

1368-
set_option("print_config.float_format", EngFormatter(accuracy, use_eng_prefix))
1369-
set_option("print_config.column_space", max(12, accuracy + 9))
1368+
set_option("print.float_format", EngFormatter(accuracy, use_eng_prefix))
1369+
set_option("print.column_space", max(12, accuracy + 9))
13701370

13711371
def _put_lines(buf, lines):
13721372
if any(isinstance(x, unicode) for x in lines):

pandas/core/frame.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -589,9 +589,9 @@ def _need_info_repr_(self):
589589
terminal_width, terminal_height = 100, 100
590590
else:
591591
terminal_width, terminal_height = get_terminal_size()
592-
max_rows = (terminal_height if get_option("print_config.max_rows") == 0
593-
else get_option("print_config.max_rows"))
594-
max_columns = get_option("print_config.max_columns")
592+
max_rows = (terminal_height if get_option("print.max_rows") == 0
593+
else get_option("print.max_rows"))
594+
max_columns = get_option("print.max_columns")
595595

596596
if max_columns > 0:
597597
if len(self.index) <= max_rows and \
@@ -669,7 +669,7 @@ def _repr_html_(self):
669669
if com.in_qtconsole():
670670
raise ValueError('Disable HTML output in QtConsole')
671671

672-
if get_option("print_config.notebook_repr_html"):
672+
if get_option("print.notebook_repr_html"):
673673
if self._need_info_repr_():
674674
return None
675675
else:

pandas/core/index.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -1583,7 +1583,7 @@ def format(self, space=2, sparsify=None, adjoin=True, names=False,
15831583
result_levels.append(level)
15841584

15851585
if sparsify is None:
1586-
sparsify = get_option("print_config.multi_sparse")
1586+
sparsify = get_option("print.multi_sparse")
15871587

15881588
if sparsify:
15891589
# little bit of a kludge job for #1217

pandas/core/series.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -948,8 +948,8 @@ def __unicode__(self):
948948
Invoked by unicode(df) in py2 only. Yields a Unicode String in both py2/py3.
949949
"""
950950
width, height = get_terminal_size()
951-
max_rows = (height if get_option("print_config.max_rows") == 0
952-
else get_option("print_config.max_rows"))
951+
max_rows = (height if get_option("print.max_rows") == 0
952+
else get_option("print.max_rows"))
953953
if len(self.index) > (max_rows or 1000):
954954
result = self._tidy_repr(min(30, max_rows - 4))
955955
elif len(self.index) > 0:

pandas/tests/test_format.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def test_repr_tuples(self):
6565

6666
def test_repr_truncation(self):
6767
max_len = 20
68-
set_option("print_config.max_colwidth", max_len)
68+
set_option("print.max_colwidth", max_len)
6969
df = DataFrame({'A': np.random.randn(10),
7070
'B': [tm.rands(np.random.randint(max_len - 1,
7171
max_len + 1)) for i in range(10)]})
@@ -80,10 +80,10 @@ def test_repr_truncation(self):
8080
else:
8181
self.assert_('...' not in line)
8282

83-
set_option("print_config.max_colwidth", 999999)
83+
set_option("print.max_colwidth", 999999)
8484
self.assert_('...' not in repr(df))
8585

86-
set_option("print_config.max_colwidth", max_len + 2)
86+
set_option("print.max_colwidth", max_len + 2)
8787
self.assert_('...' not in repr(df))
8888

8989
def test_repr_should_return_str (self):
@@ -453,7 +453,7 @@ def test_to_string_float_formatting(self):
453453
assert(df_s == expected)
454454

455455
fmt.reset_printoptions()
456-
self.assertEqual(get_option("print_config.precision"), 7)
456+
self.assertEqual(get_option("print.precision"), 7)
457457

458458
df = DataFrame({'x': [1e9, 0.2512]})
459459
df_s = df.to_string()

pandas/tseries/tools.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -222,9 +222,9 @@ def parse_time_string(arg, freq=None, dayfirst=None, yearfirst=None):
222222
return mresult
223223

224224
if dayfirst is None:
225-
dayfirst = get_option("print_config.date_dayfirst")
225+
dayfirst = get_option("print.date_dayfirst")
226226
if yearfirst is None:
227-
yearfirst = get_option("print_config.date_yearfirst")
227+
yearfirst = get_option("print.date_yearfirst")
228228

229229
try:
230230
parsed = parse(arg, dayfirst=dayfirst, yearfirst=yearfirst)

0 commit comments

Comments
 (0)