repast4py.geometry module

class repast4py.geometry.BoundingBox(xmin, xextent, ymin, yextent, zmin=0, zextent=0)

Bases: tuple

A BoundingBox defines an up to 3 dimensional space in terms of the minimum value and extent along each dimension.

Create new instance of BoundingBox(xmin, xextent, ymin, yextent, zmin, zextent)

xextent

the size of the x dimension

Type:

int

xmin

the minimun x coordinate value.

Type:

int

yextent

the size of the y dimension

Type:

int

ymin

the minimun y coordinate value.

Type:

int

zextent

the size of the z dimension

Type:

int

zmin

the minimun z coordinate value.

Type:

int

repast4py.geometry.find_1d_nghs_periodic(pt, min_max)

Finds the neighboring 1D points of the specified point within the min_max inclusive range, using “periodic” semantics. See repast4py.space.BorderType and repast4py.space.GridPeriodicBorders for more on periodic border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least one element

  • min_max (array) – A numpy array of format [min_x, max_x]

Returns:

A 1d numpy array with the neighboring points according to periodic border semantics, including the source point.

Examples

Find the neighboring points of pt(4) within the bounds of 4 and 10.

>>> from repast4py.space import DiscretePoint
>>> import numpy as np
>>> pt = DiscretePoint(4, 0, 0)
>>> min_max = np.array([4, 10])
>>> nghs = find_1d_nghs_periodic(pt.coordinates, min_max)
>>> nghs
array([10, 4, 5])
repast4py.geometry.find_1d_nghs_sticky(pt, min_max)

Finds the neighboring 1D points of the specified point within the min_max inclusive range, using “sticky” semantics. See repast4py.space.BorderType and repast4py.space.GridStickyBorders for more on sticky border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least one element

  • min_max (array) – A numpy array of format [min_x, max_x]

Returns:

A 1d numpy array with the neighboring points according to sticky border semantics, including the source point.

Examples

Find the neighboring points of pt(4) within the bounds of 2 and 10.

>>> from repast4py.space import DiscretePoint
>>> import numpy as np
>>> pt = DiscretePoint(4, 0, 0)
>>> min_max = np.array([2, 10])
>>> nghs = find_1d_nghs_sticky(pt.coordinates, min_max)
>>> nghs
array([3, 4, 5])
repast4py.geometry.find_2d_nghs_periodic(pt, min_max, pytorch_order=False)

Finds the neighboring 2D points of the specified point within the min_max inclusive range, using “periodic” semantics. See repast4py.space.BorderType and repast4py.space.GridPeriodicBorders for more on periodic border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least two elements

  • min_max (array) – A numpy array of format [min_x, max_x, min_y, max_y]

  • pytorch_order – determines the order in which the neighbors are returned. If True, the y coordinates are returned first, otherwise, the x coordinates are returned first.

Returns:

A 2d numpy array with the neighboring points according to periodic border semantics, in the order determined by the pytorch_order argument, including the source point.

repast4py.geometry.find_2d_nghs_sticky(pt, min_max, pytorch_order=False)

Finds the neighboring 2D points of the specifed point within the min_max inclusive range, using “sticky” semantics. See repast4py.space.BorderType and repast4py.space.GridStickyBorders for more on sticky border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least two elements

  • min_max (array) – A numpy array of format [min_x, max_x, min_y, max_y]

  • pytorch_order (bool) – determines the order in which the neighbors are returned. If True, the y coordinates are returned first, otherwise, the x coordinates are returned first.

Returns:

A 2d numpy array with the neighboring points according to sticky border semantics, in the order determined by the pytorch_order argument, including the source point

repast4py.geometry.find_3d_nghs_periodic(pt, min_max, pytorch_order=False)

Finds the neighboring 3D points of the specified point within the min_max inclusive range, using “periodic” semantics. See repast4py.space.BorderType and repast4py.space.GridPeriodicBorders for more on periodic border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least three elements

  • min_max (array) – A numpy array of format [min_x, max_x, min_y, max_y, min_z, max_z]

  • pytorch_order – determines the order in which the neighbors are returned. If True, the y coordinates are returned first, otherwise, the x coordinates are returned first.

Returns:

A 3d numpy array with the neighboring points according to periodic border semantics, in the order determined by the pytorch_order argument, including the source point.

repast4py.geometry.find_3d_nghs_sticky(pt, min_max, pytorch_order=False)

Finds the neighboring 3D point of the specifed point within the min_max inclusive range, using “sticky” semantics. See repast4py.space.BorderType and repast4py.space.GridStickyBorders for more on sticky border semantics.

Parameters:
  • pt (array) – A numpy scalar array with at least three elements

  • min_max (array) – A numpy array of format [min_x, max_x, min_y, max_y, min_z, max_z]

  • pytorch_order – determines the order in which the neighbors are returned. If True, the y coordinates are returned first, otherwise, the x coordinates are returned first.

Returns:

A 3d numpy array with the neighboring points according to sticky border semantics, in the order determined by the pytorch_order argument, including the source point.

repast4py.geometry.get_num_dims(box)

Gets the BoundingBox’s number of dimensions.

A dimension with an extent of 0 is considered not to exist.

Parameters:

box (BoundingBox) – the bounding box

Returns:

the number of dimensions.

Return type:

int

Examples

1D BoundingBox

>>> bb = BoundingBox(xmin=0, xextent=10, ymin=0, yextent=0, zmin=0, zextent=0)
>>> get_num_dims(bb)
1

2D BoundingBox

>>> bb = BoundingBox(xmin=0, xextent=10, ymin=0, yextent=20, zmin=0, zextent=0)
>>> get_num_dims(bb)
2

3D BoundingBox

>>> bb = BoundingBox(xmin=0, xextent=10, ymin=0, yextent=10, zmin=0, zextent=12)
>>> get_num_dims(bb)
3