print('quantize',sq.N() , 834) assert sq.N() == 834 ###################################### bounds ss = sphere.clone().scale([1,2,3]) print('bounds',ss.xbounds()) assert np.allclose(ss.xbounds(), [-1,1], atol=0.01) print('bounds',ss.ybounds()) assert np.allclose(ss.ybounds(), [-2,2], atol=0.01) print('bounds',ss.zbounds()) assert np.allclose(ss.zbounds(), [-3,3], atol=0.01) ###################################### averageSize print('averageSize',sphere.averageSize()) assert 0.9 < sphere.averageSize() < 1.0 print('diagonalSize',sphere.diagonalSize()) assert 3.3 < sphere.diagonalSize() < 3.5 print('maxBoundSize',sphere.maxBoundSize()) assert 1.9 < sphere.maxBoundSize() < 2.1 print('centerOfMass',sphere.centerOfMass()) assert np.allclose(sphere.centerOfMass(), [0,0,0]) print('volume',sphere.volume()) assert 4.1 < sphere.volume() < 4.2 print('area',sphere.area()) assert 12.5 < sphere.area() < 12.6 ###################################### closestPoint pt = [12,34,52]
###################################### quantize print('Test quantize') sq = sphere.clone().quantize(0.1) assert sq.N() == 834 ###################################### bounds print('Test bounds') ss = sphere.clone().scale([1, 2, 3]) assert np.allclose(ss.xbounds(), [-1, 1], atol=0.01) assert np.allclose(ss.ybounds(), [-2, 2], atol=0.01) assert np.allclose(ss.zbounds(), [-3, 3], atol=0.01) ###################################### averageSize print('Test sizes et al') assert 0.9 < sphere.averageSize() < 1.0 assert 3.3 < sphere.diagonalSize() < 3.5 assert 1.9 < sphere.maxBoundSize() < 2.1 assert np.allclose(sphere.centerOfMass(), [0, 0, 0]) assert 4.1 < sphere.volume() < 4.2 assert 12.5 < sphere.area() < 12.6 ###################################### closestPoint print('Test closestPoint') pt = [12, 34, 52] assert np.allclose(sphere.closestPoint(pt), [0.19883616, 0.48003298, 0.85441941]) ###################################### findCellsWithin print('Test findCellsWithin') ics = sphere.findCellsWithin(xbounds=(-0.5, 0.5))