/
testGateSetFunction.py
34 lines (25 loc) · 1.03 KB
/
testGateSetFunction.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import unittest
import pygsti
import numpy as np
import warnings
import pickle
import os
import copy
from pygsti.construction import std1Q_XYI as std
from ..testutils import BaseTestCase, compare_files, temp_files
# This class is for unifying some gatesets that get used in this file and in testGateSets2.py
class GatesetFunctionTestCase(BaseTestCase):
def setUp(self):
super(GatesetFunctionTestCase, self).setUp()
def test_gatesetfunction(self):
gs = std.gs_target.copy()
raw_gsf = pygsti.objects.gatesetfunction.GateSetFunction(gs, "all")
self.assertTrue(raw_gsf.evaluate(gs) is None)
#another case that isn't covered elsewhere: "effect" mode of a vec-fn
def vec_dummy(vecA, vecB, mxBasis):
return np.linalg.norm(vecA-vecB)
Vec_dummy = pygsti.objects.gatesetfunction.vecsfn_factory(vec_dummy)
# init args == (gateset1, gateset2, label, typ)
test = Vec_dummy(gs, gs, "Mdefault:0", "effect")
if __name__ == "__main__":
unittest.main(verbosity=2)