From 7f72817565b9522aa5927499e14296fc6eed244e Mon Sep 17 00:00:00 2001 From: Valentin Haenel Date: Sun, 29 Mar 2015 17:58:18 +0200 Subject: [PATCH 1/2] expose issue #170 via test --- bcolz/tests/test_ctable.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bcolz/tests/test_ctable.py b/bcolz/tests/test_ctable.py index 3602e643..c0243dff 100644 --- a/bcolz/tests/test_ctable.py +++ b/bcolz/tests/test_ctable.py @@ -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): From 42ec9a8adf5782db2daa33c73e7631b635378c10 Mon Sep 17 00:00:00 2001 From: Valentin Haenel Date: Sun, 29 Mar 2015 17:58:39 +0200 Subject: [PATCH 2/2] fix issue --- bcolz/ctable.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bcolz/ctable.py b/bcolz/ctable.py index 3cb4ee5e..2813b645 100644 --- a/bcolz/ctable.py +++ b/bcolz/ctable.py @@ -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):