Skip to content

CLN: put mgr_locs setter next to property definition #19264

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
Jan 17, 2018
Merged
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
17 changes: 8 additions & 9 deletions pandas/core/internals.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,13 @@ def fill_value(self):
def mgr_locs(self):
return self._mgr_locs

@mgr_locs.setter
def mgr_locs(self, new_mgr_locs):
if not isinstance(new_mgr_locs, BlockPlacement):
new_mgr_locs = BlockPlacement(new_mgr_locs)

self._mgr_locs = new_mgr_locs

@property
def array_dtype(self):
""" the dtype to return if I want to construct this block as an
Expand Down Expand Up @@ -224,13 +231,6 @@ def make_block_same_class(self, values, placement=None, fastpath=True,
return make_block(values, placement=placement, klass=self.__class__,
fastpath=fastpath, **kwargs)

@mgr_locs.setter
def mgr_locs(self, new_mgr_locs):
if not isinstance(new_mgr_locs, BlockPlacement):
new_mgr_locs = BlockPlacement(new_mgr_locs)

self._mgr_locs = new_mgr_locs

def __unicode__(self):

# don't want to print out all of the items here
Expand Down Expand Up @@ -840,7 +840,6 @@ def setitem(self, indexer, value, mgr=None):

transf = (lambda x: x.T) if self.ndim == 2 else (lambda x: x)
values = transf(values)
l = len(values)

# length checking
# boolean with truth values == len of the value is ok too
Expand All @@ -855,7 +854,7 @@ def setitem(self, indexer, value, mgr=None):
# slice
elif isinstance(indexer, slice):

if is_list_like(value) and l:
if is_list_like(value) and len(values):
if len(value) != length_of_indexer(indexer, values):
raise ValueError("cannot set using a slice indexer with a "
"different length than the value")
Expand Down