Skip to content
This repository has been archived by the owner on Dec 11, 2023. It is now read-only.

Commit

Permalink
Merge pull request #170 from esc/vh/fix/copy_carray
Browse files Browse the repository at this point in the history
issue regarding deletion of moved columns
  • Loading branch information
esc committed Apr 19, 2015
2 parents 56dc09f + 42ec9a8 commit ac52154
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bcolz/ctable.py
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ def addcol(self, newcol, name=None, pos=None, move=False, **kwargs):
shutil.move(newcol.rootdir, col_rootdir)
newcol.rootdir = col_rootdir
else: # copy the the carray
shutil.copytree(newcol.rootdir, col_rootdir)
newcol = newcol.copy(rootdir=col_rootdir)
elif isinstance(newcol, (np.ndarray, bcolz.carray)):
newcol = bcolz.carray(newcol, **kwargs)
elif type(newcol) in (list, tuple):
Expand Down
5 changes: 4 additions & 1 deletion bcolz/tests/test_ctable.py
Original file line number Diff line number Diff line change
Expand Up @@ -435,12 +435,15 @@ def test_add_new_column_ondisk_other_carray_rootdir(self):
c = np.fromiter(("s%d" % i for i in xrange(N)), dtype='S2')
_, fn = tempfile.mkstemp()
os.remove(fn)
t.addcol(bcolz.carray(c, rootdir=fn), 'f2')
c = bcolz.carray(c, rootdir=fn)
t.addcol(c, 'f2')
ra = np.fromiter(((i, i * 2., "s%d" % i) for i in xrange(N)),
dtype='i4,f8,S2')
newpath = os.path.join(self.rootdir, 'f2')
assert_array_equal(t[:], ra, "ctable values are not correct")
assert_array_equal(bcolz.carray(rootdir=newpath)[:], ra['f2'])
self.assertEqual(fn, c.rootdir)
self.assertEqual(newpath, t['f2'].rootdir)


class getitemTest(MayBeDiskTest):
Expand Down

0 comments on commit ac52154

Please sign in to comment.