# Test ufunc compare(algs.cos(randomVec) - numpy.cos(npa), 1E-7) assert algs.cos(randomVec).DataSet is randomVec.DataSet assert algs.in1d(elev, [0,1]) == [item in [0, 1] for item in elev] # Various numerical ops implemented in VTK g = algs.gradient(elev) assert algs.all(g[0] == (1, 0, 0)) v = algs.make_vector(elev, g[:,0], elev) assert algs.all(algs.gradient(v) == [[1, 0, 1], [0, 0, 0], [0, 0, 0]]) v = algs.make_vector(elev, g[:,0], elev2) assert algs.all(algs.curl(v) == [1, 0, 0]) v = algs.make_vector(elev, elev2, 2*elev3) g = algs.gradient(v) assert g.DataSet is v.DataSet assert algs.all(algs.det(g) == 2) assert algs.all(algs.eigenvalue(g) == [2, 1, 1]) assert algs.all(randomVec[:,0] == randomVec[:,0]) int_array1 = numpy.array([1, 0, 1], dtype=numpy.int) int_array2 = numpy.array([0, 1, 0], dtype=numpy.int) assert algs.all(algs.bitwise_or(int_array1, int_array2) == 1) assert algs.all(algs.bitwise_or(int_array1, dsa.NoneArray) == int_array1) assert algs.all(algs.bitwise_or(dsa.NoneArray, int_array1) == int_array1)
assert algs.all(randomVec[algs.where(randomVec[:,0] > 0.2)].Arrays[0] - npa[numpy.where(npa[:,0] > 0.2)] < 1E-7) assert algs.all(randomVec[dsa.VTKCompositeDataArray([(slice(None, None, None), slice(0,2,None)), 2])].Arrays[0] - npa[:, 0:2] < 1E-6) # Test ufunc assert algs.all(algs.cos(randomVec) - numpy.cos(npa) < 1E-7) assert algs.cos(randomVec).DataSet is randomVec.DataSet # Various numerical ops implemented in VTK g = algs.gradient(elev) assert algs.all(g[0] == (1, 0, 0)) v = algs.make_vector(elev, g[:,0], elev) assert algs.all(algs.gradient(v) == [[1, 0, 0], [0, 0, 0], [1, 0, 0]]) v = algs.make_vector(elev, g[:,0], elev2) assert algs.all(algs.curl(v) == [1, 0, 0]) v = algs.make_vector(elev, elev2, 2*elev3) g = algs.gradient(v) assert g.DataSet is v.DataSet assert algs.all(algs.det(g) == 2) assert algs.all(algs.eigenvalue(g) == [2, 1, 1]) assert algs.all(randomVec[:,0] == randomVec[:,0]) ssource = vtk.vtkSphereSource() ssource.Update() output = ssource.GetOutput()