From: W. Trevor King Date: Tue, 31 Aug 2010 12:44:49 +0000 (-0400) Subject: Check data copying in Curve.__copy__ and .__deepcopy__ doctests. X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=fd370c0ef71a554fdc950305bb9eb418ca6805e0;p=hooke.git Check data copying in Curve.__copy__ and .__deepcopy__ doctests. --- diff --git a/hooke/curve.py b/hooke/curve.py index bc8138a..fc8701b 100644 --- a/hooke/curve.py +++ b/hooke/curve.py @@ -292,7 +292,12 @@ class Curve (object): >>> class Hooke (object): ... pass >>> h = Hooke() + >>> d = Data(shape=(3,2), info={'columns':['distance (m)', 'force (N)']}) + >>> for i in range(3): # initialize d + ... for j in range(2): + ... d[i,j] = i*10 + j >>> c = Curve(None) + >>> c.data = [d] >>> c.set_hooke(h) >>> c._hooke # doctest: +ELLIPSIS @@ -303,6 +308,14 @@ class Curve (object): >>> c2._hooke == h True + >>> c2.data + [Data([[ 0., 1.], + [ 10., 11.], + [ 20., 21.]])] + >>> d.info + {'columns': ['distance (m)', 'force (N)']} + >>> id(c2.data[0]) == id(d) + True """ copier = _copy_dispatch.get(type(self)) if copier: @@ -328,7 +341,12 @@ class Curve (object): >>> class Hooke (object): ... pass >>> h = Hooke() + >>> d = Data(shape=(3,2), info={'columns':['distance (m)', 'force (N)']}) + >>> for i in range(3): # initialize d + ... for j in range(2): + ... d[i,j] = i*10 + j >>> c = Curve(None) + >>> c.data = [d] >>> c.set_hooke(h) >>> c._hooke # doctest: +ELLIPSIS @@ -339,6 +357,14 @@ class Curve (object): >>> c2._hooke == h True + >>> c2.data + [Data([[ 0., 1.], + [ 10., 11.], + [ 20., 21.]])] + >>> d.info + {'columns': ['distance (m)', 'force (N)']} + >>> id(c2.data[0]) == id(d) + False """ reductor = dispatch_table.get(type(self)) if reductor: