IMP  2.1.0
The Integrative Modeling Platform
algebra/grid_space.py

This example shows how to use the grid support in IMP.algebra to discretize a set of continuous points. In this case the points are simply randomly drawn from the surface of a sphere, but they could be taken from something more interesting.

1 ## \example algebra/grid_space.py
2 # This example shows how to use the grid support in IMP.algebra to
3 # discretize a set of continuous points. In this case the points are
4 # simply randomly drawn from the surface of a sphere, but they could be
5 # taken from something more interesting.
6 
7 import IMP.algebra
8 
9 # create a unit grid with its origin at 0,0,0
11 
13 count = 0
14 for i in range(0, 100):
16  ei = g.get_extended_index(p)
17  if g.get_has_index(ei):
18  print "hit"
19  else:
20  g.add_voxel(ei, count)
21  count = count + 1
22 print "There are", len(g.get_all_indexes()), "distinct values", count