[yt-svn] commit/yt: ngoldbaum: Merged in MatthewTurk/yt (pull request #1818)
commits-noreply at bitbucket.org
commits-noreply at bitbucket.org
Mon Oct 26 11:47:36 PDT 2015
1 new commit in yt:
https://bitbucket.org/yt_analysis/yt/commits/75c9b92eb87a/
Changeset: 75c9b92eb87a
Branch: yt
User: ngoldbaum
Date: 2015-10-26 18:47:21+00:00
Summary: Merged in MatthewTurk/yt (pull request #1818)
Adding grid_arrays to grid_container
Affected #: 6 files
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/grid_container.pxd
--- a/yt/geometry/grid_container.pxd
+++ b/yt/geometry/grid_container.pxd
@@ -21,7 +21,8 @@
from libc.math cimport nearbyint, rint
from yt.geometry.selection_routines cimport SelectorObject, _ensure_code
from yt.utilities.lib.fp_utils cimport iclip
-from grid_visitors cimport GridTreeNode, GridVisitorData, grid_visitor_function
+from grid_visitors cimport GridTreeNode, GridVisitorData, \
+ grid_visitor_function, GridTreeNodePadded
cimport grid_visitors
from yt.utilities.lib.bitarray cimport bitarray
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/grid_container.pyx
--- a/yt/geometry/grid_container.pyx
+++ b/yt/geometry/grid_container.pyx
@@ -124,6 +124,31 @@
children.append(childs)
return indices, levels, nchild, children
+ @property
+ def grid_arrays(self):
+ cdef GridTreeNodePadded[:] grids
+ grids = <GridTreeNodePadded[:self.num_grids]> \
+ (<GridTreeNodePadded*> self.grids)
+ grids_basic = np.asarray(grids)
+ # This next bit is necessary because as of 0.23.4, Cython can't make
+ # nested dtypes automatically where you have a property that is
+ # something like float[3]. So we unroll all of those, then re-roll
+ # them in a new dtype.
+ dtn = {}
+ dt = grids_basic.dtype
+ for name in dt.names:
+ d, o = dt.fields[name]
+ n = name
+ if name.endswith("_x"):
+ f = (d.char, 3)
+ n = name[:-2]
+ elif name.endswith("_y") or name.endswith("_z"):
+ continue
+ else:
+ f = (d.char, 1)
+ dtn[n] = (f, o)
+ return grids_basic.view(dtype=np.dtype(dtn))
+
cdef void setup_data(self, GridVisitorData *data):
# Being handed a new GVD object, we initialize it to sane defaults.
data.index = 0
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/grid_visitors.pxd
--- a/yt/geometry/grid_visitors.pxd
+++ b/yt/geometry/grid_visitors.pxd
@@ -27,6 +27,27 @@
int dims[3]
np.float64_t dds[3]
+cdef struct GridTreeNodePadded:
+ int num_children
+ int level
+ long int index
+ double left_edge_x
+ double left_edge_y
+ double left_edge_z
+ double right_edge_x
+ double right_edge_y
+ double right_edge_z
+ long int children_pointers
+ long int start_index_x
+ long int start_index_y
+ long int start_index_z
+ int dims_x
+ int dims_y
+ int dims_z
+ double dds_x
+ double dds_y
+ double dds_z
+
cdef struct GridVisitorData:
GridTreeNode *grid
np.uint64_t index
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/oct_container.pyx
--- a/yt/geometry/oct_container.pyx
+++ b/yt/geometry/oct_container.pyx
@@ -20,6 +20,7 @@
from selection_routines cimport SelectorObject
from libc.math cimport floor
cimport selection_routines
+from yt.geometry.oct_visitors cimport OctPadded
ORDER_MAX = 20
_ORDER_MAX = ORDER_MAX
@@ -109,6 +110,19 @@
for k in range(self.nn[2]):
self.root_mesh[i][j][k] = NULL
+ @property
+ def oct_arrays(self):
+ cdef OctAllocationContainer *cur = self.cont
+ cdef Oct *this
+ cdef int i
+ cdef OctPadded[:] mm
+ rv = []
+ while cur != NULL:
+ mm = <OctPadded[:cur.n_assigned]> (<OctPadded*> cur.my_octs)
+ rv.append(np.asarray(mm))
+ cur = cur.next
+ return rv
+
@classmethod
def load_octree(cls, header):
cdef np.ndarray[np.uint8_t, ndim=1] ref_mask
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/oct_visitors.pxd
--- a/yt/geometry/oct_visitors.pxd
+++ b/yt/geometry/oct_visitors.pxd
@@ -24,6 +24,12 @@
np.int64_t domain # (opt) addl int index
Oct **children # Up to 8 long
+cdef struct OctPadded:
+ np.int64_t file_ind
+ np.int64_t domain_ind
+ np.int64_t domain
+ np.int64_t padding
+
cdef struct OctVisitorData:
np.uint64_t index
np.uint64_t last
diff -r 2096df33b692550e8090b58bf31da407b35cc2dd -r 75c9b92eb87a6e379461548c23f3b3902fa2b666 yt/geometry/tests/test_grid_container.py
--- a/yt/geometry/tests/test_grid_container.py
+++ b/yt/geometry/tests/test_grid_container.py
@@ -116,3 +116,12 @@
# Test if find_points fails properly for non equal indices' array sizes
yield assert_raises, AssertionError, test_ds.index._find_points, \
[0], 1.0, [2, 3]
+
+def test_grid_arrays_view():
+ ds = setup_test_ds()
+ tree = ds.index._get_grid_tree()
+ grid_arr = tree.grid_arrays
+ yield assert_equal, grid_arr['left_edge'], ds.index.grid_left_edge
+ yield assert_equal, grid_arr['right_edge'], ds.index.grid_right_edge
+ yield assert_equal, grid_arr['dims'], ds.index.grid_dimensions
+ yield assert_equal, grid_arr['level'], ds.index.grid_levels[:,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