Skip to content

Commit c738523

Browse files
jbrockmendeljreback
authored andcommitted
CLN: remove incorrect usages of com.AbstractMethodError (#23625)
1 parent b9ba708 commit c738523

File tree

14 files changed

+48
-44
lines changed

14 files changed

+48
-44
lines changed

pandas/core/generic.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import pandas as pd
1212

1313
from pandas._libs import properties, Timestamp, iNaT
14+
from pandas.errors import AbstractMethodError
15+
1416
from pandas.core.dtypes.common import (
1517
ensure_int64,
1618
ensure_object,
@@ -200,7 +202,7 @@ def _constructor(self):
200202
"""Used when a manipulation result has the same dimensions as the
201203
original.
202204
"""
203-
raise com.AbstractMethodError(self)
205+
raise AbstractMethodError(self)
204206

205207
def __unicode__(self):
206208
# unicode representation based upon iterating over self
@@ -221,7 +223,7 @@ def _constructor_sliced(self):
221223
"""Used when a manipulation result has one lower dimension(s) as the
222224
original, such as DataFrame single columns slicing.
223225
"""
224-
raise com.AbstractMethodError(self)
226+
raise AbstractMethodError(self)
225227

226228
@property
227229
def _constructor_expanddim(self):
@@ -2884,7 +2886,7 @@ def _iget_item_cache(self, item):
28842886
return lower
28852887

28862888
def _box_item_values(self, key, values):
2887-
raise com.AbstractMethodError(self)
2889+
raise AbstractMethodError(self)
28882890

28892891
def _maybe_cache_changed(self, item, value):
28902892
"""The object has called back to us saying maybe it has changed.

pandas/core/groupby/generic.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
import pandas.compat as compat
1919
from pandas.compat import lzip, map
2020
from pandas.compat.numpy import _np_version_under1p13
21+
from pandas.errors import AbstractMethodError
2122
from pandas.util._decorators import Appender, Substitution
2223

2324
from pandas.core.dtypes.cast import maybe_downcast_to_dtype
@@ -240,7 +241,7 @@ def _aggregate_generic(self, func, *args, **kwargs):
240241
return self._wrap_generic_output(result, obj)
241242

242243
def _wrap_aggregated_output(self, output, names=None):
243-
raise com.AbstractMethodError(self)
244+
raise AbstractMethodError(self)
244245

245246
def _aggregate_item_by_item(self, func, *args, **kwargs):
246247
# only for axis==0
@@ -1659,4 +1660,4 @@ def _aggregate_item_by_item(self, func, *args, **kwargs):
16591660
raise ValueError("axis value must be greater than 0")
16601661

16611662
def _wrap_aggregated_output(self, output, names=None):
1662-
raise com.AbstractMethodError(self)
1663+
raise AbstractMethodError(self)

pandas/core/groupby/groupby.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class providing the base-class of operations.
2020
import pandas.compat as compat
2121
from pandas.compat import callable, range, set_function_name, zip
2222
from pandas.compat.numpy import function as nv
23+
from pandas.errors import AbstractMethodError
2324
from pandas.util._decorators import Appender, Substitution, cache_readonly
2425
from pandas.util._validators import validate_kwargs
2526

@@ -706,7 +707,7 @@ def _iterate_slices(self):
706707
yield self._selection_name, self._selected_obj
707708

708709
def transform(self, func, *args, **kwargs):
709-
raise com.AbstractMethodError(self)
710+
raise AbstractMethodError(self)
710711

711712
def _cumcount_array(self, ascending=True):
712713
"""
@@ -861,7 +862,7 @@ def _python_agg_general(self, func, *args, **kwargs):
861862
return self._wrap_aggregated_output(output)
862863

863864
def _wrap_applied_output(self, *args, **kwargs):
864-
raise com.AbstractMethodError(self)
865+
raise AbstractMethodError(self)
865866

866867
def _concat_objects(self, keys, values, not_indexed_same=False):
867868
from pandas.core.reshape.concat import concat

pandas/core/groupby/ops.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
from pandas._libs import NaT, groupby as libgroupby, iNaT, lib, reduction
1515
from pandas.compat import lzip, range, zip
16+
from pandas.errors import AbstractMethodError
1617
from pandas.util._decorators import cache_readonly
1718

1819
from pandas.core.dtypes.common import (
@@ -841,7 +842,7 @@ def _chop(self, sdata, slice_obj):
841842
return sdata.iloc[slice_obj]
842843

843844
def apply(self, f):
844-
raise com.AbstractMethodError(self)
845+
raise AbstractMethodError(self)
845846

846847

847848
class SeriesSplitter(DataSplitter):

pandas/core/indexes/datetimelike.py

+3-2
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
from pandas._libs.tslibs.timestamps import RoundTo, round_nsint64
1111
import pandas.compat as compat
1212
from pandas.compat.numpy import function as nv
13+
from pandas.errors import AbstractMethodError
1314
from pandas.util._decorators import Appender, cache_readonly
1415

1516
from pandas.core.dtypes.common import (
@@ -21,7 +22,7 @@
2122
from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
2223
from pandas.core.dtypes.missing import isna
2324

24-
from pandas.core import algorithms, common as com, ops
25+
from pandas.core import algorithms, ops
2526
from pandas.core.arrays import PeriodArray
2627
from pandas.core.arrays.datetimelike import DatetimeLikeArrayMixin
2728
import pandas.core.indexes.base as ibase
@@ -531,7 +532,7 @@ def argmax(self, axis=None, *args, **kwargs):
531532

532533
@property
533534
def _formatter_func(self):
534-
raise com.AbstractMethodError(self)
535+
raise AbstractMethodError(self)
535536

536537
def _format_attrs(self):
537538
"""

pandas/io/common.py

+3-4
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,11 @@
1010
import pandas.compat as compat
1111
from pandas.compat import BytesIO, StringIO, string_types, text_type
1212
from pandas.errors import ( # noqa
13-
DtypeWarning, EmptyDataError, ParserError, ParserWarning)
13+
AbstractMethodError, DtypeWarning, EmptyDataError, ParserError,
14+
ParserWarning)
1415

1516
from pandas.core.dtypes.common import is_file_like, is_number
1617

17-
import pandas.core.common as com
18-
1918
from pandas.io.formats.printing import pprint_thing
2019

2120
# gh-12665: Alias for now and remove later.
@@ -67,7 +66,7 @@ def __iter__(self):
6766
return self
6867

6968
def __next__(self):
70-
raise com.AbstractMethodError(self)
69+
raise AbstractMethodError(self)
7170

7271

7372
if not compat.PY3:

pandas/io/html.py

+9-10
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,11 @@
1212
from pandas.compat import (
1313
binary_type, iteritems, lmap, lrange, raise_with_traceback, string_types,
1414
u)
15-
from pandas.errors import EmptyDataError
15+
from pandas.errors import AbstractMethodError, EmptyDataError
1616

1717
from pandas.core.dtypes.common import is_list_like
1818

1919
from pandas import Series
20-
import pandas.core.common as com
2120

2221
from pandas.io.common import _is_url, _validate_header_arg, urlopen
2322
from pandas.io.formats.printing import pprint_thing
@@ -256,7 +255,7 @@ def _text_getter(self, obj):
256255
text : str or unicode
257256
The text from an individual DOM node.
258257
"""
259-
raise com.AbstractMethodError(self)
258+
raise AbstractMethodError(self)
260259

261260
def _parse_td(self, obj):
262261
"""Return the td elements from a row element.
@@ -271,7 +270,7 @@ def _parse_td(self, obj):
271270
list of node-like
272271
These are the elements of each row, i.e., the columns.
273272
"""
274-
raise com.AbstractMethodError(self)
273+
raise AbstractMethodError(self)
275274

276275
def _parse_thead_tr(self, table):
277276
"""
@@ -286,7 +285,7 @@ def _parse_thead_tr(self, table):
286285
list of node-like
287286
These are the <tr> row elements of a table.
288287
"""
289-
raise com.AbstractMethodError(self)
288+
raise AbstractMethodError(self)
290289

291290
def _parse_tbody_tr(self, table):
292291
"""
@@ -305,7 +304,7 @@ def _parse_tbody_tr(self, table):
305304
list of node-like
306305
These are the <tr> row elements of a table.
307306
"""
308-
raise com.AbstractMethodError(self)
307+
raise AbstractMethodError(self)
309308

310309
def _parse_tfoot_tr(self, table):
311310
"""
@@ -320,7 +319,7 @@ def _parse_tfoot_tr(self, table):
320319
list of node-like
321320
These are the <tr> row elements of a table.
322321
"""
323-
raise com.AbstractMethodError(self)
322+
raise AbstractMethodError(self)
324323

325324
def _parse_tables(self, doc, match, attrs):
326325
"""
@@ -346,7 +345,7 @@ def _parse_tables(self, doc, match, attrs):
346345
list of node-like
347346
HTML <table> elements to be parsed into raw data.
348347
"""
349-
raise com.AbstractMethodError(self)
348+
raise AbstractMethodError(self)
350349

351350
def _equals_tag(self, obj, tag):
352351
"""
@@ -365,7 +364,7 @@ def _equals_tag(self, obj, tag):
365364
boolean
366365
Whether `obj`'s tag name is `tag`
367366
"""
368-
raise com.AbstractMethodError(self)
367+
raise AbstractMethodError(self)
369368

370369
def _build_doc(self):
371370
"""
@@ -376,7 +375,7 @@ def _build_doc(self):
376375
node-like
377376
The DOM from which to parse the table element.
378377
"""
379-
raise com.AbstractMethodError(self)
378+
raise AbstractMethodError(self)
380379

381380
def _parse_thead_tbody_tfoot(self, table_html):
382381
"""

pandas/io/json/json.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
import pandas._libs.json as json
88
from pandas._libs.tslibs import iNaT
99
from pandas.compat import StringIO, long, to_str, u
10+
from pandas.errors import AbstractMethodError
1011

1112
from pandas.core.dtypes.common import is_period_dtype
1213

1314
from pandas import DataFrame, MultiIndex, Series, compat, isna, to_datetime
14-
import pandas.core.common as com
1515
from pandas.core.reshape.concat import concat
1616

1717
from pandas.io.common import (
@@ -97,7 +97,7 @@ def __init__(self, obj, orient, date_format, double_precision,
9797
self._format_axes()
9898

9999
def _format_axes(self):
100-
raise com.AbstractMethodError(self)
100+
raise AbstractMethodError(self)
101101

102102
def write(self):
103103
return self._write(self.obj, self.orient, self.double_precision,
@@ -658,7 +658,7 @@ def _convert_axes(self):
658658
setattr(self.obj, axis, new_axis)
659659

660660
def _try_convert_types(self):
661-
raise com.AbstractMethodError(self)
661+
raise AbstractMethodError(self)
662662

663663
def _try_convert_data(self, name, data, use_dtypes=True,
664664
convert_dates=True):
@@ -771,7 +771,7 @@ def _try_convert_to_date(self, data):
771771
return data, False
772772

773773
def _try_convert_dates(self):
774-
raise com.AbstractMethodError(self)
774+
raise AbstractMethodError(self)
775775

776776

777777
class SeriesParser(Parser):

pandas/io/parquet.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
from warnings import catch_warnings
55

66
from pandas.compat import string_types
7+
from pandas.errors import AbstractMethodError
78

89
from pandas import DataFrame, get_option
9-
import pandas.core.common as com
1010

1111
from pandas.io.common import get_filepath_or_buffer, is_s3_url
1212

@@ -67,10 +67,10 @@ def validate_dataframe(df):
6767
raise ValueError("Index level names must be strings")
6868

6969
def write(self, df, path, compression, **kwargs):
70-
raise com.AbstractMethodError(self)
70+
raise AbstractMethodError(self)
7171

7272
def read(self, path, columns=None, **kwargs):
73-
raise com.AbstractMethodError(self)
73+
raise AbstractMethodError(self)
7474

7575

7676
class PyArrowImpl(BaseImpl):

pandas/io/parsers.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@
2020
import pandas.compat as compat
2121
from pandas.compat import (
2222
PY3, StringIO, lrange, lzip, map, range, string_types, u, zip)
23-
from pandas.errors import EmptyDataError, ParserError, ParserWarning
23+
from pandas.errors import (
24+
AbstractMethodError, EmptyDataError, ParserError, ParserWarning)
2425
from pandas.util._decorators import Appender
2526

2627
from pandas.core.dtypes.cast import astype_nansafe
@@ -33,7 +34,6 @@
3334

3435
from pandas.core import algorithms
3536
from pandas.core.arrays import Categorical
36-
import pandas.core.common as com
3737
from pandas.core.frame import DataFrame
3838
from pandas.core.index import (
3939
Index, MultiIndex, RangeIndex, ensure_index_from_sequences)
@@ -1050,7 +1050,7 @@ def _make_engine(self, engine='c'):
10501050
self._engine = klass(self.f, **self.options)
10511051

10521052
def _failover_to_python(self):
1053-
raise com.AbstractMethodError(self)
1053+
raise AbstractMethodError(self)
10541054

10551055
def read(self, nrows=None):
10561056
nrows = _validate_integer('nrows', nrows)

pandas/plotting/_core.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from pandas.util._decorators import cache_readonly, Appender
1313
from pandas.compat import range, lrange, map, zip, string_types
1414
import pandas.compat as compat
15+
from pandas.errors import AbstractMethodError
1516

1617
import pandas.core.common as com
1718
from pandas.core.base import PandasObject
@@ -373,7 +374,7 @@ def _compute_plot_data(self):
373374
self.data = numeric_data
374375

375376
def _make_plot(self):
376-
raise com.AbstractMethodError(self)
377+
raise AbstractMethodError(self)
377378

378379
def _add_table(self):
379380
if self.table is False:

pandas/tests/io/parser/test_parsers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
from pandas._libs.tslib import Timestamp
88
from pandas.compat import StringIO
9+
from pandas.errors import AbstractMethodError
910

1011
from pandas import DataFrame, read_csv, read_table
11-
import pandas.core.common as com
1212
import pandas.util.testing as tm
1313

1414
from .c_parser_only import CParserTests
@@ -46,7 +46,7 @@ def read_table(self, *args, **kwargs):
4646
raise NotImplementedError
4747

4848
def float_precision_choices(self):
49-
raise com.AbstractMethodError(self)
49+
raise AbstractMethodError(self)
5050

5151
@pytest.fixture(autouse=True)
5252
def setup_method(self, datapath):

pandas/tests/test_resample.py

+2-3
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,11 @@
2424
notna, Timestamp, Timedelta)
2525

2626
from pandas.compat import range, lrange, zip, OrderedDict
27-
from pandas.errors import UnsupportedFunctionCall
27+
from pandas.errors import AbstractMethodError, UnsupportedFunctionCall
2828
import pandas.tseries.offsets as offsets
2929
from pandas.tseries.offsets import Minute, BDay
3030

3131
from pandas.core.groupby.groupby import DataError
32-
import pandas.core.common as com
3332

3433
from pandas.core.indexes.datetimes import date_range
3534
from pandas.core.indexes.period import period_range, PeriodIndex, Period
@@ -599,7 +598,7 @@ def index(self, _index_start, _index_end, _index_freq):
599598

600599
@pytest.fixture
601600
def _series_name(self):
602-
raise com.AbstractMethodError(self)
601+
raise AbstractMethodError(self)
603602

604603
@pytest.fixture
605604
def _static_values(self, index):

0 commit comments

Comments
 (0)