Skip to content

Commit

Permalink
Merge branch '183-RelativePathInQuickSetup' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Razilov committed Mar 29, 2022
2 parents 0c2a80a + 6bcdf77 commit 52d0a12
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
15 changes: 11 additions & 4 deletions c3/experiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,9 @@ def load_quick_setup(self, filepath: str) -> None:
"""
with open(filepath, "r") as cfg_file:
cfg = hjson.loads(cfg_file.read(), object_pairs_hook=hjson_decode)
self.quick_setup(cfg)
self.quick_setup(cfg, os.path.dirname(filepath))

def quick_setup(self, cfg) -> None:
def quick_setup(self, cfg, base_dir: str = None) -> None:
"""
Load a quick setup cfg and create all necessary components.
Expand All @@ -121,10 +121,17 @@ def quick_setup(self, cfg) -> None:
Configuration options
"""

def make_absolute(filename: str) -> str:
if base_dir or os.path.isabs(filename):
return os.path.join(base_dir, filename)
else:
return filename

model = Model()
model.read_config(cfg["model"])
model.read_config(make_absolute(cfg["model"]))
gen = Generator()
gen.read_config(cfg["generator"])
gen.read_config(make_absolute(cfg["generator"]))

single_gate_time = cfg["single_qubit_gate_time"]
v2hz = cfg["v2hz"]
Expand Down
4 changes: 2 additions & 2 deletions test/qiskit.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"optim_type": "C1",
"run_name" : "qiskit",
"include_model" : true,
"model" : "test/test_model.cfg",
"generator": "test/generator.cfg",
"model" : "test_model.cfg",
"generator": "generator.cfg",
"v2hz": 1e9
"sideband": 50e6
"single_qubit_gate_time" : 20e-9
Expand Down
4 changes: 2 additions & 2 deletions test/quickstart.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
"optim_type": "C1",
"run_name" : "quick",
"include_model" : true,
"model" : "test/test_model.cfg",
"generator": "test/generator.cfg",
"model" : "test_model.cfg",
"generator": "generator.cfg",
"v2hz": 1e9
"sideband": 50e6
"single_qubit_gate_time" : 20e-9
Expand Down

0 comments on commit 52d0a12

Please sign in to comment.