Skip to content

Commit a743743

Browse files
Garrett-Rjreback
authored andcommitted
MAINT: minor refactoring and some documentation
MAINT: minor readability edits to conf.py DOC: fix typos in documentation
1 parent 7559522 commit a743743

File tree

8 files changed

+29
-36
lines changed

8 files changed

+29
-36
lines changed

doc/source/conf.py

+11-10
Original file line numberDiff line numberDiff line change
@@ -52,36 +52,37 @@
5252

5353

5454
with open("index.rst") as f:
55-
lines = f.readlines()
55+
index_rst_lines = f.readlines()
5656

5757
# only include the slow autosummary feature if we're building the API section
5858
# of the docs
5959

6060
# JP: added from sphinxdocs
6161
autosummary_generate = False
6262

63-
if any([re.match("\s*api\s*",l) for l in lines]):
63+
if any([re.match("\s*api\s*",l) for l in index_rst_lines]):
6464
autosummary_generate = True
6565

66-
ds = []
66+
files_to_delete = []
6767
for f in os.listdir(os.path.dirname(__file__)):
68-
if (not f.endswith(('.rst'))) or (f.startswith('.')) or os.path.basename(f) == 'index.rst':
68+
if not f.endswith('.rst') or f.startswith('.') or os.path.basename(f) == 'index.rst':
6969
continue
7070

71-
_f = f.split('.rst')[0]
72-
if not any([re.match("\s*%s\s*$" % _f,l) for l in lines]):
73-
ds.append(f)
71+
_file_basename = f.split('.rst')[0]
72+
_regex_to_match = "\s*{}\s*$".format(_file_basename)
73+
if not any([re.match(_regex_to_match, line) for line in index_rst_lines]):
74+
files_to_delete.append(f)
7475

75-
if ds:
76-
print("I'm about to DELETE the following:\n%s\n" % list(sorted(ds)))
76+
if files_to_delete:
77+
print("I'm about to DELETE the following:\n%s\n" % list(sorted(files_to_delete)))
7778
sys.stdout.write("WARNING: I'd like to delete those to speed up processing (yes/no)? ")
7879
if PY3:
7980
answer = input()
8081
else:
8182
answer = raw_input()
8283

8384
if answer.lower().strip() in ('y','yes'):
84-
for f in ds:
85+
for f in files_to_delete:
8586
f = os.path.join(os.path.join(os.path.dirname(__file__),f))
8687
f= os.path.abspath(f)
8788
try:

doc/source/internals.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ containers for the axis labels:
3535
- ``TimedeltaIndex``: An Index object with ``Timedelta`` boxed elements (impl are the in64 values)
3636
- ``PeriodIndex``: An Index object with Period elements
3737

38-
These are range generates to make the creation of a regular index easy:
38+
There are functions that make the creation of a regular index easy:
3939

4040
- ``date_range``: fixed frequency date range generated from a time rule or
4141
DateOffset. An ndarray of Python datetime objects
@@ -193,7 +193,7 @@ Below example shows how to define ``SubclassedSeries`` and ``SubclassedDataFrame
193193
Define Original Properties
194194
~~~~~~~~~~~~~~~~~~~~~~~~~~
195195

196-
To let original data structures have additional properties, you should let ``pandas`` knows what properties are added. ``pandas`` maps unknown properties to data names overriding ``__getattribute__``. Defining original properties can be done in one of 2 ways:
196+
To let original data structures have additional properties, you should let ``pandas`` know what properties are added. ``pandas`` maps unknown properties to data names overriding ``__getattribute__``. Defining original properties can be done in one of 2 ways:
197197

198198
1. Define ``_internal_names`` and ``_internal_names_set`` for temporary properties which WILL NOT be passed to manipulation results.
199199
2. Define ``_metadata`` for normal properties which will be passed to manipulation results.

pandas/core/common.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ def __init__(self, class_instance):
4747
self.class_instance = class_instance
4848

4949
def __str__(self):
50-
return "This method must be defined on the concrete class of " \
50+
return "This method must be defined in the concrete class of " \
5151
+ self.class_instance.__class__.__name__
5252

5353
_POSSIBLY_CAST_DTYPES = set([np.dtype(t).name

pandas/core/frame.py

+2-13
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,6 @@ class DataFrame(NDFrame):
184184
DataFrame.from_items : from sequence of (key, value) pairs
185185
pandas.read_csv, pandas.read_table, pandas.read_clipboard
186186
"""
187-
_auto_consolidate = True
188187

189188
@property
190189
def _constructor(self):
@@ -2171,28 +2170,18 @@ def _ensure_valid_index(self, value):
21712170
ensure that if we don't have an index, that we can create one from the
21722171
passed value
21732172
"""
2174-
if not len(self.index):
2175-
2176-
# GH5632, make sure that we are a Series convertible
2177-
if is_list_like(value):
2173+
# GH5632, make sure that we are a Series convertible
2174+
if not len(self.index) and is_list_like(value):
21782175
try:
21792176
value = Series(value)
21802177
except:
2181-
pass
2182-
2183-
if not isinstance(value, Series):
21842178
raise ValueError('Cannot set a frame with no defined index '
21852179
'and a value that cannot be converted to a '
21862180
'Series')
21872181

21882182
self._data = self._data.reindex_axis(value.index.copy(), axis=1,
21892183
fill_value=np.nan)
21902184

2191-
# we are a scalar
2192-
# noop
2193-
else:
2194-
2195-
pass
21962185

21972186
def _set_item(self, key, value):
21982187
"""

pandas/core/generic.py

+9
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ def _init_mgr(self, mgr, axes=None, dtype=None, copy=False):
138138

139139
@property
140140
def _constructor(self):
141+
"""Used when a manipulation result has the same dimesions as the
142+
original.
143+
"""
141144
raise AbstractMethodError(self)
142145

143146
def __unicode__(self):
@@ -153,10 +156,16 @@ def _dir_additions(self):
153156

154157
@property
155158
def _constructor_sliced(self):
159+
"""Used when a manipulation result has one lower dimension(s) as the
160+
original, such as DataFrame single columns slicing.
161+
"""
156162
raise AbstractMethodError(self)
157163

158164
@property
159165
def _constructor_expanddim(self):
166+
"""Used when a manipulation result has one higher dimension as the
167+
original, such as Series.to_frame() and DataFrame.to_panel()
168+
"""
160169
raise NotImplementedError
161170

162171
#----------------------------------------------------------------------

pandas/core/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -431,8 +431,8 @@ def can_do_equal_len():
431431

432432
return False
433433

434-
# we need an interable, with a ndim of at least 1
435-
# eg. don't pass thru np.array(0)
434+
# we need an iterable, with a ndim of at least 1
435+
# eg. don't pass through np.array(0)
436436
if is_list_like_indexer(value) and getattr(value,'ndim',1) > 0:
437437

438438
# we have an equal len Frame

pandas/core/internals.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -2121,7 +2121,7 @@ def make_block(values, placement, klass=None, ndim=None,
21212121
class BlockManager(PandasObject):
21222122

21232123
"""
2124-
Core internal data structure to implement DataFrame
2124+
Core internal data structure to implement DataFrame, Series, Panel, etc.
21252125
21262126
Manage a bunch of labeled 2D mixed-type ndarrays. Essentially it's a
21272127
lightweight blocked set of labeled data to be manipulated by the DataFrame

pandas/src/generate_code.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -2613,13 +2613,7 @@ def generate_take_cython_file():
26132613
print(generate_put_selection_template(template, use_ints=True,
26142614
use_datelikes=True,
26152615
use_objects=True),
2616-
file=f)
2617-
2618-
# for template in templates_1d_datetime:
2619-
# print >> f, generate_from_template_datetime(template)
2620-
2621-
# for template in templates_2d_datetime:
2622-
# print >> f, generate_from_template_datetime(template, ndim=2)
2616+
file=f)
26232617

26242618
for template in nobool_1d_templates:
26252619
print(generate_from_template(template, exclude=['bool']), file=f)

0 commit comments

Comments
 (0)