Skip to content

Commit 01b4667

Browse files
author
y-p
committed
ENH: update describe_option to report default and current value
1 parent 16f791b commit 01b4667

File tree

4 files changed

+11
-10
lines changed

4 files changed

+11
-10
lines changed

RELEASE.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ pandas 0.11.0
4747
preserve an all-nan object (e.g. strings)
4848
- Series print output now includes the dtype by default
4949
- Optimize internal reindexing routines for upcasting cases (#2819)
50+
- ``describe_option()`` now reports the default and current value of options.
5051

5152
**API Changes**
5253

pandas/core/config.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,11 @@ def _build_option_description(k):
554554

555555
o = _get_registered_option(k)
556556
d = _get_deprecated_option(k)
557+
557558
s = u'%s: ' % k
559+
if o:
560+
s += u'[default: %s] [currently: %s]' % (o.defval, _get_option(k, True))
561+
558562
if o.doc:
559563
s += '\n' + '\n '.join(o.doc.strip().split('\n'))
560564
else:

pandas/core/config_init.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
pc_colspace_doc = """
2828
: int
29-
Default space for DataFrame columns, defaults to 12
29+
Default space for DataFrame columns.
3030
"""
3131

3232
pc_max_rows_doc = """
@@ -53,7 +53,7 @@
5353

5454
pc_nb_repr_h_doc = """
5555
: boolean
56-
When True (default), IPython notebook will use html representation for
56+
When True, IPython notebook will use html representation for
5757
pandas objects (if it is available).
5858
"""
5959

@@ -69,13 +69,12 @@
6969

7070
pc_pprint_nest_depth = """
7171
: int
72-
Defaults to 3.
7372
Controls the number of nested levels to process when pretty-printing
7473
"""
7574

7675
pc_multi_sparse_doc = """
7776
: boolean
78-
Default True, "sparsify" MultiIndex display (don't display repeated
77+
"sparsify" MultiIndex display (don't display repeated
7978
elements in outer levels within groups)
8079
"""
8180

@@ -109,20 +108,17 @@
109108

110109
pc_expand_repr_doc = """
111110
: boolean
112-
Default False
113111
Whether to print out the full DataFrame repr for wide DataFrames
114112
across multiple lines.
115113
If False, the summary representation is shown.
116114
"""
117115

118116
pc_line_width_doc = """
119117
: int
120-
Default 80
121118
When printing wide DataFrames, this is the width of each line.
122119
"""
123120
pc_chop_threshold_doc = """
124121
: float or None
125-
Default None
126122
if set to a float value, all float values smaller then the given threshold
127123
will be displayed as exactly 0 by repr and friends.
128124
"""
@@ -156,7 +152,6 @@
156152

157153
tc_sim_interactive_doc = """
158154
: boolean
159-
Default False
160155
Whether to simulate interactive mode for purposes of testing
161156
"""
162157
with cf.config_prefix('mode'):

pandas/tests/test_config.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@ def test_describe_option(self):
7373
self.cf.register_option('c.d.e2', 1, 'doc4')
7474
self.cf.register_option('f', 1)
7575
self.cf.register_option('g.h', 1)
76-
self.cf.deprecate_option('g.h', rkey="blah")
76+
self.cf.register_option('k', 2)
77+
self.cf.deprecate_option('g.h', rkey="k")
7778

7879
# non-existent keys raise KeyError
7980
self.assertRaises(KeyError, self.cf.describe_option, 'no.such.key')
@@ -100,7 +101,7 @@ def test_describe_option(self):
100101
self.assertTrue(
101102
'precated' in self.cf.describe_option('g.h', _print_desc=False))
102103
self.assertTrue(
103-
'blah' in self.cf.describe_option('g.h', _print_desc=False))
104+
'k' in self.cf.describe_option('g.h', _print_desc=False))
104105

105106
def test_case_insensitive(self):
106107
self.cf.register_option('KanBAN', 1, 'doc')

0 commit comments

Comments
 (0)