Introduction
Introduction Statistics Contact Development Disclaimer Help
tallow selection of several particles in i - sphere - GPU-based 3D discrete ele…
git clone git://src.adamsgaard.dk/sphere
Log
Files
Refs
LICENSE
---
commit a9b29db26630b8d195836748f6e4440f02195224
parent 6e0ae86edd96ea60957e2e2e8c8c140b45c130fb
Author: Anders Damsgaard <[email protected]>
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(-)
---
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)
You are viewing proxied material from mx1.adamsgaard.dk. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.