def test_p6m_parity_func_flat_stabilizer(): from groupy.gfunc.p6m_parity_func_array import P6MFuncArray import groupy.garray.p6m_array as p6a v = np.random.randn(13, 15, 12, 3, 3) v[..., 0, 0] = 0 v[..., 2, 0] = 0 f = P6MFuncArray(v=v) g = p6a.P6MArray([np.random.randint(2), np.random.randint(6), 0, 0]) h = p6a.P6MArray([np.random.randint(2), np.random.randint(6), 0, 0]) check_associative(g, h, f) check_identity(p6a, f) check_invertible(g, f) check_i2g_g2i_invertible(f)
def test_p6m_axial_func(): from groupy.gfunc.p6m_axial_func_array import P6MFuncArray import groupy.garray.p6m_array as p6ma v = np.random.randn(13, 15, 2, 6, 3, 3) v[..., 0, 0] = 0 v[..., 2, 2] = 0 f = P6MFuncArray(v=v) g = p6ma.P6MArray([np.random.randint(2), np.random.randint(6), 0, 0]) h = p6ma.P6MArray([np.random.randint(2), np.random.randint(6), 0, 0]) check_associative(g, h, f) check_identity(p6ma, f) check_invertible(g, f) check_i2g_g2i_invertible(f)
def make_d3_p6m_indices(ksize): assert ksize % 2 == 1 # TODO from groupy.gfunc.p6m_axial_func_array import P6MFuncArray import groupy.garray.p6m_array as p6ma import groupy.garray.D6_array as d6a x = np.random.randn(12, ksize, ksize) f = P6MFuncArray(v=x) li = f.left_translation_indices(d6a.D6.flatten()[:, None, None, None]) # Set invalid indices to the weight which is known to be zero. li[np.min(li[..., -2:], axis=-1) < 0, :] = np.zeros(li.shape[-1]) li[np.max(li[..., -2:], axis=-1) >= ksize, :] = np.zeros(li.shape[-1]) return li.astype('int32')