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

commits-noreply at bitbucket.org commits-noreply at bitbucket.org
Wed Jun 14 14:14:46 PDT 2017


2 new commits in yt:

https://bitbucket.org/yt_analysis/yt/commits/bbce7672522d/
Changeset:   bbce7672522d
User:        ngoldbaum
Date:        2017-05-29 16:30:11+00:00
Summary:     remove unused kdtree and parallel components from grid_traversal.pyx
Affected #:  8 files

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd setup.py
--- a/setup.py
+++ b/setup.py
@@ -154,14 +154,10 @@
               depends=["yt/utilities/lib/origami_tags.h"]),
     Extension("yt.utilities.lib.grid_traversal",
               ["yt/utilities/lib/grid_traversal.pyx",
-               "yt/utilities/lib/fixed_interpolator.c",
-               "yt/utilities/lib/kdtree.c"],
+               "yt/utilities/lib/fixed_interpolator.c"],
               include_dirs=["yt/utilities/lib/"],
               libraries=std_libs,
-              extra_compile_args=omp_args,
-              extra_link_args=omp_args,
-              depends=["yt/utilities/lib/kdtree.h",
-                       "yt/utilities/lib/fixed_interpolator.h"]),
+              depends=["yt/utilities/lib/fixed_interpolator.h"]),
     Extension("yt.utilities.lib.image_samplers",
               ["yt/utilities/lib/image_samplers.pyx",
                "yt/utilities/lib/fixed_interpolator.c"],

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/grid_traversal.pyx
--- a/yt/utilities/lib/grid_traversal.pyx
+++ b/yt/utilities/lib/grid_traversal.pyx
@@ -26,8 +26,6 @@
     FIT_eval_transfer_with_light
 from fixed_interpolator cimport *
 
-from cython.parallel import prange, parallel, threadid
-
 DEF Nch = 4
 
 @cython.boundscheck(False)

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/image_samplers.pxd
--- a/yt/utilities/lib/image_samplers.pxd
+++ b/yt/utilities/lib/image_samplers.pxd
@@ -17,7 +17,6 @@
 import numpy as np
 cimport numpy as np
 cimport cython
-cimport kdtree_utils
 from .volume_container cimport VolumeContainer
 from .partitioned_grid cimport PartitionedGrid
 
@@ -85,7 +84,6 @@
     cdef VolumeRenderAccumulator *vra
     cdef public object tf_obj
     cdef public object my_field_tables
-    cdef kdtree_utils.kdtree **trees
     cdef object tree_containers
 
 cdef class LightSourceRenderSampler(ImageSampler):

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/image_samplers.pyx
--- a/yt/utilities/lib/image_samplers.pyx
+++ b/yt/utilities/lib/image_samplers.pyx
@@ -51,7 +51,6 @@
     np.float64_t star_coeff
     np.float64_t star_er
     np.float64_t star_sigma_num
-    kdtree_utils.kdtree *star_list
     np.float64_t *light_dir
     np.float64_t *light_rgba
     int grey_opacity
@@ -295,7 +294,7 @@
                   np.ndarray[np.float64_t, ndim=1] y_vec,
                   np.ndarray[np.float64_t, ndim=1] width,
                   tf_obj, n_samples = 10,
-                  star_list = None, **kwargs):
+                  **kwargs):
         ImageSampler.__init__(self, vp_pos, vp_dir, center, bounds, image,
                                x_vec, y_vec, width, **kwargs)
         cdef int i

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/kdtree.c
--- a/yt/utilities/lib/kdtree.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
-This file is part of ``kdtree'', a library for working with kd-trees.
-Copyright (C) 2007-2011 John Tsiombikas <nuclear at siggraph.org>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-*/
-/* single nearest neighbor search written by Tamas Nepusz <tamas at cs.rhul.ac.uk> */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "kdtree.h"
-
-#ifdef MS_WIN32
-#include <malloc.h>
-#endif
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
-#else
-
-#ifndef I_WANT_THREAD_BUGS
-#error "You are compiling with the fast list node allocator, with pthreads disabled! This WILL break if used from multiple threads."
-#endif	/* I want thread bugs */
-
-#endif	/* pthread support */
-#endif	/* use list node allocator */
-
-struct kdhyperrect {
-	int dim;
-	npy_float64 *min, *max;              /* minimum/maximum coords */
-};
-
-struct kdnode {
-	npy_float64 *pos;
-	int dir;
-	void *data;
-
-	struct kdnode *left, *right;	/* negative/positive side */
-};
-
-struct res_node {
-	struct kdnode *item;
-	npy_float64 dist_sq;
-	struct res_node *next;
-};
-
-struct kdtree {
-	int dim;
-	struct kdnode *root;
-	struct kdhyperrect *rect;
-	void (*destr)(void*);
-};
-
-struct kdres {
-	struct kdtree *tree;
-	struct res_node *rlist, *riter;
-	int size;
-};
-
-#define SQ(x)			((x) * (x))
-
-
-static void clear_rec(struct kdnode *node, void (*destr)(void*));
-static int insert_rec(struct kdnode **node, const npy_float64 *pos, void *data, int dir, int dim);
-static int rlist_insert(struct res_node *list, struct kdnode *item, npy_float64 dist_sq);
-static void clear_results(struct kdres *set);
-
-static struct kdhyperrect* hyperrect_create(int dim, const npy_float64 *min, const npy_float64 *max);
-static void hyperrect_free(struct kdhyperrect *rect);
-static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect);
-static void hyperrect_extend(struct kdhyperrect *rect, const npy_float64 *pos);
-static npy_float64 hyperrect_dist_sq(struct kdhyperrect *rect, const npy_float64 *pos);
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-static struct res_node *alloc_resnode(void);
-static void free_resnode(struct res_node*);
-#else
-#define alloc_resnode()		malloc(sizeof(struct res_node))
-#define free_resnode(n)		free(n)
-#endif
-
-
-
-struct kdtree *kd_create(int k)
-{
-	struct kdtree *tree;
-
-	if(!(tree = malloc(sizeof *tree))) {
-		return 0;
-	}
-
-	tree->dim = k;
-	tree->root = 0;
-	tree->destr = 0;
-	tree->rect = 0;
-
-	return tree;
-}
-
-void kd_free(struct kdtree *tree)
-{
-	if(tree) {
-		kd_clear(tree);
-		free(tree);
-	}
-}
-
-static void clear_rec(struct kdnode *node, void (*destr)(void*))
-{
-	if(!node) return;
-
-	clear_rec(node->left, destr);
-	clear_rec(node->right, destr);
-	
-	if(destr) {
-		destr(node->data);
-	}
-	free(node->pos);
-	free(node);
-}
-
-void kd_clear(struct kdtree *tree)
-{
-	clear_rec(tree->root, tree->destr);
-	tree->root = 0;
-
-	if (tree->rect) {
-		hyperrect_free(tree->rect);
-		tree->rect = 0;
-	}
-}
-
-void kd_data_destructor(struct kdtree *tree, void (*destr)(void*))
-{
-	tree->destr = destr;
-}
-
-
-static int insert_rec(struct kdnode **nptr, const npy_float64 *pos, void *data, int dir, int dim)
-{
-	int new_dir;
-	struct kdnode *node;
-
-	if(!*nptr) {
-		if(!(node = malloc(sizeof *node))) {
-			return -1;
-		}
-		if(!(node->pos = malloc(dim * sizeof *node->pos))) {
-			free(node);
-			return -1;
-		}
-		memcpy(node->pos, pos, dim * sizeof *node->pos);
-		node->data = data;
-		node->dir = dir;
-		node->left = node->right = 0;
-		*nptr = node;
-		return 0;
-	}
-
-	node = *nptr;
-	new_dir = (node->dir + 1) % dim;
-	if(pos[node->dir] < node->pos[node->dir]) {
-		return insert_rec(&(*nptr)->left, pos, data, new_dir, dim);
-	}
-	return insert_rec(&(*nptr)->right, pos, data, new_dir, dim);
-}
-
-int kd_insert(struct kdtree *tree, const npy_float64 *pos, void *data)
-{
-	if (insert_rec(&tree->root, pos, data, 0, tree->dim)) {
-		return -1;
-	}
-
-	if (tree->rect == 0) {
-		tree->rect = hyperrect_create(tree->dim, pos, pos);
-	} else {
-		hyperrect_extend(tree->rect, pos);
-	}
-
-	return 0;
-}
-
-int kd_insertf(struct kdtree *tree, const float *pos, void *data)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int res, dim = tree->dim;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return -1;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_insert(tree, buf, data);
-#ifndef NO_ALLOCA
-	if(tree->dim > 256)
-#else
-	if(tree->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-int kd_insert3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, void *data)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_insert(tree, buf, data);
-}
-
-int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_insert(tree, buf, data);
-}
-
-static int find_nearest(struct kdnode *node, const npy_float64 *pos, npy_float64 range, struct res_node *list, int ordered, int dim)
-{
-	npy_float64 dist_sq, dx;
-	int i, ret, added_res = 0;
-
-	if(!node) return 0;
-
-	dist_sq = 0;
-	for(i=0; i<dim; i++) {
-		dist_sq += SQ(node->pos[i] - pos[i]);
-	}
-	if(dist_sq <= SQ(range)) {
-		if(rlist_insert(list, node, ordered ? dist_sq : -1.0) == -1) {
-			return -1;
-		}
-		added_res = 1;
-	}
-
-	dx = pos[node->dir] - node->pos[node->dir];
-
-	ret = find_nearest(dx <= 0.0 ? node->left : node->right, pos, range, list, ordered, dim);
-	if(ret >= 0 && fabs(dx) < range) {
-		added_res += ret;
-		ret = find_nearest(dx <= 0.0 ? node->right : node->left, pos, range, list, ordered, dim);
-	}
-	if(ret == -1) {
-		return -1;
-	}
-	added_res += ret;
-
-	return added_res;
-}
-
-static void kd_nearest_i(struct kdnode *node, const npy_float64 *pos, struct kdnode **result, npy_float64 *result_dist_sq, struct kdhyperrect* rect)
-{
-	int dir = node->dir;
-	int i, side;
-	npy_float64 dummy, dist_sq;
-	struct kdnode *nearer_subtree, *farther_subtree;
-	npy_float64 *nearer_hyperrect_coord, *farther_hyperrect_coord;
-
-	/* Decide whether to go left or right in the tree */
-	dummy = pos[dir] - node->pos[dir];
-	if (dummy <= 0) {
-		nearer_subtree = node->left;
-		farther_subtree = node->right;
-		nearer_hyperrect_coord = rect->max + dir;
-		farther_hyperrect_coord = rect->min + dir;
-		side = 0;
-	} else {
-		nearer_subtree = node->right;
-		farther_subtree = node->left;
-		nearer_hyperrect_coord = rect->min + dir;
-		farther_hyperrect_coord = rect->max + dir;
-		side = 1;
-	}
-
-	if (nearer_subtree) {
-		/* Slice the hyperrect to get the hyperrect of the nearer subtree */
-		dummy = *nearer_hyperrect_coord;
-		*nearer_hyperrect_coord = node->pos[dir];
-		/* Recurse down into nearer subtree */
-		kd_nearest_i(nearer_subtree, pos, result, result_dist_sq, rect);
-		/* Undo the slice */
-		*nearer_hyperrect_coord = dummy;
-	}
-
-	/* Check the distance of the point at the current node, compare it
-	 * with our best so far */
-	dist_sq = 0;
-	for(i=0; i < rect->dim; i++) {
-		dist_sq += SQ(node->pos[i] - pos[i]);
-	}
-	if (dist_sq < *result_dist_sq) {
-		*result = node;
-		*result_dist_sq = dist_sq;
-	}
-
-	if (farther_subtree) {
-		/* Get the hyperrect of the farther subtree */
-		dummy = *farther_hyperrect_coord;
-		*farther_hyperrect_coord = node->pos[dir];
-		/* Check if we have to recurse down by calculating the closest
-		 * point of the hyperrect and see if it's closer than our
-		 * minimum distance in result_dist_sq. */
-		if (hyperrect_dist_sq(rect, pos) < *result_dist_sq) {
-			/* Recurse down into farther subtree */
-			kd_nearest_i(farther_subtree, pos, result, result_dist_sq, rect);
-		}
-		/* Undo the slice on the hyperrect */
-		*farther_hyperrect_coord = dummy;
-	}
-}
-
-struct kdres *kd_nearest(struct kdtree *kd, const npy_float64 *pos)
-{
-	struct kdhyperrect *rect;
-	struct kdnode *result;
-	struct kdres *rset;
-	npy_float64 dist_sq;
-	int i;
-
-	if (!kd) return 0;
-	if (!kd->rect) return 0;
-
-	/* Allocate result set */
-	if(!(rset = malloc(sizeof *rset))) {
-		return 0;
-	}
-	if(!(rset->rlist = alloc_resnode())) {
-		free(rset);
-		return 0;
-	}
-	rset->rlist->next = 0;
-	rset->tree = kd;
-
-	/* Duplicate the bounding hyperrectangle, we will work on the copy */
-	if (!(rect = hyperrect_duplicate(kd->rect))) {
-		kd_res_free(rset);
-		return 0;
-	}
-
-	/* Our first guesstimate is the root node */
-	result = kd->root;
-	dist_sq = 0;
-	for (i = 0; i < kd->dim; i++)
-		dist_sq += SQ(result->pos[i] - pos[i]);
-
-	/* Search for the nearest neighbour recursively */
-	kd_nearest_i(kd->root, pos, &result, &dist_sq, rect);
-
-	/* Free the copy of the hyperrect */
-	hyperrect_free(rect);
-
-	/* Store the result */
-	if (result) {
-		if (rlist_insert(rset->rlist, result, -1.0) == -1) {
-			kd_res_free(rset);
-			return 0;
-		}
-		rset->size = 1;
-		kd_res_rewind(rset);
-		return rset;
-	} else {
-		kd_res_free(rset);
-		return 0;
-	}
-}
-
-struct kdres *kd_nearestf(struct kdtree *tree, const float *pos)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int dim = tree->dim;
-	struct kdres *res;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return 0;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_nearest(tree, buf);
-#ifndef NO_ALLOCA
-	if(tree->dim > 256)
-#else
-	if(tree->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-struct kdres *kd_nearest3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z)
-{
-	npy_float64 pos[3];
-	pos[0] = x;
-	pos[1] = y;
-	pos[2] = z;
-	return kd_nearest(tree, pos);
-}
-
-struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z)
-{
-	npy_float64 pos[3];
-	pos[0] = x;
-	pos[1] = y;
-	pos[2] = z;
-	return kd_nearest(tree, pos);
-}
-
-struct kdres *kd_nearest_range(struct kdtree *kd, const npy_float64 *pos, npy_float64 range)
-{
-	int ret;
-	struct kdres *rset;
-
-	if(!(rset = malloc(sizeof *rset))) {
-		return 0;
-	}
-	if(!(rset->rlist = alloc_resnode())) {
-		free(rset);
-		return 0;
-	}
-	rset->rlist->next = 0;
-	rset->tree = kd;
-
-	if((ret = find_nearest(kd->root, pos, range, rset->rlist, 0, kd->dim)) == -1) {
-		kd_res_free(rset);
-		return 0;
-	}
-	rset->size = ret;
-	kd_res_rewind(rset);
-	return rset;
-}
-
-struct kdres *kd_nearest_rangef(struct kdtree *kd, const float *pos, float range)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int dim = kd->dim;
-	struct kdres *res;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return 0;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_nearest_range(kd, buf, range);
-#ifndef NO_ALLOCA
-	if(kd->dim > 256)
-#else
-	if(kd->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-struct kdres *kd_nearest_range3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, npy_float64 range)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_nearest_range(tree, buf, range);
-}
-
-struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_nearest_range(tree, buf, range);
-}
-
-void kd_res_free(struct kdres *rset)
-{
-	clear_results(rset);
-	free_resnode(rset->rlist);
-	free(rset);
-}
-
-int kd_res_size(struct kdres *set)
-{
-	return (set->size);
-}
-
-void kd_res_rewind(struct kdres *rset)
-{
-	rset->riter = rset->rlist->next;
-}
-
-int kd_res_end(struct kdres *rset)
-{
-	return rset->riter == 0;
-}
-
-int kd_res_next(struct kdres *rset)
-{
-	rset->riter = rset->riter->next;
-	return rset->riter != 0;
-}
-
-void *kd_res_item(struct kdres *rset, npy_float64 *pos)
-{
-	if(rset->riter) {
-		if(pos) {
-			memcpy(pos, rset->riter->item->pos, rset->tree->dim * sizeof *pos);
-		}
-		return rset->riter->item->data;
-	}
-	return 0;
-}
-
-void *kd_res_itemf(struct kdres *rset, float *pos)
-{
-	if(rset->riter) {
-		if(pos) {
-			int i;
-			for(i=0; i<rset->tree->dim; i++) {
-				pos[i] = rset->riter->item->pos[i];
-			}
-		}
-		return rset->riter->item->data;
-	}
-	return 0;
-}
-
-void *kd_res_item3(struct kdres *rset, npy_float64 *x, npy_float64 *y, npy_float64 *z)
-{
-	if(rset->riter) {
-		if(*x) *x = rset->riter->item->pos[0];
-		if(*y) *y = rset->riter->item->pos[1];
-		if(*z) *z = rset->riter->item->pos[2];
-	}
-	return 0;
-}
-
-void *kd_res_item3f(struct kdres *rset, float *x, float *y, float *z)
-{
-	if(rset->riter) {
-		if(*x) *x = rset->riter->item->pos[0];
-		if(*y) *y = rset->riter->item->pos[1];
-		if(*z) *z = rset->riter->item->pos[2];
-	}
-	return 0;
-}
-
-void *kd_res_item_data(struct kdres *set)
-{
-	return kd_res_item(set, 0);
-}
-
-/* ---- hyperrectangle helpers ---- */
-static struct kdhyperrect* hyperrect_create(int dim, const npy_float64 *min, const npy_float64 *max)
-{
-	size_t size = dim * sizeof(npy_float64);
-	struct kdhyperrect* rect = 0;
-
-	if (!(rect = malloc(sizeof(struct kdhyperrect)))) {
-		return 0;
-	}
-
-	rect->dim = dim;
-	if (!(rect->min = malloc(size))) {
-		free(rect);
-		return 0;
-	}
-	if (!(rect->max = malloc(size))) {
-		free(rect->min);
-		free(rect);
-		return 0;
-	}
-	memcpy(rect->min, min, size);
-	memcpy(rect->max, max, size);
-
-	return rect;
-}
-
-static void hyperrect_free(struct kdhyperrect *rect)
-{
-	free(rect->min);
-	free(rect->max);
-	free(rect);
-}
-
-static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect)
-{
-	return hyperrect_create(rect->dim, rect->min, rect->max);
-}
-
-static void hyperrect_extend(struct kdhyperrect *rect, const npy_float64 *pos)
-{
-	int i;
-
-	for (i=0; i < rect->dim; i++) {
-		if (pos[i] < rect->min[i]) {
-			rect->min[i] = pos[i];
-		}
-		if (pos[i] > rect->max[i]) {
-			rect->max[i] = pos[i];
-		}
-	}
-}
-
-static npy_float64 hyperrect_dist_sq(struct kdhyperrect *rect, const npy_float64 *pos)
-{
-	int i;
-	npy_float64 result = 0;
-
-	for (i=0; i < rect->dim; i++) {
-		if (pos[i] < rect->min[i]) {
-			result += SQ(rect->min[i] - pos[i]);
-		} else if (pos[i] > rect->max[i]) {
-			result += SQ(rect->max[i] - pos[i]);
-		}
-	}
-
-	return result;
-}
-
-/* ---- static helpers ---- */
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-/* special list node allocators. */
-static struct res_node *free_nodes;
-
-#ifndef NO_PTHREADS
-static pthread_mutex_t alloc_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
-static struct res_node *alloc_resnode(void)
-{
-	struct res_node *node;
-
-#ifndef NO_PTHREADS
-	pthread_mutex_lock(&alloc_mutex);
-#endif
-
-	if(!free_nodes) {
-		node = malloc(sizeof *node);
-	} else {
-		node = free_nodes;
-		free_nodes = free_nodes->next;
-		node->next = 0;
-	}
-
-#ifndef NO_PTHREADS
-	pthread_mutex_unlock(&alloc_mutex);
-#endif
-
-	return node;
-}
-
-static void free_resnode(struct res_node *node)
-{
-#ifndef NO_PTHREADS
-	pthread_mutex_lock(&alloc_mutex);
-#endif
-
-	node->next = free_nodes;
-	free_nodes = node;
-
-#ifndef NO_PTHREADS
-	pthread_mutex_unlock(&alloc_mutex);
-#endif
-}
-#endif	/* list node allocator or not */
-
-
-/* inserts the item. if dist_sq is >= 0, then do an ordered insert */
-static int rlist_insert(struct res_node *list, struct kdnode *item, npy_float64 dist_sq)
-{
-	struct res_node *rnode;
-
-	if(!(rnode = alloc_resnode())) {
-		return -1;
-	}
-	rnode->item = item;
-	rnode->dist_sq = dist_sq;
-
-	if(dist_sq >= 0.0) {
-		while(list->next && list->next->dist_sq < dist_sq) {
-			list = list->next;
-		}
-	}
-	rnode->next = list->next;
-	list->next = rnode;
-	return 0;
-}
-
-static void clear_results(struct kdres *rset)
-{
-	struct res_node *tmp, *node = rset->rlist->next;
-
-	while(node) {
-		tmp = node;
-		node = node->next;
-		free_resnode(tmp);
-	}
-
-	rset->rlist->next = 0;
-}

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/kdtree.h
--- a/yt/utilities/lib/kdtree.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-This file is part of ``kdtree'', a library for working with kd-trees.
-Copyright (C) 2007-2011 John Tsiombikas <nuclear at siggraph.org>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-*/
-#ifndef _KDTREE_H_
-#define _KDTREE_H_
-#include "Python.h"
-#include "numpy/ndarrayobject.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct kdtree;
-struct kdres;
-
-
-/* create a kd-tree for "k"-dimensional data */
-struct kdtree *kd_create(int k);
-
-/* free the struct kdtree */
-void kd_free(struct kdtree *tree);
-
-/* remove all the elements from the tree */
-void kd_clear(struct kdtree *tree);
-
-/* if called with non-null 2nd argument, the function provided
- * will be called on data pointers (see kd_insert) when nodes
- * are to be removed from the tree.
- */
-void kd_data_destructor(struct kdtree *tree, void (*destr)(void*));
-
-/* insert a node, specifying its position, and optional data */
-int kd_insert(struct kdtree *tree, const npy_float64 *pos, void *data);
-int kd_insertf(struct kdtree *tree, const float *pos, void *data);
-int kd_insert3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, void *data);
-int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data);
-
-/* Find one of the nearest nodes from the specified point.
- *
- * This function returns a pointer to a result set with at most one element.
- */
-struct kdres *kd_nearest(struct kdtree *tree, const npy_float64 *pos);
-struct kdres *kd_nearestf(struct kdtree *tree, const float *pos);
-struct kdres *kd_nearest3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z);
-struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z);
-
-/* Find any nearest nodes from the specified point within a range.
- *
- * This function returns a pointer to a result set, which can be manipulated
- * by the kd_res_* functions.
- * The returned pointer can be null as an indication of an error. Otherwise
- * a valid result set is always returned which may contain 0 or more elements.
- * The result set must be deallocated with kd_res_free, after use.
- */
-struct kdres *kd_nearest_range(struct kdtree *tree, const npy_float64 *pos, npy_float64 range);
-struct kdres *kd_nearest_rangef(struct kdtree *tree, const float *pos, float range);
-struct kdres *kd_nearest_range3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, npy_float64 range);
-struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range);
-
-/* frees a result set returned by kd_nearest_range() */
-void kd_res_free(struct kdres *set);
-
-/* returns the size of the result set (in elements) */
-int kd_res_size(struct kdres *set);
-
-/* rewinds the result set iterator */
-void kd_res_rewind(struct kdres *set);
-
-/* returns non-zero if the set iterator reached the end after the last element */
-int kd_res_end(struct kdres *set);
-
-/* advances the result set iterator, returns non-zero on success, zero if
- * there are no more elements in the result set.
- */
-int kd_res_next(struct kdres *set);
-
-/* returns the data pointer (can be null) of the current result set item
- * and optionally sets its position to the pointers(s) if not null.
- */
-void *kd_res_item(struct kdres *set, npy_float64 *pos);
-void *kd_res_itemf(struct kdres *set, float *pos);
-void *kd_res_item3(struct kdres *set, npy_float64 *x, npy_float64 *y, npy_float64 *z);
-void *kd_res_item3f(struct kdres *set, float *x, float *y, float *z);
-
-/* equivalent to kd_res_item(set, 0) */
-void *kd_res_item_data(struct kdres *set);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _KDTREE_H_ */

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/utilities/lib/kdtree_utils.pxd
--- a/yt/utilities/lib/kdtree_utils.pxd
+++ /dev/null
@@ -1,43 +0,0 @@
-"""
-A light interface to kdtree, from http://code.google.com/p/kdtree/
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-import numpy as np
-cimport numpy as np
-cimport cython
-
-cdef extern from "kdtree.h":
-    struct kdtree
-    struct kdres
-
-    kdtree *kd_create(int k)
-    void kd_free(kdtree *tree)
-    
-    int kd_insert3(kdtree *tree, np.float64_t x, np.float64_t y, np.float64_t z, void *data)
-    kdres *kd_nearest3(kdtree *tree, np.float64_t x, np.float64_t y,
-                       np.float64_t z) nogil
-
-    kdres *kd_nearest_range3(kdtree *tree, np.float64_t x, np.float64_t y, np.float64_t z,
-                             np.float64_t range) nogil
-
-    void kd_res_free(kdres *set) nogil
-    int kd_res_size(kdres *set) nogil
-    int kd_res_next(kdres *set) nogil
-    void kd_res_rewind(kdres *set) nogil
-
-    void kd_res_item3(kdres *set, np.float64_t *x, np.float64_t *y,
-                      np.float64_t *z) nogil
-    void *kd_res_item_data(kdres *set) nogil
-
-    void kd_data_destructor(kdtree *tree, void (*destr)(void*))

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r bbce7672522d2153664ba3032223ace97f5c66cd yt/visualization/volume_rendering/old_camera.py
--- a/yt/visualization/volume_rendering/old_camera.py
+++ b/yt/visualization/volume_rendering/old_camera.py
@@ -617,10 +617,7 @@
                 np.array(self.width, dtype='float64'), self.transfer_function, self.sub_samples)
         return args, {'lens_type': 'plane-parallel'}
 
-    star_trees = None
     def get_sampler(self, args, kwargs):
-        if self.star_trees is not None:
-            kwargs = {'star_list': self.star_trees}
         if self.use_light:
             if self.light_dir is None:
                 self.set_default_light_dir()


https://bitbucket.org/yt_analysis/yt/commits/dd6dc6a11c26/
Changeset:   dd6dc6a11c26
User:        jzuhone
Date:        2017-06-14 21:14:35+00:00
Summary:     Merge pull request #1430 from ngoldbaum/cython-setup

Remove unused kdtree and parallel components from grid_traversal.pyx
Affected #:  8 files

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 setup.py
--- a/setup.py
+++ b/setup.py
@@ -154,14 +154,10 @@
               depends=["yt/utilities/lib/origami_tags.h"]),
     Extension("yt.utilities.lib.grid_traversal",
               ["yt/utilities/lib/grid_traversal.pyx",
-               "yt/utilities/lib/fixed_interpolator.c",
-               "yt/utilities/lib/kdtree.c"],
+               "yt/utilities/lib/fixed_interpolator.c"],
               include_dirs=["yt/utilities/lib/"],
               libraries=std_libs,
-              extra_compile_args=omp_args,
-              extra_link_args=omp_args,
-              depends=["yt/utilities/lib/kdtree.h",
-                       "yt/utilities/lib/fixed_interpolator.h"]),
+              depends=["yt/utilities/lib/fixed_interpolator.h"]),
     Extension("yt.utilities.lib.image_samplers",
               ["yt/utilities/lib/image_samplers.pyx",
                "yt/utilities/lib/fixed_interpolator.c"],

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/grid_traversal.pyx
--- a/yt/utilities/lib/grid_traversal.pyx
+++ b/yt/utilities/lib/grid_traversal.pyx
@@ -26,8 +26,6 @@
     FIT_eval_transfer_with_light
 from fixed_interpolator cimport *
 
-from cython.parallel import prange, parallel, threadid
-
 DEF Nch = 4
 
 @cython.boundscheck(False)

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/image_samplers.pxd
--- a/yt/utilities/lib/image_samplers.pxd
+++ b/yt/utilities/lib/image_samplers.pxd
@@ -17,7 +17,6 @@
 import numpy as np
 cimport numpy as np
 cimport cython
-cimport kdtree_utils
 from .volume_container cimport VolumeContainer
 from .partitioned_grid cimport PartitionedGrid
 
@@ -85,7 +84,6 @@
     cdef VolumeRenderAccumulator *vra
     cdef public object tf_obj
     cdef public object my_field_tables
-    cdef kdtree_utils.kdtree **trees
     cdef object tree_containers
 
 cdef class LightSourceRenderSampler(ImageSampler):

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/image_samplers.pyx
--- a/yt/utilities/lib/image_samplers.pyx
+++ b/yt/utilities/lib/image_samplers.pyx
@@ -51,7 +51,6 @@
     np.float64_t star_coeff
     np.float64_t star_er
     np.float64_t star_sigma_num
-    kdtree_utils.kdtree *star_list
     np.float64_t *light_dir
     np.float64_t *light_rgba
     int grey_opacity
@@ -295,7 +294,7 @@
                   np.ndarray[np.float64_t, ndim=1] y_vec,
                   np.ndarray[np.float64_t, ndim=1] width,
                   tf_obj, n_samples = 10,
-                  star_list = None, **kwargs):
+                  **kwargs):
         ImageSampler.__init__(self, vp_pos, vp_dir, center, bounds, image,
                                x_vec, y_vec, width, **kwargs)
         cdef int i

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/kdtree.c
--- a/yt/utilities/lib/kdtree.c
+++ /dev/null
@@ -1,761 +0,0 @@
-/*
-This file is part of ``kdtree'', a library for working with kd-trees.
-Copyright (C) 2007-2011 John Tsiombikas <nuclear at siggraph.org>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-*/
-/* single nearest neighbor search written by Tamas Nepusz <tamas at cs.rhul.ac.uk> */
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <math.h>
-#include "kdtree.h"
-
-#ifdef MS_WIN32
-#include <malloc.h>
-#endif
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-
-#ifndef NO_PTHREADS
-#include <pthread.h>
-#else
-
-#ifndef I_WANT_THREAD_BUGS
-#error "You are compiling with the fast list node allocator, with pthreads disabled! This WILL break if used from multiple threads."
-#endif	/* I want thread bugs */
-
-#endif	/* pthread support */
-#endif	/* use list node allocator */
-
-struct kdhyperrect {
-	int dim;
-	npy_float64 *min, *max;              /* minimum/maximum coords */
-};
-
-struct kdnode {
-	npy_float64 *pos;
-	int dir;
-	void *data;
-
-	struct kdnode *left, *right;	/* negative/positive side */
-};
-
-struct res_node {
-	struct kdnode *item;
-	npy_float64 dist_sq;
-	struct res_node *next;
-};
-
-struct kdtree {
-	int dim;
-	struct kdnode *root;
-	struct kdhyperrect *rect;
-	void (*destr)(void*);
-};
-
-struct kdres {
-	struct kdtree *tree;
-	struct res_node *rlist, *riter;
-	int size;
-};
-
-#define SQ(x)			((x) * (x))
-
-
-static void clear_rec(struct kdnode *node, void (*destr)(void*));
-static int insert_rec(struct kdnode **node, const npy_float64 *pos, void *data, int dir, int dim);
-static int rlist_insert(struct res_node *list, struct kdnode *item, npy_float64 dist_sq);
-static void clear_results(struct kdres *set);
-
-static struct kdhyperrect* hyperrect_create(int dim, const npy_float64 *min, const npy_float64 *max);
-static void hyperrect_free(struct kdhyperrect *rect);
-static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect);
-static void hyperrect_extend(struct kdhyperrect *rect, const npy_float64 *pos);
-static npy_float64 hyperrect_dist_sq(struct kdhyperrect *rect, const npy_float64 *pos);
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-static struct res_node *alloc_resnode(void);
-static void free_resnode(struct res_node*);
-#else
-#define alloc_resnode()		malloc(sizeof(struct res_node))
-#define free_resnode(n)		free(n)
-#endif
-
-
-
-struct kdtree *kd_create(int k)
-{
-	struct kdtree *tree;
-
-	if(!(tree = malloc(sizeof *tree))) {
-		return 0;
-	}
-
-	tree->dim = k;
-	tree->root = 0;
-	tree->destr = 0;
-	tree->rect = 0;
-
-	return tree;
-}
-
-void kd_free(struct kdtree *tree)
-{
-	if(tree) {
-		kd_clear(tree);
-		free(tree);
-	}
-}
-
-static void clear_rec(struct kdnode *node, void (*destr)(void*))
-{
-	if(!node) return;
-
-	clear_rec(node->left, destr);
-	clear_rec(node->right, destr);
-	
-	if(destr) {
-		destr(node->data);
-	}
-	free(node->pos);
-	free(node);
-}
-
-void kd_clear(struct kdtree *tree)
-{
-	clear_rec(tree->root, tree->destr);
-	tree->root = 0;
-
-	if (tree->rect) {
-		hyperrect_free(tree->rect);
-		tree->rect = 0;
-	}
-}
-
-void kd_data_destructor(struct kdtree *tree, void (*destr)(void*))
-{
-	tree->destr = destr;
-}
-
-
-static int insert_rec(struct kdnode **nptr, const npy_float64 *pos, void *data, int dir, int dim)
-{
-	int new_dir;
-	struct kdnode *node;
-
-	if(!*nptr) {
-		if(!(node = malloc(sizeof *node))) {
-			return -1;
-		}
-		if(!(node->pos = malloc(dim * sizeof *node->pos))) {
-			free(node);
-			return -1;
-		}
-		memcpy(node->pos, pos, dim * sizeof *node->pos);
-		node->data = data;
-		node->dir = dir;
-		node->left = node->right = 0;
-		*nptr = node;
-		return 0;
-	}
-
-	node = *nptr;
-	new_dir = (node->dir + 1) % dim;
-	if(pos[node->dir] < node->pos[node->dir]) {
-		return insert_rec(&(*nptr)->left, pos, data, new_dir, dim);
-	}
-	return insert_rec(&(*nptr)->right, pos, data, new_dir, dim);
-}
-
-int kd_insert(struct kdtree *tree, const npy_float64 *pos, void *data)
-{
-	if (insert_rec(&tree->root, pos, data, 0, tree->dim)) {
-		return -1;
-	}
-
-	if (tree->rect == 0) {
-		tree->rect = hyperrect_create(tree->dim, pos, pos);
-	} else {
-		hyperrect_extend(tree->rect, pos);
-	}
-
-	return 0;
-}
-
-int kd_insertf(struct kdtree *tree, const float *pos, void *data)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int res, dim = tree->dim;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return -1;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_insert(tree, buf, data);
-#ifndef NO_ALLOCA
-	if(tree->dim > 256)
-#else
-	if(tree->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-int kd_insert3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, void *data)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_insert(tree, buf, data);
-}
-
-int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_insert(tree, buf, data);
-}
-
-static int find_nearest(struct kdnode *node, const npy_float64 *pos, npy_float64 range, struct res_node *list, int ordered, int dim)
-{
-	npy_float64 dist_sq, dx;
-	int i, ret, added_res = 0;
-
-	if(!node) return 0;
-
-	dist_sq = 0;
-	for(i=0; i<dim; i++) {
-		dist_sq += SQ(node->pos[i] - pos[i]);
-	}
-	if(dist_sq <= SQ(range)) {
-		if(rlist_insert(list, node, ordered ? dist_sq : -1.0) == -1) {
-			return -1;
-		}
-		added_res = 1;
-	}
-
-	dx = pos[node->dir] - node->pos[node->dir];
-
-	ret = find_nearest(dx <= 0.0 ? node->left : node->right, pos, range, list, ordered, dim);
-	if(ret >= 0 && fabs(dx) < range) {
-		added_res += ret;
-		ret = find_nearest(dx <= 0.0 ? node->right : node->left, pos, range, list, ordered, dim);
-	}
-	if(ret == -1) {
-		return -1;
-	}
-	added_res += ret;
-
-	return added_res;
-}
-
-static void kd_nearest_i(struct kdnode *node, const npy_float64 *pos, struct kdnode **result, npy_float64 *result_dist_sq, struct kdhyperrect* rect)
-{
-	int dir = node->dir;
-	int i, side;
-	npy_float64 dummy, dist_sq;
-	struct kdnode *nearer_subtree, *farther_subtree;
-	npy_float64 *nearer_hyperrect_coord, *farther_hyperrect_coord;
-
-	/* Decide whether to go left or right in the tree */
-	dummy = pos[dir] - node->pos[dir];
-	if (dummy <= 0) {
-		nearer_subtree = node->left;
-		farther_subtree = node->right;
-		nearer_hyperrect_coord = rect->max + dir;
-		farther_hyperrect_coord = rect->min + dir;
-		side = 0;
-	} else {
-		nearer_subtree = node->right;
-		farther_subtree = node->left;
-		nearer_hyperrect_coord = rect->min + dir;
-		farther_hyperrect_coord = rect->max + dir;
-		side = 1;
-	}
-
-	if (nearer_subtree) {
-		/* Slice the hyperrect to get the hyperrect of the nearer subtree */
-		dummy = *nearer_hyperrect_coord;
-		*nearer_hyperrect_coord = node->pos[dir];
-		/* Recurse down into nearer subtree */
-		kd_nearest_i(nearer_subtree, pos, result, result_dist_sq, rect);
-		/* Undo the slice */
-		*nearer_hyperrect_coord = dummy;
-	}
-
-	/* Check the distance of the point at the current node, compare it
-	 * with our best so far */
-	dist_sq = 0;
-	for(i=0; i < rect->dim; i++) {
-		dist_sq += SQ(node->pos[i] - pos[i]);
-	}
-	if (dist_sq < *result_dist_sq) {
-		*result = node;
-		*result_dist_sq = dist_sq;
-	}
-
-	if (farther_subtree) {
-		/* Get the hyperrect of the farther subtree */
-		dummy = *farther_hyperrect_coord;
-		*farther_hyperrect_coord = node->pos[dir];
-		/* Check if we have to recurse down by calculating the closest
-		 * point of the hyperrect and see if it's closer than our
-		 * minimum distance in result_dist_sq. */
-		if (hyperrect_dist_sq(rect, pos) < *result_dist_sq) {
-			/* Recurse down into farther subtree */
-			kd_nearest_i(farther_subtree, pos, result, result_dist_sq, rect);
-		}
-		/* Undo the slice on the hyperrect */
-		*farther_hyperrect_coord = dummy;
-	}
-}
-
-struct kdres *kd_nearest(struct kdtree *kd, const npy_float64 *pos)
-{
-	struct kdhyperrect *rect;
-	struct kdnode *result;
-	struct kdres *rset;
-	npy_float64 dist_sq;
-	int i;
-
-	if (!kd) return 0;
-	if (!kd->rect) return 0;
-
-	/* Allocate result set */
-	if(!(rset = malloc(sizeof *rset))) {
-		return 0;
-	}
-	if(!(rset->rlist = alloc_resnode())) {
-		free(rset);
-		return 0;
-	}
-	rset->rlist->next = 0;
-	rset->tree = kd;
-
-	/* Duplicate the bounding hyperrectangle, we will work on the copy */
-	if (!(rect = hyperrect_duplicate(kd->rect))) {
-		kd_res_free(rset);
-		return 0;
-	}
-
-	/* Our first guesstimate is the root node */
-	result = kd->root;
-	dist_sq = 0;
-	for (i = 0; i < kd->dim; i++)
-		dist_sq += SQ(result->pos[i] - pos[i]);
-
-	/* Search for the nearest neighbour recursively */
-	kd_nearest_i(kd->root, pos, &result, &dist_sq, rect);
-
-	/* Free the copy of the hyperrect */
-	hyperrect_free(rect);
-
-	/* Store the result */
-	if (result) {
-		if (rlist_insert(rset->rlist, result, -1.0) == -1) {
-			kd_res_free(rset);
-			return 0;
-		}
-		rset->size = 1;
-		kd_res_rewind(rset);
-		return rset;
-	} else {
-		kd_res_free(rset);
-		return 0;
-	}
-}
-
-struct kdres *kd_nearestf(struct kdtree *tree, const float *pos)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int dim = tree->dim;
-	struct kdres *res;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return 0;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_nearest(tree, buf);
-#ifndef NO_ALLOCA
-	if(tree->dim > 256)
-#else
-	if(tree->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-struct kdres *kd_nearest3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z)
-{
-	npy_float64 pos[3];
-	pos[0] = x;
-	pos[1] = y;
-	pos[2] = z;
-	return kd_nearest(tree, pos);
-}
-
-struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z)
-{
-	npy_float64 pos[3];
-	pos[0] = x;
-	pos[1] = y;
-	pos[2] = z;
-	return kd_nearest(tree, pos);
-}
-
-struct kdres *kd_nearest_range(struct kdtree *kd, const npy_float64 *pos, npy_float64 range)
-{
-	int ret;
-	struct kdres *rset;
-
-	if(!(rset = malloc(sizeof *rset))) {
-		return 0;
-	}
-	if(!(rset->rlist = alloc_resnode())) {
-		free(rset);
-		return 0;
-	}
-	rset->rlist->next = 0;
-	rset->tree = kd;
-
-	if((ret = find_nearest(kd->root, pos, range, rset->rlist, 0, kd->dim)) == -1) {
-		kd_res_free(rset);
-		return 0;
-	}
-	rset->size = ret;
-	kd_res_rewind(rset);
-	return rset;
-}
-
-struct kdres *kd_nearest_rangef(struct kdtree *kd, const float *pos, float range)
-{
-	static npy_float64 sbuf[16];
-	npy_float64 *bptr, *buf = 0;
-	int dim = kd->dim;
-	struct kdres *res;
-
-	if(dim > 16) {
-#ifndef NO_ALLOCA
-		if(dim <= 256)
-			bptr = buf = alloca(dim * sizeof *bptr);
-		else
-#endif
-			if(!(bptr = buf = malloc(dim * sizeof *bptr))) {
-				return 0;
-			}
-	} else {
-		bptr = sbuf;
-	}
-
-	while(dim-- > 0) {
-		*bptr++ = *pos++;
-	}
-
-	res = kd_nearest_range(kd, buf, range);
-#ifndef NO_ALLOCA
-	if(kd->dim > 256)
-#else
-	if(kd->dim > 16)
-#endif
-		free(buf);
-	return res;
-}
-
-struct kdres *kd_nearest_range3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, npy_float64 range)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_nearest_range(tree, buf, range);
-}
-
-struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range)
-{
-	npy_float64 buf[3];
-	buf[0] = x;
-	buf[1] = y;
-	buf[2] = z;
-	return kd_nearest_range(tree, buf, range);
-}
-
-void kd_res_free(struct kdres *rset)
-{
-	clear_results(rset);
-	free_resnode(rset->rlist);
-	free(rset);
-}
-
-int kd_res_size(struct kdres *set)
-{
-	return (set->size);
-}
-
-void kd_res_rewind(struct kdres *rset)
-{
-	rset->riter = rset->rlist->next;
-}
-
-int kd_res_end(struct kdres *rset)
-{
-	return rset->riter == 0;
-}
-
-int kd_res_next(struct kdres *rset)
-{
-	rset->riter = rset->riter->next;
-	return rset->riter != 0;
-}
-
-void *kd_res_item(struct kdres *rset, npy_float64 *pos)
-{
-	if(rset->riter) {
-		if(pos) {
-			memcpy(pos, rset->riter->item->pos, rset->tree->dim * sizeof *pos);
-		}
-		return rset->riter->item->data;
-	}
-	return 0;
-}
-
-void *kd_res_itemf(struct kdres *rset, float *pos)
-{
-	if(rset->riter) {
-		if(pos) {
-			int i;
-			for(i=0; i<rset->tree->dim; i++) {
-				pos[i] = rset->riter->item->pos[i];
-			}
-		}
-		return rset->riter->item->data;
-	}
-	return 0;
-}
-
-void *kd_res_item3(struct kdres *rset, npy_float64 *x, npy_float64 *y, npy_float64 *z)
-{
-	if(rset->riter) {
-		if(*x) *x = rset->riter->item->pos[0];
-		if(*y) *y = rset->riter->item->pos[1];
-		if(*z) *z = rset->riter->item->pos[2];
-	}
-	return 0;
-}
-
-void *kd_res_item3f(struct kdres *rset, float *x, float *y, float *z)
-{
-	if(rset->riter) {
-		if(*x) *x = rset->riter->item->pos[0];
-		if(*y) *y = rset->riter->item->pos[1];
-		if(*z) *z = rset->riter->item->pos[2];
-	}
-	return 0;
-}
-
-void *kd_res_item_data(struct kdres *set)
-{
-	return kd_res_item(set, 0);
-}
-
-/* ---- hyperrectangle helpers ---- */
-static struct kdhyperrect* hyperrect_create(int dim, const npy_float64 *min, const npy_float64 *max)
-{
-	size_t size = dim * sizeof(npy_float64);
-	struct kdhyperrect* rect = 0;
-
-	if (!(rect = malloc(sizeof(struct kdhyperrect)))) {
-		return 0;
-	}
-
-	rect->dim = dim;
-	if (!(rect->min = malloc(size))) {
-		free(rect);
-		return 0;
-	}
-	if (!(rect->max = malloc(size))) {
-		free(rect->min);
-		free(rect);
-		return 0;
-	}
-	memcpy(rect->min, min, size);
-	memcpy(rect->max, max, size);
-
-	return rect;
-}
-
-static void hyperrect_free(struct kdhyperrect *rect)
-{
-	free(rect->min);
-	free(rect->max);
-	free(rect);
-}
-
-static struct kdhyperrect* hyperrect_duplicate(const struct kdhyperrect *rect)
-{
-	return hyperrect_create(rect->dim, rect->min, rect->max);
-}
-
-static void hyperrect_extend(struct kdhyperrect *rect, const npy_float64 *pos)
-{
-	int i;
-
-	for (i=0; i < rect->dim; i++) {
-		if (pos[i] < rect->min[i]) {
-			rect->min[i] = pos[i];
-		}
-		if (pos[i] > rect->max[i]) {
-			rect->max[i] = pos[i];
-		}
-	}
-}
-
-static npy_float64 hyperrect_dist_sq(struct kdhyperrect *rect, const npy_float64 *pos)
-{
-	int i;
-	npy_float64 result = 0;
-
-	for (i=0; i < rect->dim; i++) {
-		if (pos[i] < rect->min[i]) {
-			result += SQ(rect->min[i] - pos[i]);
-		} else if (pos[i] > rect->max[i]) {
-			result += SQ(rect->max[i] - pos[i]);
-		}
-	}
-
-	return result;
-}
-
-/* ---- static helpers ---- */
-
-#ifdef USE_LIST_NODE_ALLOCATOR
-/* special list node allocators. */
-static struct res_node *free_nodes;
-
-#ifndef NO_PTHREADS
-static pthread_mutex_t alloc_mutex = PTHREAD_MUTEX_INITIALIZER;
-#endif
-
-static struct res_node *alloc_resnode(void)
-{
-	struct res_node *node;
-
-#ifndef NO_PTHREADS
-	pthread_mutex_lock(&alloc_mutex);
-#endif
-
-	if(!free_nodes) {
-		node = malloc(sizeof *node);
-	} else {
-		node = free_nodes;
-		free_nodes = free_nodes->next;
-		node->next = 0;
-	}
-
-#ifndef NO_PTHREADS
-	pthread_mutex_unlock(&alloc_mutex);
-#endif
-
-	return node;
-}
-
-static void free_resnode(struct res_node *node)
-{
-#ifndef NO_PTHREADS
-	pthread_mutex_lock(&alloc_mutex);
-#endif
-
-	node->next = free_nodes;
-	free_nodes = node;
-
-#ifndef NO_PTHREADS
-	pthread_mutex_unlock(&alloc_mutex);
-#endif
-}
-#endif	/* list node allocator or not */
-
-
-/* inserts the item. if dist_sq is >= 0, then do an ordered insert */
-static int rlist_insert(struct res_node *list, struct kdnode *item, npy_float64 dist_sq)
-{
-	struct res_node *rnode;
-
-	if(!(rnode = alloc_resnode())) {
-		return -1;
-	}
-	rnode->item = item;
-	rnode->dist_sq = dist_sq;
-
-	if(dist_sq >= 0.0) {
-		while(list->next && list->next->dist_sq < dist_sq) {
-			list = list->next;
-		}
-	}
-	rnode->next = list->next;
-	list->next = rnode;
-	return 0;
-}
-
-static void clear_results(struct kdres *rset)
-{
-	struct res_node *tmp, *node = rset->rlist->next;
-
-	while(node) {
-		tmp = node;
-		node = node->next;
-		free_resnode(tmp);
-	}
-
-	rset->rlist->next = 0;
-}

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/kdtree.h
--- a/yt/utilities/lib/kdtree.h
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
-This file is part of ``kdtree'', a library for working with kd-trees.
-Copyright (C) 2007-2011 John Tsiombikas <nuclear at siggraph.org>
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions are met:
-
-1. Redistributions of source code must retain the above copyright notice, this
-   list of conditions and the following disclaimer.
-2. Redistributions in binary form must reproduce the above copyright notice,
-   this list of conditions and the following disclaimer in the documentation
-   and/or other materials provided with the distribution.
-3. The name of the author may not be used to endorse or promote products
-   derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
-WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
-MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
-EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
-EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
-OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
-INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
-CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
-IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
-OF SUCH DAMAGE.
-*/
-#ifndef _KDTREE_H_
-#define _KDTREE_H_
-#include "Python.h"
-#include "numpy/ndarrayobject.h"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-struct kdtree;
-struct kdres;
-
-
-/* create a kd-tree for "k"-dimensional data */
-struct kdtree *kd_create(int k);
-
-/* free the struct kdtree */
-void kd_free(struct kdtree *tree);
-
-/* remove all the elements from the tree */
-void kd_clear(struct kdtree *tree);
-
-/* if called with non-null 2nd argument, the function provided
- * will be called on data pointers (see kd_insert) when nodes
- * are to be removed from the tree.
- */
-void kd_data_destructor(struct kdtree *tree, void (*destr)(void*));
-
-/* insert a node, specifying its position, and optional data */
-int kd_insert(struct kdtree *tree, const npy_float64 *pos, void *data);
-int kd_insertf(struct kdtree *tree, const float *pos, void *data);
-int kd_insert3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, void *data);
-int kd_insert3f(struct kdtree *tree, float x, float y, float z, void *data);
-
-/* Find one of the nearest nodes from the specified point.
- *
- * This function returns a pointer to a result set with at most one element.
- */
-struct kdres *kd_nearest(struct kdtree *tree, const npy_float64 *pos);
-struct kdres *kd_nearestf(struct kdtree *tree, const float *pos);
-struct kdres *kd_nearest3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z);
-struct kdres *kd_nearest3f(struct kdtree *tree, float x, float y, float z);
-
-/* Find any nearest nodes from the specified point within a range.
- *
- * This function returns a pointer to a result set, which can be manipulated
- * by the kd_res_* functions.
- * The returned pointer can be null as an indication of an error. Otherwise
- * a valid result set is always returned which may contain 0 or more elements.
- * The result set must be deallocated with kd_res_free, after use.
- */
-struct kdres *kd_nearest_range(struct kdtree *tree, const npy_float64 *pos, npy_float64 range);
-struct kdres *kd_nearest_rangef(struct kdtree *tree, const float *pos, float range);
-struct kdres *kd_nearest_range3(struct kdtree *tree, npy_float64 x, npy_float64 y, npy_float64 z, npy_float64 range);
-struct kdres *kd_nearest_range3f(struct kdtree *tree, float x, float y, float z, float range);
-
-/* frees a result set returned by kd_nearest_range() */
-void kd_res_free(struct kdres *set);
-
-/* returns the size of the result set (in elements) */
-int kd_res_size(struct kdres *set);
-
-/* rewinds the result set iterator */
-void kd_res_rewind(struct kdres *set);
-
-/* returns non-zero if the set iterator reached the end after the last element */
-int kd_res_end(struct kdres *set);
-
-/* advances the result set iterator, returns non-zero on success, zero if
- * there are no more elements in the result set.
- */
-int kd_res_next(struct kdres *set);
-
-/* returns the data pointer (can be null) of the current result set item
- * and optionally sets its position to the pointers(s) if not null.
- */
-void *kd_res_item(struct kdres *set, npy_float64 *pos);
-void *kd_res_itemf(struct kdres *set, float *pos);
-void *kd_res_item3(struct kdres *set, npy_float64 *x, npy_float64 *y, npy_float64 *z);
-void *kd_res_item3f(struct kdres *set, float *x, float *y, float *z);
-
-/* equivalent to kd_res_item(set, 0) */
-void *kd_res_item_data(struct kdres *set);
-
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif	/* _KDTREE_H_ */

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/utilities/lib/kdtree_utils.pxd
--- a/yt/utilities/lib/kdtree_utils.pxd
+++ /dev/null
@@ -1,43 +0,0 @@
-"""
-A light interface to kdtree, from http://code.google.com/p/kdtree/
-
-
-
-"""
-
-#-----------------------------------------------------------------------------
-# Copyright (c) 2013, yt Development Team.
-#
-# Distributed under the terms of the Modified BSD License.
-#
-# The full license is in the file COPYING.txt, distributed with this software.
-#-----------------------------------------------------------------------------
-
-import numpy as np
-cimport numpy as np
-cimport cython
-
-cdef extern from "kdtree.h":
-    struct kdtree
-    struct kdres
-
-    kdtree *kd_create(int k)
-    void kd_free(kdtree *tree)
-    
-    int kd_insert3(kdtree *tree, np.float64_t x, np.float64_t y, np.float64_t z, void *data)
-    kdres *kd_nearest3(kdtree *tree, np.float64_t x, np.float64_t y,
-                       np.float64_t z) nogil
-
-    kdres *kd_nearest_range3(kdtree *tree, np.float64_t x, np.float64_t y, np.float64_t z,
-                             np.float64_t range) nogil
-
-    void kd_res_free(kdres *set) nogil
-    int kd_res_size(kdres *set) nogil
-    int kd_res_next(kdres *set) nogil
-    void kd_res_rewind(kdres *set) nogil
-
-    void kd_res_item3(kdres *set, np.float64_t *x, np.float64_t *y,
-                      np.float64_t *z) nogil
-    void *kd_res_item_data(kdres *set) nogil
-
-    void kd_data_destructor(kdtree *tree, void (*destr)(void*))

diff -r fc8b883d884e901840c0eb707db889c4ac8bddc7 -r dd6dc6a11c26c2aa7bb30bbe22893518cbc65713 yt/visualization/volume_rendering/old_camera.py
--- a/yt/visualization/volume_rendering/old_camera.py
+++ b/yt/visualization/volume_rendering/old_camera.py
@@ -617,10 +617,7 @@
                 np.array(self.width, dtype='float64'), self.transfer_function, self.sub_samples)
         return args, {'lens_type': 'plane-parallel'}
 
-    star_trees = None
     def get_sampler(self, args, kwargs):
-        if self.star_trees is not None:
-            kwargs = {'star_list': self.star_trees}
         if self.use_light:
             if self.light_dir is None:
                 self.set_default_light_dir()

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