Data Model version 2.1.2

Method: pointToIndex


    converts point to equivalent array index. Point is padded to matrix dimension with zeros. negative index values -i in point are treated as eqal to (size-i).

guid: www.ccpn.ac.uk_Fogh_2011-03-30-18:05:06_00006__www.ccpn.ac.uk_Fogh_2011-04-05-18:08:58_00001
OpType: otherQuery
OpSubType: None
isQuery: True
isAbstract: False
Scope: instance_level
Code: shape = self.shape
lendiff = len(shape) -  len(point)
if lendiff < 0:
  raise ApiError("Point %s incompatible with %s-dimensional matrix"
                 % (point,len(shape)))
elif lendiff:
  point = list(point) + lendiff*[0]

result = 0
factor = 1
for ii in range(len(shape)-1,0,-1):   # loop over dimensions in reverse order
  # skipping the first one
  size = shape[ii]
  num,indx = divmod(point[ii],size) # convert -n to width-n
  if num not in (0,-1):
    raise ApiError("Point %s out of range for dimension %s" % (point,ii))
  result += factor * indx
  factor *= size
    
# treat first dimension differently, because locations beyond the end of
# the data may be relevant and are certainly defined
indx = point[0]
if indx < 0:
  indx += shape[0]
if indx < 0:
  raise ApiError("Point %s out of range for dimension %s" % (point,0))
result += factor * indx
  Data Model Version 2.1.2
Go to Top  
  Autogenerated by  PyApiDocGen  revision 1.3   on  Thu Oct 2 16:09:53 2014    from data model package  ccp.api.nmr.NmrCalc.FloatMatrixData   revision ?  
  Work done by the CCPN team.
www.ccpn.ac.uk