def test_operators_into_frame_basis_with_cutoff_no_cutoff(self): """Test function for construction of operators with cutoff, without a cutoff. """ # no cutoff with already diagonal frame frame_op = -1j * np.pi * Array([1.0, -1.0]) operators = Array([self.X.data, self.Y.data, self.Z.data]) carrier_freqs = Array([1.0, 2.0, 3.0]) frame = Frame(frame_op) ops_w_cutoff, ops_w_conj_cutoff = frame.operators_into_frame_basis_with_cutoff( operators, carrier_freqs=carrier_freqs) self.assertAllClose(ops_w_cutoff, operators) self.assertAllClose(ops_w_conj_cutoff, operators) # same test but with frame given as a 2d array # in this case diagonalization will occur, causing eigenvalues to # be sorted in ascending order. This will flip Y and Z frame_op = -1j * np.pi * Array([[1.0, 0], [0, -1.0]]) carrier_freqs = Array([1.0, 2.0, 3.0]) frame = Frame(frame_op) ops_w_cutoff, ops_w_conj_cutoff = frame.operators_into_frame_basis_with_cutoff( operators, carrier_freqs=carrier_freqs) expected_ops = Array([self.X.data, -self.Y.data, -self.Z.data]) self.assertAllClose(ops_w_cutoff, expected_ops) self.assertAllClose(ops_w_conj_cutoff, expected_ops)
def test_operators_into_frame_basis_with_cutoff(self): """Test function for construction of operators with cutoff.""" # cutoff test frame_op = -1j * np.pi * Array([1.0, -1.0]) operators = Array([self.X.data, self.Y.data, self.Z.data]) carrier_freqs = Array([1.0, 2.0, 3.0]) cutoff_freq = 3.0 frame = Frame(frame_op) cutoff_mat = Array([[[1, 1], [1, 1]], [[1, 0], [1, 1]], [[0, 0], [1, 0]]]) ops_w_cutoff, ops_w_conj_cutoff = frame.operators_into_frame_basis_with_cutoff( operators, cutoff_freq=cutoff_freq, carrier_freqs=carrier_freqs) ops_w_cutoff_expect = cutoff_mat * operators ops_w_conj_cutoff_expect = cutoff_mat.transpose([0, 2, 1]) * operators self.assertAllClose(ops_w_cutoff, ops_w_cutoff_expect) self.assertAllClose(ops_w_conj_cutoff, ops_w_conj_cutoff_expect) # same test with lower cutoff cutoff_freq = 2.0 cutoff_mat = Array([[[1, 0], [1, 1]], [[0, 0], [1, 0]], [[0, 0], [0, 0]]]) ops_w_cutoff, ops_w_conj_cutoff = frame.operators_into_frame_basis_with_cutoff( operators, cutoff_freq=cutoff_freq, carrier_freqs=carrier_freqs) ops_w_cutoff_expect = cutoff_mat * operators ops_w_conj_cutoff_expect = cutoff_mat.transpose([0, 2, 1]) * operators self.assertAllClose(ops_w_cutoff, ops_w_cutoff_expect) self.assertAllClose(ops_w_conj_cutoff, ops_w_conj_cutoff_expect)