Skip to content

Commit bd16952

Browse files
committed
NotImplementedError messages updated
1 parent a6ba456 commit bd16952

26 files changed

+86
-85
lines changed

pandas/core/base.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class StringMixin(object):
1919
# Formatting
2020

2121
def __unicode__(self):
22-
raise NotImplementedError
22+
raise NotImplementedError("StringMixin __unicode__ format")
2323

2424
def __str__(self):
2525
"""
@@ -382,7 +382,7 @@ def _box_func(self):
382382
"""
383383
box function to get object from internal representation
384384
"""
385-
raise NotImplementedError
385+
raise NotImplementedError("Box function to get object from internal representation")
386386

387387
def _box_values(self, values):
388388
"""

pandas/core/generic.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ def _init_mgr(self, mgr, axes=None, dtype=None, copy=False):
135135

136136
@property
137137
def _constructor(self):
138-
raise NotImplementedError
138+
raise NotImplementedError("NDFrame _constructor")
139139

140140
def __unicode__(self):
141141
# unicode representation based upon iterating over self
@@ -150,7 +150,7 @@ def _local_dir(self):
150150

151151
@property
152152
def _constructor_sliced(self):
153-
raise NotImplementedError
153+
raise NotImplementedError("NDFrame _constructor_sliced")
154154

155155
#----------------------------------------------------------------------
156156
# Axis
@@ -1073,7 +1073,7 @@ def _iget_item_cache(self, item):
10731073
return lower
10741074

10751075
def _box_item_values(self, key, values):
1076-
raise NotImplementedError
1076+
raise NotImplementedError("NDFrame _box_item_values")
10771077

10781078
def _maybe_cache_changed(self, item, value):
10791079
"""
@@ -1653,7 +1653,7 @@ def _needs_reindex_multi(self, axes, method, level):
16531653
method is None and level is None and not self._is_mixed_type)
16541654

16551655
def _reindex_multi(self, axes, copy, fill_value):
1656-
return NotImplemented
1656+
raise NotImplementedError("NDFrame _reindex_multi")
16571657

16581658
_shared_docs['reindex_axis'] = (
16591659
"""Conform input object to new index with optional filling logic,
@@ -2179,7 +2179,7 @@ def fillna(self, value=None, method=None, axis=0, inplace=False,
21792179
raise ValueError('must specify a fill method or value')
21802180
if self._is_mixed_type and axis == 1:
21812181
if inplace:
2182-
raise NotImplementedError()
2182+
raise NotImplementedError("fillna with inplace=True and _is_mixed_type=True and axis=1")
21832183
result = self.T.fillna(method=method, limit=limit).T
21842184

21852185
# need to downcast here because of all of the transposes
@@ -2880,7 +2880,7 @@ def first(self, offset):
28802880
"""
28812881
from pandas.tseries.frequencies import to_offset
28822882
if not isinstance(self.index, DatetimeIndex):
2883-
raise NotImplementedError
2883+
raise NotImplementedError("Currently implemented for DatatimeIndex instance only")
28842884

28852885
if len(self.index) == 0:
28862886
return self
@@ -2914,7 +2914,7 @@ def last(self, offset):
29142914
"""
29152915
from pandas.tseries.frequencies import to_offset
29162916
if not isinstance(self.index, DatetimeIndex):
2917-
raise NotImplementedError
2917+
raise NotImplementedError("Currently implemented for DatatimeIndex instance only")
29182918

29192919
if len(self.index) == 0:
29202920
return self

pandas/core/groupby.py

+14-14
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ def _set_grouper(self, obj, sort=False):
283283
return self.grouper
284284

285285
def _get_binner_for_grouping(self, obj):
286-
raise NotImplementedError
286+
raise NotImplementedError("Binner for grouping")
287287

288288
@property
289289
def groups(self):
@@ -644,7 +644,7 @@ def _python_apply_general(self, f):
644644
not_indexed_same=mutated)
645645

646646
def aggregate(self, func, *args, **kwargs):
647-
raise NotImplementedError
647+
raise NotImplementedError("Groupby aggregrate")
648648

649649
@Appender(_agg_doc)
650650
def agg(self, func, *args, **kwargs):
@@ -654,7 +654,7 @@ def _iterate_slices(self):
654654
yield self.name, self._selected_obj
655655

656656
def transform(self, func, *args, **kwargs):
657-
raise NotImplementedError
657+
raise NotImplementedError("Groupby transform")
658658

659659
def mean(self):
660660
"""
@@ -1041,7 +1041,7 @@ def _python_agg_general(self, func, *args, **kwargs):
10411041
return self._wrap_aggregated_output(output)
10421042

10431043
def _wrap_applied_output(self, *args, **kwargs):
1044-
raise NotImplementedError
1044+
raise NotImplementedError("Groupby wrap applied output")
10451045

10461046
def _concat_objects(self, keys, values, not_indexed_same=False):
10471047
from pandas.tools.merge import concat
@@ -1404,7 +1404,7 @@ def aggregate(self, values, how, axis=0):
14041404
swapped = True
14051405
values = values.swapaxes(0, axis)
14061406
if arity > 1:
1407-
raise NotImplementedError
1407+
raise NotImplementedError("BaseGrouper aggregate for arity > 1")
14081408
out_shape = (self.ngroups,) + values.shape[1:]
14091409

14101410
if is_numeric_dtype(values.dtype):
@@ -1459,7 +1459,7 @@ def _aggregate(self, result, counts, values, how, is_numeric):
14591459
comp_ids, _, ngroups = self.group_info
14601460
if values.ndim > 3:
14611461
# punting for now
1462-
raise NotImplementedError
1462+
raise NotImplementedError("BaseGrouper aggregrate for > 3 dimensions")
14631463
elif values.ndim > 2:
14641464
for i, chunk in enumerate(values.transpose(2, 0, 1)):
14651465

@@ -1695,7 +1695,7 @@ def _aggregate(self, result, counts, values, how, is_numeric=True):
16951695

16961696
if values.ndim > 3:
16971697
# punting for now
1698-
raise NotImplementedError
1698+
raise NotImplementedError("BinGrouper aggregate for > 3 dimensions")
16991699
elif values.ndim > 2:
17001700
for i, chunk in enumerate(values.transpose(2, 0, 1)):
17011701
agg_func(result[:, :, i], counts, chunk, self.bins)
@@ -2399,7 +2399,7 @@ def aggregate(self, arg, *args, **kwargs):
23992399
if self._selection is not None:
24002400
subset = obj
24012401
if isinstance(subset, DataFrame):
2402-
raise NotImplementedError
2402+
raise NotImplementedError("aggregate not implemented for subset being a Dataframe")
24032403

24042404
for fname, agg_how in compat.iteritems(arg):
24052405
colg = SeriesGroupBy(subset, selection=self._selection,
@@ -2459,7 +2459,7 @@ def _aggregate_multiple_funcs(self, arg):
24592459
from pandas.tools.merge import concat
24602460

24612461
if self.axis != 0:
2462-
raise NotImplementedError
2462+
raise NotImplementedError("Currently implemented for axis = 0")
24632463

24642464
obj = self._obj_with_exclusions
24652465

@@ -2509,7 +2509,7 @@ def _aggregate_generic(self, func, *args, **kwargs):
25092509
return self._wrap_generic_output(result, obj)
25102510

25112511
def _wrap_aggregated_output(self, output, names=None):
2512-
raise NotImplementedError
2512+
raise NotImplementedError("NDFrameGroupBy wrap aggregated output")
25132513

25142514
def _aggregate_item_by_item(self, func, *args, **kwargs):
25152515
# only for axis==0
@@ -3050,7 +3050,7 @@ def _iterate_slices(self):
30503050
slice_axis = self._selection_list
30513051
slicer = lambda x: self._selected_obj[x]
30523052
else:
3053-
raise NotImplementedError
3053+
raise NotImplementedError("Currently implemented for axis = 0")
30543054

30553055
for val in slice_axis:
30563056
if val in self.exclusions:
@@ -3115,10 +3115,10 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
31153115
new_axes[self.axis] = self.grouper.result_index
31163116
return Panel._from_axes(result, new_axes)
31173117
else:
3118-
raise NotImplementedError
3118+
raise NotImplementedError("Currently implemented for axis>0")
31193119

31203120
def _wrap_aggregated_output(self, output, names=None):
3121-
raise NotImplementedError
3121+
raise NotImplementedError("PanelGroupBy _wrap_aggregated_output")
31223122

31233123

31243124
class NDArrayGroupBy(GroupBy):
@@ -3172,7 +3172,7 @@ def _chop(self, sdata, slice_obj):
31723172
return sdata.iloc[slice_obj]
31733173

31743174
def apply(self, f):
3175-
raise NotImplementedError
3175+
raise NotImplementedError("DataSplitter apply function")
31763176

31773177

31783178
class ArraySplitter(DataSplitter):

pandas/core/indexing.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ def __setitem__(self, key, value):
120120
self._setitem_with_indexer(indexer, value)
121121

122122
def _has_valid_type(self, k, axis):
123-
raise NotImplementedError()
123+
raise NotImplementedError("Valid type checking for _NDFrameIndexer is not implemented")
124124

125125
def _has_valid_tuple(self, key):
126126
""" check the key for valid keys across my indexer """
@@ -1141,7 +1141,7 @@ def __getitem__(self, key):
11411141
return self._getitem_axis(key, axis=0)
11421142

11431143
def _getitem_axis(self, key, axis=0, validate_iterable=False):
1144-
raise NotImplementedError()
1144+
raise NotImplementedError("Get item along given axis in _LocationIndexer is not implemented")
11451145

11461146
def _getbool_axis(self, key, axis=0):
11471147
labels = self.obj._get_axis(axis)

pandas/core/internals.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ def fillna(self, value, limit=None, inplace=False, downcast=None):
243243
mask = isnull(self.values)
244244
if limit is not None:
245245
if self.ndim > 2:
246-
raise NotImplementedError
246+
raise NotImplementedError("fillna function not implemented for more than 2 dimensions")
247247
mask[mask.cumsum(self.ndim-1)>limit]=False
248248

249249
value = self._try_fill(value)
@@ -363,10 +363,10 @@ def convert(self, copy=True, **kwargs):
363363
return [self.copy()] if copy else [self]
364364

365365
def _can_hold_element(self, value):
366-
raise NotImplementedError()
366+
raise NotImplementedError("Block _can_hold_element function")
367367

368368
def _try_cast(self, value):
369-
raise NotImplementedError()
369+
raise NotImplementedError("Block _try_cast")
370370

371371
def _try_cast_result(self, result, dtype=None):
372372
""" try to cast the result to our original type,
@@ -1519,7 +1519,7 @@ def fillna(self, value, limit=None,
15191519
value = self._try_fill(value)
15201520
if limit is not None:
15211521
if self.ndim > 2:
1522-
raise NotImplementedError
1522+
raise NotImplementedError("fillna function not implemented for more than 2 dimensions")
15231523
mask[mask.cumsum(self.ndim-1)>limit]=False
15241524

15251525
np.putmask(values, mask, value)
@@ -1741,7 +1741,7 @@ def interpolate(self, method='pad', axis=0, inplace=False,
17411741
def fillna(self, value, limit=None, inplace=False, downcast=None):
17421742
# we may need to upcast our fill to match our dtype
17431743
if limit is not None:
1744-
raise NotImplementedError
1744+
raise NotImplementedError("fillna currently implemented only for limit=None")
17451745
if issubclass(self.dtype.type, np.floating):
17461746
value = float(value)
17471747
values = self.values if inplace else self.values.copy()

pandas/core/panel.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,10 @@ def conform(self, frame, axis='items'):
595595
return frame.reindex(**self._extract_axes_for_slice(self, axes))
596596

597597
def head(self, n=5):
598-
raise NotImplementedError
598+
raise NotImplementedError("Returns the head content of a Panel")
599599

600600
def tail(self, n=5):
601-
raise NotImplementedError
601+
raise NotImplementedError("Returns the tail content of a Panel")
602602

603603
def _needs_reindex_multi(self, axes, method, level):
604604
""" don't allow a multi reindex on Panel or above ndim """

pandas/core/panelnd.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def _combine_with_constructor(self, other, func):
9999
for f in ['to_frame', 'to_excel', 'to_sparse', 'groupby', 'join', 'filter',
100100
'dropna', 'shift']:
101101
def func(self, *args, **kwargs):
102-
raise NotImplementedError
102+
raise NotImplementedError("%s is not implemented" % f)
103103
setattr(klass, f, func)
104104

105105
# add the aggregate operations

pandas/core/series.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ def __init__(self, data=None, index=None, dtype=None, name=None,
156156
dtype = self._validate_dtype(dtype)
157157

158158
if isinstance(data, MultiIndex):
159-
raise NotImplementedError
159+
raise NotImplementedError("Series initialization currently is not implemented for MultiIndex")
160160
elif isinstance(data, Index):
161161
# need to copy to avoid aliasing issues
162162
if name is None:

pandas/core/strings.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ def str_slice_replace(arr, start=None, stop=None, repl=None):
680680
-------
681681
replaced : array
682682
"""
683-
raise NotImplementedError
683+
raise NotImplementedError("String slice replace not implemented")
684684

685685

686686
def str_strip(arr, to_strip=None):
@@ -985,7 +985,7 @@ def slice(self, start=None, stop=None, step=1):
985985

986986
@copy(str_slice)
987987
def slice_replace(self, i=None, j=None):
988-
raise NotImplementedError
988+
raise NotImplementedError("String slice replace is not implemented.")
989989

990990
@copy(str_decode)
991991
def decode(self, encoding, errors="strict"):

pandas/index.pyx

+2-2
Original file line numberDiff line numberDiff line change
@@ -234,10 +234,10 @@ cdef class IndexEngine:
234234
self._ensure_mapping_populated()
235235

236236
def _call_monotonic(self, values):
237-
raise NotImplementedError
237+
raise NotImplementedError("IndexEngine _call_monotonic is not implemented")
238238

239239
cdef _make_hash_table(self, n):
240-
raise NotImplementedError
240+
raise NotImplementedError("IndexEngine _make_hash_table is not implemented")
241241

242242
cdef _check_type(self, object val):
243243
hash(val)

pandas/io/ga.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ def get_profile(self, account_id=None, web_property_id=None, name=None,
240240
return _get_match(profiles, name, id, **kwargs)
241241

242242
def create_query(self, *args, **kwargs):
243-
raise NotImplementedError()
243+
raise NotImplementedError("Create query in GDataReader is not implemented")
244244

245245
@Substitution(extras='')
246246
@Appender(_GA_READER_DOC)

0 commit comments

Comments
 (0)