def test_mean(): a = afnumpy.random.random((2, 3)) b = numpy.array(a) fassert(afnumpy.mean(a), numpy.mean(b)) fassert(afnumpy.mean(a, axis=0), numpy.mean(b, axis=0)) fassert(afnumpy.mean(a, axis=1), numpy.mean(b, axis=1)) fassert(afnumpy.mean(a, axis=(0, 1)), numpy.mean(b, axis=(0, 1)))
def test_mean(): a = afnumpy.random.random((2,3)) b = numpy.array(a) fassert(afnumpy.mean(a), numpy.mean(b)) fassert(afnumpy.mean(a,axis=0), numpy.mean(b,axis=0)) fassert(afnumpy.mean(a,axis=1), numpy.mean(b,axis=1)) fassert(afnumpy.mean(a,axis=(0,1)), numpy.mean(b,axis=(0,1)))
def test_P212121_unflips(): # test mode inversion print('\n\n') print('Testing --> modes --> object:') a = np.arange(4**3).reshape((4,4,4)) + 0J #sym_ops = crappy_crystals.phasing.symmetry_operations.P212121(a.shape, a.shape, a.dtype) sym_ops = crappy_crystals.phasing.symmetry_operations.P212121( \ (a.shape[0]//2, a.shape[1]//2, a.shape[2]//2), a.shape, a.dtype) U = sym_ops.solid_syms_Fourier(a) U_inv = sym_ops.unflip_modes_Fourier(U) print('solid == unflipped modes? (for all modes):') [print(np.allclose(a, m)) for m in U_inv] print('solid == average unflipped modes?:') print(np.allclose(a, np.mean(U_inv, axis=0))) print('modes == broadcast average unflipped modes?:') print(np.allclose(U, sym_ops.solid_syms_Fourier(np.mean(U_inv, axis=0)))) print('\n') print('gpu:') sym_ops_gpu = crappy_crystals.gpu.phasing.symmetry_operations.P212121(a.shape, a.shape, a.dtype) U_gpu = sym_ops_gpu.solid_syms_Fourier(afnumpy.array(a)) U_inv = sym_ops.unflip_modes_Fourier(U_gpu) print('solid == unflipped modes? (for all modes):') [print(np.allclose(a, np.array(m))) for m in U_inv] print('solid == average unflipped modes?:') print(np.allclose(a, np.array(afnumpy.mean(U_inv, axis=0))))