lsst.afw  15.0-21-g91b8abf62
spatialCell.py
Go to the documentation of this file.
1 from __future__ import absolute_import, division, print_function
2 
3 from lsst.pex.exceptions import NotFoundError
4 from ._spatialCell import SpatialCellCandidateIterator, SpatialCell
5 
6 __all__ = [] # import this module only for its side effects
7 
8 
10  while True:
11  try:
12  yield self.__deref__()
13  except NotFoundError:
14  return
15  self.__incr__()
16 
17 
18 SpatialCellCandidateIterator.__iter__ = spatialCellCandidateIter
19 
20 
21 def spatialCellIter(self):
22  return self.begin().__iter__()
23 
24 
25 SpatialCell.__iter__ = spatialCellIter
26 
27 
28 def spatialCellGetitem(self, idx):
29  idx = int(idx)
30  num_cells = len(self)
31  if idx < -num_cells or idx >= num_cells:
32  raise IndexError("idx={} < -{} or >= {})".format(idx,
33  num_cells, num_cells))
34  if idx < 0:
35  idx += num_cells
36  for i, cell in enumerate(self):
37  if i >= idx:
38  return cell
39 
40 
41 SpatialCell.__getitem__ = spatialCellGetitem
def spatialCellCandidateIter(self)
Definition: spatialCell.py:9
def spatialCellGetitem(self, idx)
Definition: spatialCell.py:28