Skip to content

Commit

Permalink
Merge pull request #6 from QuantumBFS/formatting
Browse files Browse the repository at this point in the history
Fix formatting
  • Loading branch information
Sov-trotter authored May 13, 2021
2 parents eefc407 + c281f47 commit 1484976
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ exp_header = [Dict("description"=>"1")]
3) Creating a Qobj

```julia
q = CreateQobj([qc], id = "test_id", header= header, exp_header = exp_header)
q = create_qobj([qc], id = "test_id", header= header, exp_header = exp_header)
```
2 changes: 1 addition & 1 deletion src/YaoBlocksQobj.jl
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module YaoBlocksQobj

export CreateQobj
export create_qobj

using IBMQClient.Schema
using YaoBlocks
Expand Down
20 changes: 10 additions & 10 deletions src/qobj.jl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using Random

"""
CreateQobj(qc, id, header, nshots, exp_header, exp_config)
create_qobj(qc, id, header, nshots, exp_header, exp_config)
Creates a `Qobj` based on the IBMQClient schema.
Expand All @@ -20,14 +20,14 @@ using Random
- `exp_config` (optional): An Array of Configuration structure for user settings that can be different in each
experiment. These will override the configuration settings of the whole job.
"""
function CreateQobj(qc::Array{<:AbstractBlock{N}}; id::String = randstring(), header = nothing, nshots::Int = 1024, exp_header = nothing, exp_config = nothing) where N
experiments = CreateExperiment(qc, exp_header, exp_config)
function create_qobj(qc::Array{<:AbstractBlock{N}}; id::String = randstring(), header = nothing, nshots::Int = 1024, exp_header = nothing, exp_config = nothing) where N
experiments = create_experiment(qc, exp_header, exp_config)
config = ExpConfig(shots = nshots, memory_slots = length(experiments))
Qobj(;qobj_id = id, type = "QASM", schema_version = v"1", header, experiments = experiments, config = config)
end

"""
CreateExperiment(qc, exp_header, exp_config)
create_experiment(qc, exp_header, exp_config)
Returns and experiment type that consits of instructions.
Expand All @@ -41,7 +41,7 @@ end
- `exp_config` (optional): An Array of Configuration structure for user settings that can be different in each
experiment. These will override the configuration settings of the whole job.
"""
function CreateExperiment(qc::Array{<:AbstractBlock{N}}, exp_header = nothing, exp_config = nothing) where N
function create_experiment(qc::Array{<:AbstractBlock{N}}, exp_header = nothing, exp_config = nothing) where N
experiments = Experiment[]
head = false
config = false
Expand All @@ -53,21 +53,21 @@ function CreateExperiment(qc::Array{<:AbstractBlock{N}}, exp_header = nothing, e

for i in 1:length(qc)
if head && config
exp = CreateExperiment!(qc[i], exp_header[i], exp_config[i])
exp = create_experiment!(qc[i], exp_header[i], exp_config[i])
elseif head && !config
exp = CreateExperiment!(qc[i], exp_header[i], exp_config)
exp = create_experiment!(qc[i], exp_header[i], exp_config)
elseif !head && config
exp = CreateExperiment!(qc[i], exp_header, exp_config[i])
exp = create_experiment!(qc[i], exp_header, exp_config[i])
else
exp = CreateExperiment!(qc[i], exp_header, exp_config)
exp = create_experiment!(qc[i], exp_header, exp_config)
end

push!(experiments, exp)
end
return experiments
end

function CreateExperiment!(qc::AbstractBlock{N}, exp_header = nothing, exp_config = nothing) where N
function create_experiment!(qc::AbstractBlock{N}, exp_header = nothing, exp_config = nothing) where N
exp_inst = generate_inst(qc)
experiment = Experiment(;header = exp_header, config = exp_config, instructions = exp_inst)
return experiment
Expand Down
2 changes: 1 addition & 1 deletion test/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ include("qobjtoqbir.jl")
exp_header = [Dict("description"=>"1"), Dict("description"=>"2")]

circuits = [qc, qc1]
q = CreateQobj(circuits, id = "test", header = header, exp_header = exp_header)
q = create_qobj(circuits, id = "test", header = header, exp_header = exp_header)

experiments = q.experiments
for i in 1:length(experiments)
Expand Down

0 comments on commit 1484976

Please sign in to comment.