Skip to content

Commit

Permalink
CLN: remove incorrect usages of com.AbstractMethodError (#23625)
Browse files Browse the repository at this point in the history
  • Loading branch information
jbrockmendel authored and jreback committed Nov 12, 2018
1 parent b9ba708 commit c738523
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 44 deletions.
8 changes: 5 additions & 3 deletions pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@
import pandas as pd

from pandas._libs import properties, Timestamp, iNaT
from pandas.errors import AbstractMethodError

from pandas.core.dtypes.common import (
ensure_int64,
ensure_object,
Expand Down Expand Up @@ -200,7 +202,7 @@ def _constructor(self):
"""Used when a manipulation result has the same dimensions as the
original.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

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

@property
def _constructor_expanddim(self):
Expand Down Expand Up @@ -2884,7 +2886,7 @@ def _iget_item_cache(self, item):
return lower

def _box_item_values(self, key, values):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _maybe_cache_changed(self, item, value):
"""The object has called back to us saying maybe it has changed.
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/groupby/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import pandas.compat as compat
from pandas.compat import lzip, map
from pandas.compat.numpy import _np_version_under1p13
from pandas.errors import AbstractMethodError
from pandas.util._decorators import Appender, Substitution

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

def _wrap_aggregated_output(self, output, names=None):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

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

def _wrap_aggregated_output(self, output, names=None):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)
5 changes: 3 additions & 2 deletions pandas/core/groupby/groupby.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ class providing the base-class of operations.
import pandas.compat as compat
from pandas.compat import callable, range, set_function_name, zip
from pandas.compat.numpy import function as nv
from pandas.errors import AbstractMethodError
from pandas.util._decorators import Appender, Substitution, cache_readonly
from pandas.util._validators import validate_kwargs

Expand Down Expand Up @@ -706,7 +707,7 @@ def _iterate_slices(self):
yield self._selection_name, self._selected_obj

def transform(self, func, *args, **kwargs):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _cumcount_array(self, ascending=True):
"""
Expand Down Expand Up @@ -861,7 +862,7 @@ def _python_agg_general(self, func, *args, **kwargs):
return self._wrap_aggregated_output(output)

def _wrap_applied_output(self, *args, **kwargs):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _concat_objects(self, keys, values, not_indexed_same=False):
from pandas.core.reshape.concat import concat
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

from pandas._libs import NaT, groupby as libgroupby, iNaT, lib, reduction
from pandas.compat import lzip, range, zip
from pandas.errors import AbstractMethodError
from pandas.util._decorators import cache_readonly

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

def apply(self, f):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)


class SeriesSplitter(DataSplitter):
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/indexes/datetimelike.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from pandas._libs.tslibs.timestamps import RoundTo, round_nsint64
import pandas.compat as compat
from pandas.compat.numpy import function as nv
from pandas.errors import AbstractMethodError
from pandas.util._decorators import Appender, cache_readonly

from pandas.core.dtypes.common import (
Expand All @@ -21,7 +22,7 @@
from pandas.core.dtypes.generic import ABCIndex, ABCIndexClass, ABCSeries
from pandas.core.dtypes.missing import isna

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

@property
def _formatter_func(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _format_attrs(self):
"""
Expand Down
7 changes: 3 additions & 4 deletions pandas/io/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
import pandas.compat as compat
from pandas.compat import BytesIO, StringIO, string_types, text_type
from pandas.errors import ( # noqa
DtypeWarning, EmptyDataError, ParserError, ParserWarning)
AbstractMethodError, DtypeWarning, EmptyDataError, ParserError,
ParserWarning)

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

import pandas.core.common as com

from pandas.io.formats.printing import pprint_thing

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

def __next__(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)


if not compat.PY3:
Expand Down
19 changes: 9 additions & 10 deletions pandas/io/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
from pandas.compat import (
binary_type, iteritems, lmap, lrange, raise_with_traceback, string_types,
u)
from pandas.errors import EmptyDataError
from pandas.errors import AbstractMethodError, EmptyDataError

from pandas.core.dtypes.common import is_list_like

from pandas import Series
import pandas.core.common as com

from pandas.io.common import _is_url, _validate_header_arg, urlopen
from pandas.io.formats.printing import pprint_thing
Expand Down Expand Up @@ -256,7 +255,7 @@ def _text_getter(self, obj):
text : str or unicode
The text from an individual DOM node.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_td(self, obj):
"""Return the td elements from a row element.
Expand All @@ -271,7 +270,7 @@ def _parse_td(self, obj):
list of node-like
These are the elements of each row, i.e., the columns.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_thead_tr(self, table):
"""
Expand All @@ -286,7 +285,7 @@ def _parse_thead_tr(self, table):
list of node-like
These are the <tr> row elements of a table.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_tbody_tr(self, table):
"""
Expand All @@ -305,7 +304,7 @@ def _parse_tbody_tr(self, table):
list of node-like
These are the <tr> row elements of a table.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_tfoot_tr(self, table):
"""
Expand All @@ -320,7 +319,7 @@ def _parse_tfoot_tr(self, table):
list of node-like
These are the <tr> row elements of a table.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_tables(self, doc, match, attrs):
"""
Expand All @@ -346,7 +345,7 @@ def _parse_tables(self, doc, match, attrs):
list of node-like
HTML <table> elements to be parsed into raw data.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _equals_tag(self, obj, tag):
"""
Expand All @@ -365,7 +364,7 @@ def _equals_tag(self, obj, tag):
boolean
Whether `obj`'s tag name is `tag`
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _build_doc(self):
"""
Expand All @@ -376,7 +375,7 @@ def _build_doc(self):
node-like
The DOM from which to parse the table element.
"""
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _parse_thead_tbody_tfoot(self, table_html):
"""
Expand Down
8 changes: 4 additions & 4 deletions pandas/io/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
import pandas._libs.json as json
from pandas._libs.tslibs import iNaT
from pandas.compat import StringIO, long, to_str, u
from pandas.errors import AbstractMethodError

from pandas.core.dtypes.common import is_period_dtype

from pandas import DataFrame, MultiIndex, Series, compat, isna, to_datetime
import pandas.core.common as com
from pandas.core.reshape.concat import concat

from pandas.io.common import (
Expand Down Expand Up @@ -97,7 +97,7 @@ def __init__(self, obj, orient, date_format, double_precision,
self._format_axes()

def _format_axes(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def write(self):
return self._write(self.obj, self.orient, self.double_precision,
Expand Down Expand Up @@ -658,7 +658,7 @@ def _convert_axes(self):
setattr(self.obj, axis, new_axis)

def _try_convert_types(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _try_convert_data(self, name, data, use_dtypes=True,
convert_dates=True):
Expand Down Expand Up @@ -771,7 +771,7 @@ def _try_convert_to_date(self, data):
return data, False

def _try_convert_dates(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)


class SeriesParser(Parser):
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/parquet.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@
from warnings import catch_warnings

from pandas.compat import string_types
from pandas.errors import AbstractMethodError

from pandas import DataFrame, get_option
import pandas.core.common as com

from pandas.io.common import get_filepath_or_buffer, is_s3_url

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

def write(self, df, path, compression, **kwargs):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def read(self, path, columns=None, **kwargs):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)


class PyArrowImpl(BaseImpl):
Expand Down
6 changes: 3 additions & 3 deletions pandas/io/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
import pandas.compat as compat
from pandas.compat import (
PY3, StringIO, lrange, lzip, map, range, string_types, u, zip)
from pandas.errors import EmptyDataError, ParserError, ParserWarning
from pandas.errors import (
AbstractMethodError, EmptyDataError, ParserError, ParserWarning)
from pandas.util._decorators import Appender

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

from pandas.core import algorithms
from pandas.core.arrays import Categorical
import pandas.core.common as com
from pandas.core.frame import DataFrame
from pandas.core.index import (
Index, MultiIndex, RangeIndex, ensure_index_from_sequences)
Expand Down Expand Up @@ -1050,7 +1050,7 @@ def _make_engine(self, engine='c'):
self._engine = klass(self.f, **self.options)

def _failover_to_python(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def read(self, nrows=None):
nrows = _validate_integer('nrows', nrows)
Expand Down
3 changes: 2 additions & 1 deletion pandas/plotting/_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from pandas.util._decorators import cache_readonly, Appender
from pandas.compat import range, lrange, map, zip, string_types
import pandas.compat as compat
from pandas.errors import AbstractMethodError

import pandas.core.common as com
from pandas.core.base import PandasObject
Expand Down Expand Up @@ -373,7 +374,7 @@ def _compute_plot_data(self):
self.data = numeric_data

def _make_plot(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

def _add_table(self):
if self.table is False:
Expand Down
4 changes: 2 additions & 2 deletions pandas/tests/io/parser/test_parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

from pandas._libs.tslib import Timestamp
from pandas.compat import StringIO
from pandas.errors import AbstractMethodError

from pandas import DataFrame, read_csv, read_table
import pandas.core.common as com
import pandas.util.testing as tm

from .c_parser_only import CParserTests
Expand Down Expand Up @@ -46,7 +46,7 @@ def read_table(self, *args, **kwargs):
raise NotImplementedError

def float_precision_choices(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

@pytest.fixture(autouse=True)
def setup_method(self, datapath):
Expand Down
5 changes: 2 additions & 3 deletions pandas/tests/test_resample.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,11 @@
notna, Timestamp, Timedelta)

from pandas.compat import range, lrange, zip, OrderedDict
from pandas.errors import UnsupportedFunctionCall
from pandas.errors import AbstractMethodError, UnsupportedFunctionCall
import pandas.tseries.offsets as offsets
from pandas.tseries.offsets import Minute, BDay

from pandas.core.groupby.groupby import DataError
import pandas.core.common as com

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

@pytest.fixture
def _series_name(self):
raise com.AbstractMethodError(self)
raise AbstractMethodError(self)

@pytest.fixture
def _static_values(self, index):
Expand Down
Loading

0 comments on commit c738523

Please sign in to comment.