示例#1
0
  def test_2(self):

    from mmtbx.geometry.shared_types import voxelizer
    v = voxelizer( base = ( 0, 0, 0 ), step = ( 1, 1, 1 ) )
    indexer = indexing.hash( voxelizer = v, margin = 2 )

    for ( coords, obj ) in OBJECTS:
      indexer.add( object = obj, position = coords )

    self.assertEqual( len( indexer ), len( OBJECTS ) )
    self.assertEqual( indexer.cubes(), 8 )

    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0, 0, 0 ) ) ),
      [ 1, 1, 1.5, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0.5, 0.5, 0.5 ) ) ),
      [ 1, 1, 1.5, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0, 0, 3 ) ) ),
      [ 1.7, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 1, 1, 1 ) ) ),
      [ 1, 1, 1, 1.5, 1.7, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 2, 2, 2 ) ) ),
      [ 1, 1, 1, 1.5, 1.7, 2, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 3, 3, 3 ) ) ),
      [ 1, 2, 3, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 4, 4, 4 ) ) ),
      [ 1, 3, 4, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 5, 5, 5 ) ) ),
      [ 1, 3, 4, 5, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 6, 6, 6 ) ) ),
      [ 3, 4, 5, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 7, 7, 7 ) ) ),
      [ 3, 4, 5 ],
      )
示例#2
0
  def test_2(self):

    from mmtbx.geometry.shared_types import voxelizer
    v = voxelizer( base = ( 0, 0, 0 ), step = ( 1, 1, 1 ) )
    indexer = indexing.hash( voxelizer = v, margin = 2 )

    for ( coords, obj ) in OBJECTS:
      indexer.add( object = obj, position = coords )

    self.assertEqual( len( indexer ), len( OBJECTS ) )
    self.assertEqual( indexer.cubes(), 8 )

    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0, 0, 0 ) ) ),
      [ 1, 1, 1.5, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0.5, 0.5, 0.5 ) ) ),
      [ 1, 1, 1.5, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 0, 0, 3 ) ) ),
      [ 1.7, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 1, 1, 1 ) ) ),
      [ 1, 1, 1, 1.5, 1.7, 2 ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 2, 2, 2 ) ) ),
      [ 1, 1, 1, 1.5, 1.7, 2, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 3, 3, 3 ) ) ),
      [ 1, 2, 3, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 4, 4, 4 ) ) ),
      [ 1, 3, 4, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 5, 5, 5 ) ) ),
      [ 1, 3, 4, 5, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 6, 6, 6 ) ) ),
      [ 3, 4, 5, "foo" ],
      )
    self.assertEqual(
      sorted( indexer.close_to( centre = ( 7, 7, 7 ) ) ),
      [ 3, 4, 5 ],
      )