tallow selection of several particles in i - sphere - GPU-based 3D discrete element method algorithm with optional fluid coupling
 (HTM) git clone git://src.adamsgaard.dk/sphere
 (DIR) Log
 (DIR) Files
 (DIR) Refs
 (DIR) LICENSE
       ---
 (DIR) commit a9b29db26630b8d195836748f6e4440f02195224
 (DIR) parent 6e0ae86edd96ea60957e2e2e8c8c140b45c130fb
 (HTM) Author: Anders Damsgaard <anders.damsgaard@geo.au.dk>
       Date:   Thu, 25 Sep 2014 09:52:27 +0200
       
       allow selection of several particles in i
       
       Diffstat:
         M python/sphere.py                    |      23 +++++++++++++++++++----
       
       1 file changed, 19 insertions(+), 4 deletions(-)
       ---
 (DIR) diff --git a/python/sphere.py b/python/sphere.py
       t@@ -709,13 +709,28 @@ class sim:
        
            def deleteParticle(self, i):
                '''
       -        Delete particle with index ``i``.
       +        Delete particle(s) with index ``i``.
        
       -        :param i: Particle index to delete
       -        :type i: int
       +        :param i: One or more particle indexes to delete
       +        :type i: int, list or numpy.array
                '''
        
       -        self.np = self.np - 1
       +        # The user wants to delete several particles, indexes in a numpy.array
       +        if type(i) == numpy.ndarray:
       +            self.np -= i.size
       +
       +        # The user wants to delete several particles, indexes in a Python list
       +        elif type(i) == list:
       +            self.np -= len(i)
       +
       +        # The user wants to delete a single particle with a integer index
       +        else:
       +            self.np -= 1
       +
       +        if type(i) == tuple:
       +            raise Exception('Cannot parse tuples as index value. ' +
       +                    'Valid types are int, list and numpy.ndarray')
       +
        
                self.x      = numpy.delete(self.x, i, axis=0)
                self.radius = numpy.delete(self.radius, i)