Skip to content

BUG: Fix argument order in call to super #12924

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
2 changes: 1 addition & 1 deletion pandas/core/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def __sizeof__(self):

# no memory_usage attribute, so fall back to
# object's 'sizeof'
return super(self, PandasObject).__sizeof__()
return super(PandasObject, self).__sizeof__()


class NoNewAttributesMixin(object):
Expand Down
62 changes: 36 additions & 26 deletions pandas/tests/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -147,42 +147,46 @@ def test_values(self):

class TestPandasDelegate(tm.TestCase):

def setUp(self):
pass
class Delegator(object):
_properties = ['foo']
_methods = ['bar']

def test_invalida_delgation(self):
# these show that in order for the delegation to work
# the _delegate_* methods need to be overriden to not raise a TypeError
def _set_foo(self, value):
self.foo = value

class Delegator(object):
_properties = ['foo']
_methods = ['bar']
def _get_foo(self):
return self.foo

def _set_foo(self, value):
self.foo = value
foo = property(_get_foo, _set_foo, doc="foo property")

def _get_foo(self):
return self.foo
def bar(self, *args, **kwargs):
""" a test bar method """
pass

foo = property(_get_foo, _set_foo, doc="foo property")
class Delegate(PandasDelegate):

def bar(self, *args, **kwargs):
""" a test bar method """
pass
def __init__(self, obj):
self.obj = obj

class Delegate(PandasDelegate):
def setUp(self):
pass

def __init__(self, obj):
self.obj = obj
def test_invalida_delgation(self):
# these show that in order for the delegation to work
# the _delegate_* methods need to be overriden to not raise a TypeError

Delegate._add_delegate_accessors(delegate=Delegator,
accessors=Delegator._properties,
typ='property')
Delegate._add_delegate_accessors(delegate=Delegator,
accessors=Delegator._methods,
typ='method')
self.Delegate._add_delegate_accessors(
delegate=self.Delegator,
accessors=self.Delegator._properties,
typ='property'
)
self.Delegate._add_delegate_accessors(
delegate=self.Delegator,
accessors=self.Delegator._methods,
typ='method'
)

delegate = Delegate(Delegator())
delegate = self.Delegate(self.Delegator())

def f():
delegate.foo
Expand All @@ -199,6 +203,12 @@ def f():

self.assertRaises(TypeError, f)

def test_memory_usage(self):
# Delegate does not implement memory_usage.
# Check that we fall back to in-built `__sizeof__`
delegate = self.Delegate(self.Delegator())
sys.getsizeof(delegate)


class Ops(tm.TestCase):

Expand Down