ondrolexa/apsg

Cluster class error

Closed this issue · 2 comments

Hi, Ondrej

I can't run following example from the tutorial:

g1 = Group.randn_lin(mean=Lin(45, 30))
g2 = Group.randn_lin(mean=Lin(320, 56))
g3 = Group.randn_lin(mean=Lin(150, 40))
g = g1 + g2 + g3
cl = Cluster(g)   # <==== error
cl.dendrogram(no_labels=True)

traceback:

AttributeError                            Traceback (most recent call last)
<ipython-input-14-90e135d9136a> in <module>()
----> 1 import codecs, os;__pyfile = codecs.open('''/tmp/py32407pTR''', encoding='''utf-8''');__code = __pyfile.read().encode('''utf-8''');__pyfile.close();os.remove('''/tmp/py32407pTR''');exec(compile(__code, '''/home/jw/work/apsg_tutorial.py''', 'exec'));

/home/jw/work/apsg_tutorial.py in <module>()
----> 1 # APSG defines several new python classes to easily manage, analyze and
      2 # visualize orientation structural geology data.Base class Vec3 is derived from
      3 # numpy.array class and offers several new method which will be explained in
      4 # following examples
      5 

/home/jw/.virtualenvs/scienv/lib/python2.7/site-packages/apsg/core.pyc in __init__(self, d, **kwargs)
   2069     def __init__(self, d, **kwargs):
   2070         assert isinstance(d, Group), 'Only group could be clustered'
-> 2071         self.data = Group(d.copy())
   2072         self.maxclust = kwargs.get('maxclust', 2)
   2073         self.angle = kwargs.get('angle', None)

/home/jw/.virtualenvs/scienv/lib/python2.7/site-packages/apsg/core.pyc in copy(self)
    856 
    857     def copy(self):
--> 858         return Group(super(Group, self).copy(), self.name)
    859 
    860     @property

AttributeError: 'super' object has no attribute 'copy'

System

Linux Mint 18.3
Python 2.7.12

scipy==1.0.1
numpy==1.14.2
matplotlib==2.2.2
apsg==0.5.1

I think that this is a bug, because Group inherits from list class, so super(Group, self).copy() will fail, because there is no `copy() method for the list class.

Yes, it is a bug, but only for Python 2.x as in Python 3 list has a copy method. Anyway, it is fixed in develop branch using deepcopy function.