[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [IMP-dev] [IMP-commits] r1102 - in trunk/kernel: doc/patch include pyext/IMP src test/particles



This patch needs the following added to the appropriate place to not break memory management.

+  %pythonprepend Particle::Particle %{
+        if len(args) >0: self.thisown=False
+  %}

Probably got lost somewhere in the patch process.


On Jan 5, 2009, at 11:43 AM, Notification of IMP commits wrote:

Author: 
Date: 2009-01-05 11:43:25 -0800 (Mon, 05 Jan 2009)
New Revision: 1102

Removed:
  trunk/kernel/doc/patch/particle_model.patch
  trunk/kernel/doc/patch/particle_model.readme
Modified:
  trunk/kernel/include/Particle.h
  trunk/kernel/pyext/IMP/test.py
  trunk/kernel/src/Particle.cpp
  trunk/kernel/test/particles/test_refcount.py
Log:
Patch from Daniel, with minor cleanup by me: add a constructor to Particle to
take a Model, and change a few tests to use this constructor.


Modified: trunk/kernel/include/Particle.h
===================================================================
--- trunk/kernel/include/Particle.h	2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/include/Particle.h	2009-01-05 19:43:25 UTC (rev 1102)
@@ -96,8 +96,9 @@

public:

+  //! Construct a particle and add it to the Model
+  Particle(Model *m);

-
  Particle();
  ~Particle();


Modified: trunk/kernel/pyext/IMP/test.py
===================================================================
--- trunk/kernel/pyext/IMP/test.py	2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/pyext/IMP/test.py	2009-01-05 19:43:25 UTC (rev 1102)
@@ -34,8 +34,7 @@
    def create_point_particle(self, model, x, y, z):
        """Make a particle with optimizable x, y and z attributes, and
           add it to the model."""
-        p = IMP.Particle()
-        model.add_particle(p)
+        p = IMP.Particle(model)
        p.add_attribute(IMP.FloatKey("x"), x, True)
        p.add_attribute(IMP.FloatKey("y"), y, True)
        p.add_attribute(IMP.FloatKey("z"), z, True)

Modified: trunk/kernel/src/Particle.cpp
===================================================================
--- trunk/kernel/src/Particle.cpp	2008-12-31 00:40:19 UTC (rev 1101)
+++ trunk/kernel/src/Particle.cpp	2009-01-05 19:43:25 UTC (rev 1102)
@@ -11,6 +11,13 @@

IMP_BEGIN_NAMESPACE

+Particle::Particle(Model *m)
+{
+  is_active_ = true;
+  m->add_particle(this);
+}
+
+
Particle::Particle()
{
  is_active_ = true;

Modified: trunk/kernel/test/particles/test_refcount.py
===================================================================
--- trunk/kernel/test/particles/test_refcount.py 2008-12-31 00:40:19 UTC (rev 1101) +++ trunk/kernel/test/particles/test_refcount.py 2009-01-05 19:43:25 UTC (rev 1102)
@@ -34,8 +34,7 @@
        self._check_number(0)

        m= IMP.Model()
-        p= IMP.Particle()
-        m.add_particle(p)
+        p= IMP.Particle(m)
        self._check_number(1)

        p=1
@@ -47,8 +46,8 @@
        """Check that ref counting works with removing particles"""
        self._check_number(0)
        m= IMP.Model()
-        p= IMP.Particle()
-        pi= m.add_particle(p)
+        p= IMP.Particle(m)
+        pi= p.get_index()
        self._check_number(1)
        m.remove_particle(pi)
        self._check_number(1)
@@ -86,10 +85,10 @@
        self._check_number(0)
        m= IMP.Model()
        print 7
-        p= IMP.Particle()
+        p= IMP.Particle(m)
        print p
        print 8
-        pi= m.add_particle(p)
+        pi= p.get_index()
        print 9
        p=None
        self._check_number(1)
@@ -141,8 +140,8 @@
        """Check that removed particles are skipped"""
        print "skipped"
        m= IMP.Model()
-        p= IMP.Particle()
-        pi= m.add_particle(p)
+        p= IMP.Particle(m)
+        pi= p.get_index()
        ps= m.get_particles()
        self.assertEqual(len(ps), 1, "Should only be 1 particle")
        m.remove_particle(pi)

_______________________________________________
IMP-commits mailing list

https://salilab.org/mailman/listinfo/imp-commits