IMP  2.0.1
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 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.
3 
4 import IMP.algebra
5 
6 # create a unit grid with its origin at 0,0,0
8 
10 count=0
11 for i in range(0,100):
13  ei= g.get_extended_index(p)
14  if g.get_has_index(ei):
15  print "hit"
16  else:
17  g.add_voxel(ei, count)
18  count=count+1
19 print "There are", len(g.get_all_indexes()), "distinct values", count