Skip to content

Commit

Permalink
CLN: Remove unused variables (#21986)
Browse files Browse the repository at this point in the history
  • Loading branch information
mroeschke authored and jreback committed Jul 29, 2018
1 parent e8e078f commit 0c58a82
Show file tree
Hide file tree
Showing 19 changed files with 38 additions and 30 deletions.
1 change: 0 additions & 1 deletion pandas/core/arrays/categorical.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,6 @@ def __init__(self, values, categories=None, ordered=None, dtype=None,
" or `ordered`.")

categories = dtype.categories
ordered = dtype.ordered

elif is_categorical(values):
# If no "dtype" was passed, use the one from "values", but honor
Expand Down
1 change: 0 additions & 1 deletion pandas/core/arrays/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,6 @@ def from_tuples(cls, data, closed='right', copy=False, dtype=None):
msg = ('{name}.from_tuples received an invalid '
'item, {tpl}').format(name=name, tpl=d)
raise TypeError(msg)
lhs, rhs = d
left.append(lhs)
right.append(rhs)

Expand Down
9 changes: 8 additions & 1 deletion pandas/core/generic.py
Original file line number Diff line number Diff line change
Expand Up @@ -1084,7 +1084,8 @@ def rename(self, *args, **kwargs):
level = kwargs.pop('level', None)
axis = kwargs.pop('axis', None)
if axis is not None:
axis = self._get_axis_number(axis)
# Validate the axis
self._get_axis_number(axis)

if kwargs:
raise TypeError('rename() got an unexpected keyword '
Expand Down Expand Up @@ -5299,6 +5300,12 @@ def __copy__(self, deep=True):
return self.copy(deep=deep)

def __deepcopy__(self, memo=None):
"""
Parameters
----------
memo, default None
Standard signature. Unused
"""
if memo is None:
memo = {}
return self.copy(deep=True)
Expand Down
1 change: 0 additions & 1 deletion pandas/core/groupby/ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ def _transform(self, result, values, comp_ids, transform_func,
elif values.ndim > 2:
for i, chunk in enumerate(values.transpose(2, 0, 1)):

chunk = chunk.squeeze()
transform_func(result[:, :, i], values,
comp_ids, is_datetimelike, **kwargs)
else:
Expand Down
6 changes: 6 additions & 0 deletions pandas/core/indexes/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -993,6 +993,12 @@ def __copy__(self, **kwargs):
return self.copy(**kwargs)

def __deepcopy__(self, memo=None):
"""
Parameters
----------
memo, default None
Standard signature. Unused
"""
if memo is None:
memo = {}
return self.copy(deep=True)
Expand Down
2 changes: 1 addition & 1 deletion pandas/core/indexes/category.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ def _create_from_codes(self, codes, categories=None, ordered=None,
if name is None:
name = self.name
cat = Categorical.from_codes(codes, categories=categories,
ordered=self.ordered)
ordered=ordered)
return CategoricalIndex(cat, name=name)

@classmethod
Expand Down
1 change: 0 additions & 1 deletion pandas/core/indexes/interval.py
Original file line number Diff line number Diff line change
Expand Up @@ -939,7 +939,6 @@ def _format_data(self, name=None):
summary = '[{head} ... {tail}]'.format(
head=', '.join(head), tail=', '.join(tail))
else:
head = []
tail = [formatter(x) for x in self]
summary = '[{tail}]'.format(tail=', '.join(tail))

Expand Down
5 changes: 1 addition & 4 deletions pandas/core/internals/blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -1248,7 +1248,7 @@ def take_nd(self, indexer, axis, new_mgr_locs=None, fill_tuple=None):
if fill_tuple is None:
fill_value = self.fill_value
new_values = algos.take_nd(values, indexer, axis=axis,
allow_fill=False)
allow_fill=False, fill_value=fill_value)
else:
fill_value = fill_tuple[0]
new_values = algos.take_nd(values, indexer, axis=axis,
Expand Down Expand Up @@ -2699,7 +2699,6 @@ def _try_coerce_args(self, values, other):

values_mask = isna(values)
values = values.view('i8')
other_mask = False

if isinstance(other, bool):
raise TypeError
Expand Down Expand Up @@ -2872,11 +2871,9 @@ def _try_coerce_args(self, values, other):
values_mask = _block_shape(isna(values), ndim=self.ndim)
# asi8 is a view, needs copy
values = _block_shape(values.asi8, ndim=self.ndim)
other_mask = False

if isinstance(other, ABCSeries):
other = self._holder(other)
other_mask = isna(other)

if isinstance(other, bool):
raise TypeError
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,9 @@ def nanvar(values, axis=None, skipna=True, ddof=1):

@disallow('M8', 'm8')
def nansem(values, axis=None, skipna=True, ddof=1):
var = nanvar(values, axis, skipna, ddof=ddof)
# This checks if non-numeric-like data is passed with numeric_only=False
# and raises a TypeError otherwise
nanvar(values, axis, skipna, ddof=ddof)

mask = isna(values)
if not is_float_dtype(values.dtype):
Expand Down Expand Up @@ -635,7 +637,6 @@ def nankurt(values, axis=None, skipna=True):
adj = 3 * (count - 1) ** 2 / ((count - 2) * (count - 3))
numer = count * (count + 1) * (count - 1) * m4
denom = (count - 2) * (count - 3) * m2**2
result = numer / denom - adj

# floating point error
#
Expand Down
14 changes: 8 additions & 6 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2052,7 +2052,6 @@ def dot(self, other):
lvals = left.values
rvals = right.values
else:
left = self
lvals = self.values
rvals = np.asarray(other)
if lvals.shape[0] != rvals.shape[0]:
Expand Down Expand Up @@ -2480,7 +2479,8 @@ def sort_values(self, axis=0, ascending=True, inplace=False,
dtype: object
"""
inplace = validate_bool_kwarg(inplace, 'inplace')
axis = self._get_axis_number(axis)
# Validate the axis parameter
self._get_axis_number(axis)

# GH 5856/5853
if inplace and self._is_cached:
Expand Down Expand Up @@ -2652,7 +2652,8 @@ def sort_index(self, axis=0, level=None, ascending=True, inplace=False,
# TODO: this can be combined with DataFrame.sort_index impl as
# almost identical
inplace = validate_bool_kwarg(inplace, 'inplace')
axis = self._get_axis_number(axis)
# Validate the axis parameter
self._get_axis_number(axis)
index = self.index

if level is not None:
Expand Down Expand Up @@ -3073,7 +3074,8 @@ def _gotitem(self, key, ndim, subset=None):
versionadded='.. versionadded:: 0.20.0',
**_shared_doc_kwargs))
def aggregate(self, func, axis=0, *args, **kwargs):
axis = self._get_axis_number(axis)
# Validate the axis parameter
self._get_axis_number(axis)
result, how = self._aggregate(func, *args, **kwargs)
if result is None:

Expand Down Expand Up @@ -3919,8 +3921,8 @@ def dropna(self, axis=0, inplace=False, **kwargs):
if kwargs:
raise TypeError('dropna() got an unexpected keyword '
'argument "{0}"'.format(list(kwargs.keys())[0]))

axis = self._get_axis_number(axis or 0)
# Validate the axis parameter
self._get_axis_number(axis or 0)

if self._can_hold_na:
result = remove_na_arraylike(self)
Expand Down
1 change: 0 additions & 1 deletion pandas/core/sparse/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -597,7 +597,6 @@ def _combine_match_index(self, other, func, level=None):
new_data[col] = func(series.values, other.values)

# fill_value is a function of our operator
fill_value = None
if isna(other.fill_value) or isna(self.default_fill_value):
fill_value = np.nan
else:
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -933,7 +933,8 @@ class _Rolling_and_Expanding(_Rolling):
def count(self):

blocks, obj, index = self._create_blocks()
index, indexi = self._get_index(index=index)
# Validate the index
self._get_index(index=index)

window = self._get_window()
window = min(window, len(obj)) if not self.center else window
Expand Down
2 changes: 0 additions & 2 deletions pandas/io/formats/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -495,8 +495,6 @@ def _chk_truncate(self):
frame.iloc[:, -col_num:]), axis=1)
self.tr_col_num = col_num
if truncate_v:
if max_rows_adj == 0:
row_num = len(frame)
if max_rows_adj == 1:
row_num = max_rows
frame = frame.iloc[:max_rows, :]
Expand Down
1 change: 0 additions & 1 deletion pandas/io/formats/html.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,6 @@ def _column_header():
return row

self.write('<thead>', indent)
row = []

indent += self.indent_delta

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/formats/terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def is_terminal():


def _get_terminal_size_windows():
res = None

try:
from ctypes import windll, create_string_buffer

Expand Down
2 changes: 1 addition & 1 deletion pandas/io/json/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def _get_object_parser(self, json):

if typ == 'series' or obj is None:
if not isinstance(dtype, bool):
dtype = dict(data=dtype)
kwargs['dtype'] = dtype
obj = SeriesParser(json, **kwargs).parse()

return obj
Expand Down
4 changes: 0 additions & 4 deletions pandas/io/sas/sas_xport.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,10 +181,6 @@ def _parse_float_vec(vec):
# number sans exponent
ieee1 = xport1 & 0x00ffffff

# Get the second half of the ibm number into the second half of
# the ieee number
ieee2 = xport2

# The fraction bit to the left of the binary point in the ieee
# format was set and the number was shifted 0, 1, 2, or 3
# places. This will tell us how to adjust the ibm exponent to be a
Expand Down
1 change: 0 additions & 1 deletion pandas/plotting/_timeseries.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@ def _maybe_resample(series, ax, kwargs):
freq = ax_freq
elif frequencies.is_subperiod(freq, ax_freq) or _is_sub(freq, ax_freq):
_upsample_others(ax, freq, kwargs)
ax_freq = freq
else: # pragma: no cover
raise ValueError('Incompatible frequency conversion')
return freq, series
Expand Down
7 changes: 7 additions & 0 deletions pandas/tests/io/json/test_pandas.py
Original file line number Diff line number Diff line change
Expand Up @@ -642,6 +642,13 @@ def test_series_from_json_precise_float(self):
result = read_json(s.to_json(), typ='series', precise_float=True)
assert_series_equal(result, s, check_index_type=False)

def test_series_with_dtype(self):
# GH 21986
s = Series([4.56, 4.56, 4.56])
result = read_json(s.to_json(), typ='series', dtype=np.int64)
expected = Series([4] * 3)
assert_series_equal(result, expected)

def test_frame_from_json_precise_float(self):
df = DataFrame([[4.56, 4.56, 4.56], [4.56, 4.56, 4.56]])
result = read_json(df.to_json(), precise_float=True)
Expand Down

0 comments on commit 0c58a82

Please sign in to comment.