Commits

Nathan Goldbaum  committed 4be7647

Updating following Matt's comments.

  • Participants
  • Parent commits 1b3974d

Comments (0)

Files changed (3)

File yt/data_objects/universal_fields.py

     n_tup = tuple([1 for i in range(positions.ndim-1)])
     center = np.tile(np.reshape(c, (positions.shape[0],)+n_tup),(1,)+positions.shape[1:])
     periodicity = data.pf.periodicity
-    if np.any(periodicity):
+    if any(periodicity):
         period = data.pf.domain_right_edge - data.pf.domain_left_edge
         return periodic_dist(positions, center, period, periodicity)
     else:

File yt/frontends/flash/data_structures.py

         self.current_time = self.parameters["time"]
 
         # Determine if this is a periodic box
-        self.periodicity = (self.parameters["xl_boundary_type"] == "periodic",)
-        if self.dimensionality > 1:
-            self.periodicity += (self.parameters["yl_boundary_type"] == "periodic",)
-        if self.dimensionality > 2:
-            self.periodicity += (self.parameters["zl_boundary_type"] == "periodic",)
+        p = [self.parameters.get("%sl_boundary_type" % ax, None) == Periodic for ax in 'xyz']
+        self.periodicity = tuple(p)
 
         # Determine cosmological parameters.
         try: 

File yt/utilities/math_utils.py

         period = np.reshape(period, (a.shape[0],)+(1,1))
 
     c = np.empty((2,) + a.shape, dtype="float64")
-    c[0,:] = abs(a - b)
+    c[0,:] = np.abs(a - b)
     
     p_directions = [i for i,p in enumerate(periodicity) if p == True]
     np_directions = [i for i,p in enumerate(periodicity) if p == False]
     for d in p_directions:
-        c[1,d,:] = period[d,:] - abs(a - b)[d,:]
+        c[1,d,:] = period[d,:] - np.abs(a - b)[d,:]
     for d in np_directions:
         c[1,d,:] = c[0,d,:]
 
     a = np.array(a)
     b = np.array(b)
     if a.shape != b.shape: RuntimeError("Arrays must be the same shape.")
-    c = np.empty(a.shape, dtype="float64")
-    c = (a - b)**2
-    return np.sqrt(c.sum(axis=0))
+    c = a.copy()
+    np.subtract(c, b, c)
+    np.power(c, 2, c)
+    c = c.sum(axis = 0)
+    if isinstance(c, np.ndarray):
+        np.sqrt(c, c)
+    else:
+        # This happens if a and b only have one entry.
+        c = math.sqrt(c)
+    return c
 
 def rotate_vector_3D(a, dim, angle):
     r"""Rotates the elements of an array around an axis by some angle.