Skip to content

CLN: Remove core/array.py #8406

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions pandas/core/array.py

This file was deleted.

7 changes: 3 additions & 4 deletions pandas/core/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
from pandas.compat import StringIO, BytesIO, range, long, u, zip, map

from pandas.core.config import get_option
from pandas.core import array as pa

class PandasError(Exception):
pass
Expand Down Expand Up @@ -999,7 +998,7 @@ def _infer_dtype_from_scalar(val):
dtype = np.object_

# a 1-element ndarray
if isinstance(val, pa.Array):
if isinstance(val, np.ndarray):
if val.ndim != 0:
raise ValueError(
"invalid ndarray passed to _infer_dtype_from_scalar")
Expand Down Expand Up @@ -1350,7 +1349,7 @@ def _fill_zeros(result, x, y, name, fill):

if not isinstance(y, np.ndarray):
dtype, value = _infer_dtype_from_scalar(y)
y = pa.empty(result.shape, dtype=dtype)
y = np.empty(result.shape, dtype=dtype)
y.fill(value)

if is_integer_dtype(y):
Expand Down Expand Up @@ -1575,7 +1574,7 @@ def _interp_limit(invalid, limit):
inds = np.asarray(xvalues)
# hack for DatetimeIndex, #1646
if issubclass(inds.dtype.type, np.datetime64):
inds = inds.view(pa.int64)
inds = inds.view(np.int64)

if inds.dtype == np.object_:
inds = lib.maybe_convert_objects(inds)
Expand Down
31 changes: 15 additions & 16 deletions pandas/core/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
import pandas.index as _index
from pandas.util.decorators import Appender
import pandas.core.common as com
import pandas.core.array as pa
import pandas.computation.expressions as expressions
from pandas.core.common import(bind_method, is_list_like, notnull, isnull,
_values_from_object, _maybe_match_name)
Expand Down Expand Up @@ -332,7 +331,7 @@ def _convert_to_array(self, values, name=None, other=None):
# a datelike
elif isinstance(values, pd.DatetimeIndex):
values = values.to_series()
elif not (isinstance(values, (pa.Array, pd.Series)) and
elif not (isinstance(values, (np.ndarray, pd.Series)) and
com.is_datetime64_dtype(values)):
values = tslib.array_to_datetime(values)
elif inferred_type in ('timedelta', 'timedelta64'):
Expand All @@ -349,7 +348,7 @@ def _convert_to_array(self, values, name=None, other=None):
"operation [{0}]".format(name))
elif isinstance(values[0], pd.DateOffset):
# handle DateOffsets
os = pa.array([getattr(v, 'delta', None) for v in values])
os = np.array([getattr(v, 'delta', None) for v in values])
mask = isnull(os)
if mask.any():
raise TypeError("cannot use a non-absolute DateOffset in "
Expand All @@ -366,10 +365,10 @@ def _convert_to_array(self, values, name=None, other=None):
else:
raise TypeError(
'incompatible type [{0}] for a datetime/timedelta '
'operation'.format(pa.array(values).dtype))
'operation'.format(np.array(values).dtype))
else:
raise TypeError("incompatible type [{0}] for a datetime/timedelta"
" operation".format(pa.array(values).dtype))
" operation".format(np.array(values).dtype))

return values

Expand Down Expand Up @@ -408,7 +407,7 @@ def _convert_for_datetime(self, lvalues, rvalues):
if mask is not None:
if mask.any():
def f(x):
x = pa.array(x, dtype=self.dtype)
x = np.array(x, dtype=self.dtype)
np.putmask(x, mask, self.fill_value)
return x
self.wrap_results = f
Expand Down Expand Up @@ -449,19 +448,19 @@ def na_op(x, y):
result = expressions.evaluate(op, str_rep, x, y,
raise_on_error=True, **eval_kwargs)
except TypeError:
if isinstance(y, (pa.Array, pd.Series, pd.Index)):
if isinstance(y, (np.ndarray, pd.Series, pd.Index)):
dtype = np.find_common_type([x.dtype, y.dtype], [])
result = np.empty(x.size, dtype=dtype)
mask = notnull(x) & notnull(y)
result[mask] = op(x[mask], _values_from_object(y[mask]))
elif isinstance(x, pa.Array):
result = pa.empty(len(x), dtype=x.dtype)
elif isinstance(x, np.ndarray):
result = np.empty(len(x), dtype=x.dtype)
mask = notnull(x)
result[mask] = op(x[mask], y)
else:
raise TypeError("{typ} cannot perform the operation {op}".format(typ=type(x).__name__,op=str_rep))

result, changed = com._maybe_upcast_putmask(result, ~mask, pa.NA)
result, changed = com._maybe_upcast_putmask(result, ~mask, np.nan)

result = com._fill_zeros(result, x, y, name, fill_zeros)
return result
Expand Down Expand Up @@ -531,7 +530,7 @@ def na_op(x, y):
if isinstance(y, list):
y = lib.list_to_object_array(y)

if isinstance(y, (pa.Array, pd.Series)):
if isinstance(y, (np.ndarray, pd.Series)):
if y.dtype != np.object_:
result = lib.vec_compare(x, y.astype(np.object_), op)
else:
Expand All @@ -558,7 +557,7 @@ def wrapper(self, other):
index=self.index, name=name)
elif isinstance(other, pd.DataFrame): # pragma: no cover
return NotImplemented
elif isinstance(other, (pa.Array, pd.Index)):
elif isinstance(other, (np.ndarray, pd.Index)):
if len(self) != len(other):
raise ValueError('Lengths must match to compare')
return self._constructor(na_op(self.values, np.asarray(other)),
Expand Down Expand Up @@ -610,7 +609,7 @@ def na_op(x, y):
if isinstance(y, list):
y = lib.list_to_object_array(y)

if isinstance(y, (pa.Array, pd.Series)):
if isinstance(y, (np.ndarray, pd.Series)):
if (x.dtype == np.bool_ and
y.dtype == np.bool_): # pragma: no cover
result = op(x, y) # when would this be hit?
Expand Down Expand Up @@ -688,7 +687,7 @@ def flex_wrapper(self, other, level=None, fill_value=None, axis=0):
self._get_axis_number(axis)
if isinstance(other, pd.Series):
return self._binop(other, op, level=level, fill_value=fill_value)
elif isinstance(other, (pa.Array, pd.Series, list, tuple)):
elif isinstance(other, (np.ndarray, pd.Series, list, tuple)):
if len(other) != len(self):
raise ValueError('Lengths must be equal')
return self._binop(self._constructor(other, self.index), op,
Expand Down Expand Up @@ -925,10 +924,10 @@ def na_op(x, y):
except TypeError:

# TODO: might need to find_common_type here?
result = pa.empty(len(x), dtype=x.dtype)
result = np.empty(len(x), dtype=x.dtype)
mask = notnull(x)
result[mask] = op(x[mask], y)
result, changed = com._maybe_upcast_putmask(result, ~mask, pa.NA)
result, changed = com._maybe_upcast_putmask(result, ~mask, np.nan)

result = com._fill_zeros(result, x, y, name, fill_zeros)
return result
Expand Down
Loading