yt.utilities.lib.cykdtree.utils module

yt.utilities.lib.cykdtree.utils.py_argmax_pts_dim(pos, idx, d, Lidx0, Ridx0)

Get the maximum of points along one dimension for a subset of the point indices. This is essentially max(pos[idx[Lidx:(Ridx+1)], d]).

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • idx (np.ndarray of uint64_t) – (n,) array of indices for positions.

  • d (uint32_t) – Dimension to compute maximum along.

  • Lidx (int) – Index in idx that search should begin at.

  • Ridx (int) – Index in idx that search should end at.

Returns:

Index in idx that provides maximum position in the subset

indices along dimension d.

Return type:

uint64_t

yt.utilities.lib.cykdtree.utils.py_argmin_pts_dim(pos, idx, d, Lidx0, Ridx0)

Get the minimum of points along one dimension for a subset of the point indices. This is essentially min(pos[idx[Lidx:(Ridx+1)], d]).

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • idx (np.ndarray of uint64_t) – (n,) array of indices for positions.

  • d (uint32_t) – Dimension to compute minimum along.

  • Lidx (int) – Index in idx that search should begin at.

  • Ridx (int) – Index in idx that search should end at.

Returns:

Index in idx that provides minimum position in the subset

indices along dimension d.

Return type:

uint64_t

yt.utilities.lib.cykdtree.utils.py_insertSort(pos, d)

Get the indices required to sort coordinates along one dimension.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be sorted along.

Returns:

Indices that sort pos along dimension d.

Return type:

np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_max_pts(pos)

Get the maximum of points along each coordinate.

Parameters:

pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

Returns:

Maximum of pos along each coordinate.

Return type:

np.ndarray of float64

yt.utilities.lib.cykdtree.utils.py_min_pts(pos)

Get the minimum of points along each coordinate.

Parameters:

pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

Returns:

Minimum of pos along each coordinate.

Return type:

np.ndarray of float64

yt.utilities.lib.cykdtree.utils.py_partition(pos, d, p)

Get the indices required to partition coordinates along one dimension.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be partitioned along.

  • p (np.int64_t) – Element of pos[:,d] that should be used as the pivot to partition pos.

Returns:

Location of the pivot in the

partitioned array and the indices required to partition the array such that elements before the pivot are smaller and elements after the pivot are larger.

Return type:

tuple of int64 and np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_partition_given_pivot(pos, d, pval)

Get the indices required to partition coordinates along one dimension.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be partitioned along.

  • pval (np.float64_t) – Value that should be used to partition pos.

Returns:

Location of the largest value

that is smaller than pval in partitioned array and the indices required to partition the array such that elements before the pivot are smaller and elements after the pivot are larger.

Return type:

tuple of int64 and np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_pivot(pos, d)

Get the index of the median of medians along one dimension and indices that partition pos according to the median of medians.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be partitioned along.

Returns:

Index q of idx that is the

pivot. All elements of idx before the pivot will be less than the pivot. If there is an odd number of points, the pivot will be the median.

Return type:

tuple of int64 and np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_quickSort(pos, d)

Get the indices required to sort coordinates along one dimension.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be sorted along.

Returns:

Indices that sort pos along dimension d.

Return type:

np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_select(pos, d, t)

Get the indices required to partition coordinates such that the first t elements in pos[:,d] are the smallest t elements in pos[:,d].

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • d (np.uint32_t) – Dimension that pos should be partitioned along.

  • t (np.int64_t) – Number of smallest elements in pos[:,d] that should be partitioned.

Returns:

Location of element t in the

partitioned array and the indices required to partition the array such that elements before element t are smaller and elements after the pivot are larger.

Return type:

tuple of int64 and np.ndarray of uint64

yt.utilities.lib.cykdtree.utils.py_split(pos, mins=None, maxs=None, use_sliding_midpoint=False)

Get the indices required to split the positions equally along the largest dimension.

Parameters:
  • pos (np.ndarray of float64) – (n,m) array of n m-D coordinates.

  • mins (np.ndarray of float64, optional) – (m,) array of mins. Defaults to None and is set to mins of pos along each dimension.

  • maxs (np.ndarray of float64, optional) – (m,) array of maxs. Defaults to None and is set to maxs of pos along each dimension.

  • use_sliding_midpoint (bool, optional) – If True, the sliding midpoint rule is used to split the positions. Defaults to False.

Returns:

The index of the split in

the partitioned array, the dimension of the split, and the indices required to partition the array.

Return type:

tuple(int64, uint32, np.ndarray of uint64)