[yt-svn] commit/yt: MatthewTurk: Merged in ChrisMalone/yt (pull request #1174)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Tue Sep 2 15:50:23 PDT 2014
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/75d65dcf2ce6/
Changeset: 75d65dcf2ce6
Branch: yt
User: MatthewTurk
Date: 2014-09-03 00:50:14
Summary: Merged in ChrisMalone/yt (pull request #1174)
add an epsilon check to selector
Affected #: 2 files
diff -r 4966afceaddf8602f20a7a95aa02afd17bfaca39 -r 75d65dcf2ce66eaed99eef42d56033844a137160 yt/data_objects/tests/test_slice.py
--- a/yt/data_objects/tests/test_slice.py
+++ b/yt/data_objects/tests/test_slice.py
@@ -34,6 +34,7 @@
def test_slice():
fns = []
+ grid_eps = np.finfo(np.float64).eps
for nprocs in [8, 1]:
# We want to test both 1 proc and 8 procs, to make sure that
# parallelism isn't broken
@@ -52,6 +53,7 @@
yax = ds.coordinates.y_axis[ax]
for wf in ["density", None]:
slc = ds.slice(ax, slc_pos)
+ shifted_slc = ds.slice(ax, slc_pos + grid_eps)
yield assert_equal, slc["ones"].sum(), slc["ones"].size
yield assert_equal, slc["ones"].min(), 1.0
yield assert_equal, slc["ones"].max(), 1.0
@@ -66,6 +68,7 @@
p.save(name=tmpname)
fns.append(tmpname)
frb = slc.to_frb((1.0, 'unitary'), 64)
+ shifted_frb = shifted_slc.to_frb((1.0, 'unitary'), 64)
for slc_field in ['ones', 'density']:
fi = ds._get_field_info(slc_field)
yield assert_equal, frb[slc_field].info['data_source'], \
@@ -84,6 +87,8 @@
slc.center
yield assert_equal, frb[slc_field].info['coord'], \
slc_pos
+ yield assert_equal, frb[slc_field], \
+ shifted_frb[slc_field]
# wf == None
yield assert_equal, wf, None
teardown_func(fns)
diff -r 4966afceaddf8602f20a7a95aa02afd17bfaca39 -r 75d65dcf2ce66eaed99eef42d56033844a137160 yt/geometry/selection_routines.pyx
--- a/yt/geometry/selection_routines.pyx
+++ b/yt/geometry/selection_routines.pyx
@@ -36,6 +36,10 @@
long int lrint(double x) nogil
double fabs(double x) nogil
+# use this as an epsilon test for grids aligned with selector
+# define here to avoid the gil later
+cdef np.float64_t grid_eps = np.finfo(np.float64).eps
+
# These routines are separated into a couple different categories:
#
# * Routines for identifying intersections of an object with a bounding box
@@ -111,20 +115,19 @@
self.min_level = getattr(dobj, "min_level", 0)
self.max_level = getattr(dobj, "max_level", 99)
self.overlap_cells = 0
-
- for i in range(3) :
- ds = getattr(dobj, 'ds', None)
- if ds is None:
- for i in range(3):
- # NOTE that this is not universal.
- self.domain_width[i] = 1.0
- self.periodicity[i] = False
- else:
- DLE = _ensure_code(ds.domain_left_edge)
- DRE = _ensure_code(ds.domain_right_edge)
- for i in range(3):
- self.domain_width[i] = DRE[i] - DLE[i]
- self.periodicity[i] = ds.periodicity[i]
+
+ ds = getattr(dobj, 'ds', None)
+ if ds is None:
+ for i in range(3):
+ # NOTE that this is not universal.
+ self.domain_width[i] = 1.0
+ self.periodicity[i] = False
+ else:
+ DLE = _ensure_code(ds.domain_left_edge)
+ DRE = _ensure_code(ds.domain_right_edge)
+ for i in range(3):
+ self.domain_width[i] = DRE[i] - DLE[i]
+ self.periodicity[i] = ds.periodicity[i]
@cython.boundscheck(False)
@cython.wraparound(False)
@@ -1017,7 +1020,7 @@
@cython.cdivision(True)
cdef int select_cell(self, np.float64_t pos[3], np.float64_t dds[3]) nogil:
if pos[self.axis] + 0.5*dds[self.axis] > self.coord \
- and pos[self.axis] - 0.5*dds[self.axis] <= self.coord:
+ and pos[self.axis] - 0.5*dds[self.axis] - grid_eps <= self.coord:
return 1
return 0
@@ -1039,7 +1042,7 @@
@cython.cdivision(True)
cdef int select_bbox(self, np.float64_t left_edge[3],
np.float64_t right_edge[3]) nogil:
- if left_edge[self.axis] <= self.coord < right_edge[self.axis]:
+ if left_edge[self.axis] - grid_eps <= self.coord < right_edge[self.axis]:
return 1
return 0
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