Skip to content

Commit 04a6815

Browse files
jbrockmendeljreback
authored andcommitted
put mgr_locs setter next to property definition (#19264)
1 parent 3db6f66 commit 04a6815

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

pandas/core/internals.py

+8-9
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,13 @@ def fill_value(self):
191191
def mgr_locs(self):
192192
return self._mgr_locs
193193

194+
@mgr_locs.setter
195+
def mgr_locs(self, new_mgr_locs):
196+
if not isinstance(new_mgr_locs, BlockPlacement):
197+
new_mgr_locs = BlockPlacement(new_mgr_locs)
198+
199+
self._mgr_locs = new_mgr_locs
200+
194201
@property
195202
def array_dtype(self):
196203
""" the dtype to return if I want to construct this block as an
@@ -224,13 +231,6 @@ def make_block_same_class(self, values, placement=None, fastpath=True,
224231
return make_block(values, placement=placement, klass=self.__class__,
225232
fastpath=fastpath, **kwargs)
226233

227-
@mgr_locs.setter
228-
def mgr_locs(self, new_mgr_locs):
229-
if not isinstance(new_mgr_locs, BlockPlacement):
230-
new_mgr_locs = BlockPlacement(new_mgr_locs)
231-
232-
self._mgr_locs = new_mgr_locs
233-
234234
def __unicode__(self):
235235

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

841841
transf = (lambda x: x.T) if self.ndim == 2 else (lambda x: x)
842842
values = transf(values)
843-
l = len(values)
844843

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

858-
if is_list_like(value) and l:
857+
if is_list_like(value) and len(values):
859858
if len(value) != length_of_indexer(indexer, values):
860859
raise ValueError("cannot set using a slice indexer with a "
861860
"different length than the value")

0 commit comments

Comments
 (0)