Fixed segment rawdata copy for non-indexed segments

This commit is contained in:
Rob McMullen 2017-03-12 21:46:24 -07:00
parent bd4ff9569a
commit bdf0b67075
2 changed files with 16 additions and 9 deletions

View File

@ -228,8 +228,8 @@ class SegmentData(object):
s = self.style.np_data.copy()
copy = SegmentData(d, s, order=self.order)
else:
d = self.data
s = self.style
d = self.data.copy()
s = self.style.copy()
start, end = self.byte_bounds_offset()
copy = SegmentData(d[start:end], s[start:end])
return copy

View File

@ -38,10 +38,17 @@ class TestSegment1(object):
def test_copy(self):
for s in self.segments:
c = s.rawdata.copy()
print c.data.shape, c.is_indexed
print c.data.np_data, s.data.np_data
assert np.all((c.data - s.data) == 0)
d = s.rawdata
print "orig:", d.data.shape, d.is_indexed, d.data, id(d.data)
c = d.copy()
print "copy", c.data.shape, c.is_indexed, c.data, id(c.data)
assert c.data.shape == s.data.shape
assert id(c) != id(s)
assert np.all((c.data[:] - s.data[:]) == 0)
c.data[0:100] = 1
print d.data
print c.data
assert not np.all((c.data[:] - s.data[:]) == 0)
class TestIndexed(object):
@ -180,7 +187,7 @@ if __name__ == "__main__":
t.test_indexed()
t.test_indexed_sub()
t.test_interleave()
#t = TestSegment1()
#t.setup()
#t.test_xex()
t = TestSegment1()
t.setup()
t.test_xex()
t.test_copy()