Skip to content

TST/STYLE: remove multiprocess nose flags and slight PEP fixes #15333

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

Closed
wants to merge 1 commit into from
Closed
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
8 changes: 5 additions & 3 deletions pandas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
missing_dependencies.append(dependency)

if missing_dependencies:
raise ImportError("Missing required dependencies {0}".format(missing_dependencies))
raise ImportError(
"Missing required dependencies {0}".format(missing_dependencies))
del hard_dependencies, dependency, missing_dependencies

# numpy compat
Expand All @@ -24,7 +25,8 @@
try:
from pandas import hashtable, tslib, lib
except ImportError as e: # pragma: no cover
module = str(e).lstrip('cannot import name ') # hack but overkill to use re
# hack but overkill to use re
module = str(e).lstrip('cannot import name ')
raise ImportError("C extension: {0} not built. If you want to import "
"pandas from the source directory, you may need to run "
"'python setup.py build_ext --inplace --force' to build "
Expand Down Expand Up @@ -61,5 +63,5 @@
# use the closest tagged version if possible
from ._version import get_versions
v = get_versions()
__version__ = v.get('closest-tag',v['version'])
__version__ = v.get('closest-tag', v['version'])
del get_versions, v
2 changes: 1 addition & 1 deletion pandas/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ def git_versions_from_keywords(keywords, tag_prefix, verbose):
# "stabilization", as well as "HEAD" and "master".
tags = set([r for r in refs if re.search(r'\d', r)])
if verbose:
print("discarding '%s', no digits" % ",".join(refs-tags))
print("discarding '%s', no digits" % ",".join(refs - tags))
if verbose:
print("likely tags: %s" % ",".join(sorted(tags)))
for ref in sorted(tags):
Expand Down
2 changes: 0 additions & 2 deletions pandas/api/tests/test_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
from pandas.api import types
from pandas.util import testing as tm

_multiprocess_can_split_ = True


class Base(object):

Expand Down
24 changes: 15 additions & 9 deletions pandas/compat/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,25 +79,25 @@ def signature(f):
args = [
p.name for p in sig.parameters.values()
if p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD
]
]
varargs = [
p.name for p in sig.parameters.values()
if p.kind == inspect.Parameter.VAR_POSITIONAL
]
]
varargs = varargs[0] if varargs else None
keywords = [
p.name for p in sig.parameters.values()
if p.kind == inspect.Parameter.VAR_KEYWORD
]
]
keywords = keywords[0] if keywords else None
defaults = [
p.default for p in sig.parameters.values()
if p.kind == inspect.Parameter.POSITIONAL_OR_KEYWORD
and p.default is not p.empty
] or None
argspec = namedtuple('Signature',['args','defaults',
'varargs','keywords'])
return argspec(args,defaults,varargs,keywords)
] or None
argspec = namedtuple('Signature', ['args', 'defaults',
'varargs', 'keywords'])
return argspec(args, defaults, varargs, keywords)

# have to explicitly put builtins into the namespace
range = range
Expand Down Expand Up @@ -170,7 +170,7 @@ def iterkeys(obj, **kw):
def itervalues(obj, **kw):
return obj.itervalues(**kw)

next = lambda it : it.next()
next = lambda it: it.next()
else:
def iteritems(obj, **kw):
return iter(obj.items(**kw))
Expand All @@ -183,6 +183,7 @@ def itervalues(obj, **kw):

next = next


def bind_method(cls, name, func):
"""Bind a method to class, python 2 and python 3 compatible.

Expand Down Expand Up @@ -307,7 +308,8 @@ def set_function_name(f, name, cls):
f.__name__ = name
return f

class ResourceWarning(Warning): pass
class ResourceWarning(Warning):
pass

string_and_binary_types = string_types + (binary_type,)

Expand Down Expand Up @@ -398,14 +400,18 @@ def is_platform_little_endian():
""" am I little endian """
return sys.byteorder == 'little'


def is_platform_windows():
return sys.platform == 'win32' or sys.platform == 'cygwin'


def is_platform_linux():
return sys.platform == 'linux2'


def is_platform_mac():
return sys.platform == 'darwin'


def is_platform_32bit():
return struct.calcsize("P") * 8 < 64
1 change: 1 addition & 0 deletions pandas/compat/chainmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@


class DeepChainMap(ChainMap):

def __setitem__(self, key, value):
for mapping in self.maps:
if key in mapping:
Expand Down
1 change: 1 addition & 0 deletions pandas/compat/numpy/function.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@


class CompatValidator(object):

def __init__(self, defaults, fname=None, method=None,
max_fname_arg_count=None):
self.fname = fname
Expand Down
9 changes: 7 additions & 2 deletions pandas/compat/pickle_compat.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from pandas import compat, Index
from pandas.compat import u, string_types


def load_reduce(self):
stack = self.stack
args = stack.pop()
Expand All @@ -34,7 +35,7 @@ def load_reduce(self):
pass

# try to reencode the arguments
if getattr(self,'encoding',None) is not None:
if getattr(self, 'encoding', None) is not None:
args = tuple([arg.encode(self.encoding)
if isinstance(arg, string_types)
else arg for arg in args])
Expand All @@ -44,7 +45,7 @@ def load_reduce(self):
except:
pass

if getattr(self,'is_verbose',None):
if getattr(self, 'is_verbose', None):
print(sys.exc_info())
print(func, args)
raise
Expand All @@ -61,6 +62,7 @@ class Unpickler(pkl.Unpickler):
Unpickler.dispatch = copy.copy(Unpickler.dispatch)
Unpickler.dispatch[pkl.REDUCE[0]] = load_reduce


def load_newobj(self):
args = self.stack.pop()
cls = self.stack[-1]
Expand All @@ -75,6 +77,8 @@ def load_newobj(self):
Unpickler.dispatch[pkl.NEWOBJ[0]] = load_newobj

# py3 compat


def load_newobj_ex(self):
kwargs = self.stack.pop()
args = self.stack.pop()
Expand All @@ -91,6 +95,7 @@ def load_newobj_ex(self):
except:
pass


def load(fh, encoding=None, compat=False, is_verbose=False):
"""load a pickle, with a provided encoding

Expand Down
10 changes: 6 additions & 4 deletions pandas/computation/tests/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def check_complex_cmp_op(self, lhs, cmp1, rhs, binop, cmp2):
binop=binop,
cmp2=cmp2)
scalar_with_in_notin = (is_scalar(rhs) and (cmp1 in skip_these or
cmp2 in skip_these))
cmp2 in skip_these))
if scalar_with_in_notin:
with tm.assertRaises(TypeError):
pd.eval(ex, engine=self.engine, parser=self.parser)
Expand Down Expand Up @@ -702,7 +702,6 @@ def test_float_truncation(self):
tm.assert_frame_equal(expected, result)



class TestEvalNumexprPython(TestEvalNumexprPandas):

@classmethod
Expand Down Expand Up @@ -782,6 +781,7 @@ def check_chained_cmp_op(self, lhs, cmp1, mid, cmp2, rhs):
# typecasting rules consistency with python
# issue #12388


class TestTypeCasting(object):

def check_binop_typecasting(self, engine, parser, op, dt):
Expand All @@ -803,7 +803,8 @@ def test_binop_typecasting(self):
for engine, parser in ENGINES_PARSERS:
for op in ['+', '-', '*', '**', '/']:
# maybe someday... numexpr has too many upcasting rules now
#for dt in chain(*(np.sctypes[x] for x in ['uint', 'int', 'float'])):
# for dt in chain(*(np.sctypes[x] for x in ['uint', 'int',
# 'float'])):
for dt in [np.float32, np.float64]:
yield self.check_binop_typecasting, engine, parser, op, dt

Expand Down Expand Up @@ -1969,10 +1970,11 @@ def test_negate_lt_eq_le():
for engine, parser in product(_engines, expr._parsers):
yield check_negate_lt_eq_le, engine, parser


class TestValidate(tm.TestCase):

def test_validate_bool_args(self):
invalid_values = [1, "True", [1,2,3], 5.0]
invalid_values = [1, "True", [1, 2, 3], 5.0]

for value in invalid_values:
with self.assertRaises(ValueError):
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ def f(self, *args, **kwargs):
class AccessorProperty(object):
"""Descriptor for implementing accessor properties like Series.str
"""

def __init__(self, accessor_cls, construct_accessor):
self.accessor_cls = accessor_cls
self.construct_accessor = construct_accessor
Expand Down Expand Up @@ -651,6 +652,7 @@ class GroupByMixin(object):
@staticmethod
def _dispatch(name, *args, **kwargs):
""" dispatch to apply """

def outer(self, *args, **kwargs):
def f(x):
x = self._shallow_copy(x, groupby=self._groupby)
Expand Down
1 change: 1 addition & 0 deletions pandas/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def __dir__(self):


class CallableDynamicDoc(object):

def __init__(self, func, doc_tmpl):
self.__doc_tmpl__ = doc_tmpl
self.__func__ = func
Expand Down
5 changes: 3 additions & 2 deletions pandas/core/frame.py
Original file line number Diff line number Diff line change
Expand Up @@ -5326,9 +5326,10 @@ def isin(self, values):
"allowed to be passed to DataFrame.isin(), "
"you passed a "
"{0!r}".format(type(values).__name__))
return DataFrame(lib.ismember(self.values.ravel(),
return DataFrame(
lib.ismember(self.values.ravel(),
set(values)).reshape(self.shape), self.index,
self.columns)
self.columns)

# ----------------------------------------------------------------------
# Deprecated stuff
Expand Down
1 change: 1 addition & 0 deletions pandas/core/indexing.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ def get_indexers_list():

# the public IndexSlicerMaker
class _IndexSlice(object):

def __getitem__(self, arg):
return arg

Expand Down
1 change: 1 addition & 0 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -5122,6 +5122,7 @@ def trim_join_unit(join_unit, length):


class JoinUnit(object):

def __init__(self, block, shape, indexers=None):
# Passing shape explicitly is required for cases when block is None.
if indexers is None:
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/nanops.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


class disallow(object):

def __init__(self, *dtypes):
super(disallow, self).__init__()
self.dtypes = tuple(np.dtype(dtype).type for dtype in dtypes)
Expand Down Expand Up @@ -58,6 +59,7 @@ def _f(*args, **kwargs):


class bottleneck_switch(object):

def __init__(self, zero_value=None, **kwargs):
self.zero_value = zero_value
self.kwargs = kwargs
Expand Down
2 changes: 2 additions & 0 deletions pandas/core/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -1560,6 +1560,7 @@ def f(self, other, axis=0):

# legacy
class WidePanel(Panel):

def __init__(self, *args, **kwargs):
# deprecation, #10892
warnings.warn("WidePanel is deprecated. Please use Panel",
Expand All @@ -1569,6 +1570,7 @@ def __init__(self, *args, **kwargs):


class LongPanel(DataFrame):

def __init__(self, *args, **kwargs):
# deprecation, #10892
warnings.warn("LongPanel is deprecated. Please use DataFrame",
Expand Down
1 change: 1 addition & 0 deletions pandas/core/series.py
Original file line number Diff line number Diff line change
Expand Up @@ -2987,6 +2987,7 @@ def create_from_value(value, index, dtype):

# backwards compatiblity
class TimeSeries(Series):

def __init__(self, *args, **kwargs):
# deprecation TimeSeries, #10890
warnings.warn("TimeSeries is deprecated. Please use Series",
Expand Down
3 changes: 2 additions & 1 deletion pandas/core/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -659,6 +659,7 @@ def f(x, name=name, *args):


class _Rolling(_Window):

@property
def _constructor(self):
return Rolling
Expand Down Expand Up @@ -1718,7 +1719,7 @@ def dataframe_from_int_dict(data, frame_template):

def _get_center_of_mass(com, span, halflife, alpha):
valid_count = len([x for x in [com, span, halflife, alpha]
if x is not None])
if x is not None])
if valid_count > 1:
raise ValueError("com, span, halflife, and alpha "
"are mutually exclusive")
Expand Down
Loading