Regions

A region describes a piece of an object’s data. Regions can be used to restrict the area of a tranfer request. Example:

 1import pdc
 2import numpy as np
 3
 4with pdc.ServerContext():
 5   pdc.init()
 6   cont = pdc.Container('region_example_cont', lifetime=pdc.Container.Lifetime.TRANSIENT)
 7
 8   data = [
 9      [2, 7, 6],
10      [9, 5, 1],
11      [4, 3, 8]
12   ]
13
14   obj = cont.object_from_array('region_example_obj', data)
15
16   data1 = obj.get_data(pdc.region[:2]).wait() # [[2, 7, 6], [9, 5, 1]]
17   data2 = obj.get_data(pdc.region[0, :2]).wait() # [[2, 7]]
property pdc.region

An object used to create regions. See Region for details.

class pdc.Region(slice)
A region, which specifies the location of a ‘block’ of data.
Regions are created by slicing the region object.
Examples:
all data of an object: region[:]
the first row of a 2 dimensional object, or the first element of a 1 dimensional object: region[0]
the first 3 elements of a 1 dimensional object: region[:3]
the next 3 elements of a 1 dimensional object: region[3:6]
the last 6 columns of the first 2 rows of an object: region[:2, 6:]

The slices used to create a region object may not have step values. (region[1:100:4] is invalid)
get_absolute(dims)
Return a new absolute region, using the given dimensions to determine ommitted start and stop values.
Examples:
region[:].get_absolute((3, 4)) -> region[0:3, 0:4]
region[:2, 6:].get_absolute((10, 10)) -> region[0:2, 6:10]
is_absolute()
A region is absolute if the region’s slices have both start and stop values.
returns True if the region is absolute
Examples:
region[2:3, :9] is not absolute
region[2:3, 8] is absolute