[yt-svn] commit/yt: 3 new changesets

Bitbucket commits-noreply at bitbucket.org
Tue Feb 19 04:42:03 PST 2013


3 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/66cd765ab199/
changeset:   66cd765ab199
branch:      yt
user:        jzuhone
date:        2013-02-16 19:10:03
summary:     Small improvements to the particle generator that I had thought had already been committed, but it turns out they weren't. The notebook at http://blog.yt-project.org/post/ParticleGenerator.html actually assumed these changes(!)

1) The caller no longer has to specify "particle_index" as a field; it is added to the field list automatically by __init__.
2) "ParticleIndices" has been changed to "ParticleGridIndices" to avoid confusion with the "particle_index" field
3) Slight modification to the determination if a particle is in a grid or not, for positions that are exactly on a grid boundary.
affected #:  2 files

diff -r 9823f77dfcbbb2c286da9cc872d63d06a1791a6a -r 66cd765ab1991d32db1c4158d3cea3142d8d5104 setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,9 +1,3 @@
 [egg_info]
 #tag_build = .dev
 #tag_svn_revision = 1
-
-[nosetests]
-detailed-errors=1
-where=yt
-exclude=answer_testing
-with-xunit=1

diff -r 9823f77dfcbbb2c286da9cc872d63d06a1791a6a -r 66cd765ab1991d32db1c4158d3cea3142d8d5104 yt/utilities/particle_generator.py
--- a/yt/utilities/particle_generator.py
+++ b/yt/utilities/particle_generator.py
@@ -7,9 +7,8 @@
 
     default_fields = ["particle_position_x",
                       "particle_position_y",
-                      "particle_position_z",
-                      "particle_index"]
-
+                      "particle_position_z"]
+    
     def __init__(self, pf, num_particles, field_list) :
         """
         Base class for generating particle fields which may be applied to
@@ -21,20 +20,21 @@
         self.pf = pf
         self.num_particles = num_particles
         self.field_list = field_list
-            
+        self.field_list.append("particle_index")
+        
         try :
             self.posx_index = self.field_list.index(self.default_fields[0])
             self.posy_index = self.field_list.index(self.default_fields[1])
             self.posz_index = self.field_list.index(self.default_fields[2])
-            self.index_index = self.field_list.index(self.default_fields[3])
         except :
             raise KeyError("Field list must contain the following fields: " +
                            "\'particle_position_x\', \'particle_position_y\'" +
-                           ", \'particle_position_z\', \'particle_index\' ")
-
+                           ", \'particle_position_z\' ")
+        self.index_index = self.field_list.index("particle_index")
+        
         self.num_grids = self.pf.h.num_grids
         self.NumberOfParticles = np.zeros((self.num_grids), dtype='int64')
-        self.ParticleIndices = np.zeros(self.num_grids + 1, dtype='int64')
+        self.ParticleGridIndices = np.zeros(self.num_grids + 1, dtype='int64')
         
         self.num_fields = len(self.field_list)
         
@@ -78,8 +78,8 @@
         Return a dict containing all of the particle fields in the specified grid.
         """
         ind = grid.id-grid._id_offset
-        start = self.ParticleIndices[ind]
-        end = self.ParticleIndices[ind+1]
+        start = self.ParticleGridIndices[ind]
+        end = self.ParticleGridIndices[ind+1]
         return dict([(field, self.particles[start:end,self.field_list.index(field)])
                      for field in self.field_list])
     
@@ -97,9 +97,9 @@
                                              minlength=self.num_grids)
         if self.num_grids > 1 :
             np.add.accumulate(self.NumberOfParticles.squeeze(),
-                              out=self.ParticleIndices[1:])
+                              out=self.ParticleGridIndices[1:])
         else :
-            self.ParticleIndices[1] = self.NumberOfParticles.squeeze()
+            self.ParticleGridIndices[1] = self.NumberOfParticles.squeeze()
         if setup_fields is not None:
             for key, value in setup_fields.items():
                 if key not in self.default_fields:
@@ -130,8 +130,8 @@
         for i, grid in enumerate(self.pf.h.grids) :
             pbar.update(i)
             if self.NumberOfParticles[i] > 0:
-                start = self.ParticleIndices[i]
-                end = self.ParticleIndices[i+1]
+                start = self.ParticleGridIndices[i]
+                end = self.ParticleGridIndices[i+1]
                 # Note we add one ghost zone to the grid!
                 cube = grid.retrieve_ghost_zones(1, mapping_dict.keys())
                 le = np.array(grid.LeftEdge).astype(np.float64)
@@ -216,11 +216,11 @@
         y = data.pop("particle_position_y")
         z = data.pop("particle_position_z")
 
-        xcond = np.logical_or(x < pf.domain_left_edge[0],
+        xcond = np.logical_or(x <= pf.domain_left_edge[0],
                               x >= pf.domain_right_edge[0])
-        ycond = np.logical_or(y < pf.domain_left_edge[1],
+        ycond = np.logical_or(y <= pf.domain_left_edge[1],
                               y >= pf.domain_right_edge[1])
-        zcond = np.logical_or(z < pf.domain_left_edge[2],
+        zcond = np.logical_or(z <= pf.domain_left_edge[2],
                               z >= pf.domain_right_edge[2])
         cond = np.logical_or(xcond, ycond)
         cond = np.logical_or(zcond, cond)
@@ -257,7 +257,7 @@
         >>> le = np.array([0.25,0.25,0.25])
         >>> re = np.array([0.75,0.75,0.75])
         >>> fields = ["particle_position_x","particle_position_y",
-        >>>           "particle_position_z","particle_index",
+        >>>           "particle_position_z",
         >>>           "particle_density","particle_temperature"]
         >>> particles = LatticeParticleGenerator(pf, dims, le, re, fields)
         """
@@ -272,11 +272,11 @@
         ymax = particles_right_edge[1]
         zmax = particles_right_edge[2]
 
-        xcond = (xmin < pf.domain_left_edge[0]) or \
+        xcond = (xmin <= pf.domain_left_edge[0]) or \
                 (xmax >= pf.domain_right_edge[0])
-        ycond = (ymin < pf.domain_left_edge[1]) or \
+        ycond = (ymin <= pf.domain_left_edge[1]) or \
                 (ymax >= pf.domain_right_edge[1])
-        zcond = (zmin < pf.domain_left_edge[2]) or \
+        zcond = (zmin <= pf.domain_left_edge[2]) or \
                 (zmax >= pf.domain_right_edge[2])
         cond = xcond or ycond or zcond
 
@@ -321,7 +321,7 @@
         >>> sphere = pf.h.sphere(pf.domain_center, 0.5)
         >>> num_p = 100000
         >>> fields = ["particle_position_x","particle_position_y",
-        >>>           "particle_position_z","particle_index",
+        >>>           "particle_position_z",
         >>>           "particle_density","particle_temperature"]
         >>> particles = WithDensityParticleGenerator(pf, sphere, num_particles,
         >>>                                          fields, density_field='Dark_Matter_Density')


https://bitbucket.org/yt_analysis/yt/commits/52890207a3ad/
changeset:   52890207a3ad
branch:      yt
user:        jzuhone
date:        2013-02-16 19:10:23
summary:     Shouldn't change this
affected #:  1 file

diff -r 66cd765ab1991d32db1c4158d3cea3142d8d5104 -r 52890207a3adceb3efd4165b0f63caf19702d05b setup.cfg
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,3 +1,9 @@
 [egg_info]
 #tag_build = .dev
 #tag_svn_revision = 1
+
+[nosetests]
+detailed-errors=1
+where=yt
+exclude=answer_testing
+with-xunit=1


https://bitbucket.org/yt_analysis/yt/commits/5fb26616584a/
changeset:   5fb26616584a
branch:      yt
user:        jzuhone
date:        2013-02-17 18:20:56
summary:     Really should look at the code I'm commiting before I claim I know what it does. The previous change did not have to do with the relationship of particles to grids, but had to do with a check of whether or not the particles were inside the domain.

The right behavior should be that particles are counted as within the domain if their position is greater than or equal to the domain left edge and less than the domain right edge, which is the same behavior as for grids.
affected #:  1 file

diff -r 52890207a3adceb3efd4165b0f63caf19702d05b -r 5fb26616584a5c034777c945f5bdba7c62872f0d yt/utilities/particle_generator.py
--- a/yt/utilities/particle_generator.py
+++ b/yt/utilities/particle_generator.py
@@ -216,11 +216,11 @@
         y = data.pop("particle_position_y")
         z = data.pop("particle_position_z")
 
-        xcond = np.logical_or(x <= pf.domain_left_edge[0],
+        xcond = np.logical_or(x < pf.domain_left_edge[0],
                               x >= pf.domain_right_edge[0])
-        ycond = np.logical_or(y <= pf.domain_left_edge[1],
+        ycond = np.logical_or(y < pf.domain_left_edge[1],
                               y >= pf.domain_right_edge[1])
-        zcond = np.logical_or(z <= pf.domain_left_edge[2],
+        zcond = np.logical_or(z < pf.domain_left_edge[2],
                               z >= pf.domain_right_edge[2])
         cond = np.logical_or(xcond, ycond)
         cond = np.logical_or(zcond, cond)
@@ -272,11 +272,11 @@
         ymax = particles_right_edge[1]
         zmax = particles_right_edge[2]
 
-        xcond = (xmin <= pf.domain_left_edge[0]) or \
+        xcond = (xmin < pf.domain_left_edge[0]) or \
                 (xmax >= pf.domain_right_edge[0])
-        ycond = (ymin <= pf.domain_left_edge[1]) or \
+        ycond = (ymin < pf.domain_left_edge[1]) or \
                 (ymax >= pf.domain_right_edge[1])
-        zcond = (zmin <= pf.domain_left_edge[2]) or \
+        zcond = (zmin < pf.domain_left_edge[2]) or \
                 (zmax >= pf.domain_right_edge[2])
         cond = xcond or ycond or zcond

Repository URL: https://bitbucket.org/yt_analysis/yt/

--

This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.



More information about the yt-svn mailing list