Skip to content

Commit

Permalink
lint
Browse files Browse the repository at this point in the history
  • Loading branch information
doichanj committed Aug 22, 2024
1 parent 9f100c1 commit 9f32502
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 28 deletions.
23 changes: 10 additions & 13 deletions src/noise/noise_model.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -286,8 +286,7 @@ Circuit NoiseModel::sample_noise(const Circuit &circ, RngEngine &rng,
return sample_noise_circuit(circ, rng, method, sample_at_runtime);
}

void NoiseModel::set_config(const Circuit &circ, const Method method) const
{
void NoiseModel::set_config(const Circuit &circ, const Method method) const {
// Qubit mapping
reg_t mapping;
if (circ.remapped_qubits)
Expand Down Expand Up @@ -395,7 +394,8 @@ Circuit NoiseModel::sample_noise_circuit(const Circuit &circ, RngEngine &rng,
default:
if (noise_active) {
NoiseOps noisy_op =
sample_noise_op(op, rng, method, mapping, sample_at_runtime, (circ.num_bind_params > 0));
sample_noise_op(op, rng, method, mapping, sample_at_runtime,
(circ.num_bind_params > 0));
noisy_circ.ops.insert(noisy_circ.ops.end(), noisy_op.begin(),
noisy_op.end());
}
Expand All @@ -412,14 +412,12 @@ Circuit NoiseModel::sample_noise_circuit(const Circuit &circ, RngEngine &rng,
return noisy_circ;
}

NoiseModel::NoiseOps NoiseModel::sample_noise_op(const Operations::Op &op,
RngEngine &rng,
const Method method,
const reg_t &mapping,
bool sample_at_runtime,
bool param_bind) const {
auto noise_ops =
sample_noise_helper(op, rng, method, mapping, sample_at_runtime, param_bind);
NoiseModel::NoiseOps
NoiseModel::sample_noise_op(const Operations::Op &op, RngEngine &rng,
const Method method, const reg_t &mapping,
bool sample_at_runtime, bool param_bind) const {
auto noise_ops = sample_noise_helper(op, rng, method, mapping,
sample_at_runtime, param_bind);

// If original op is conditional, make all the noise operations also
// conditional
Expand Down Expand Up @@ -565,8 +563,7 @@ void NoiseModel::add_nonlocal_quantum_error(
NoiseModel::NoiseOps
NoiseModel::sample_noise_helper(const Operations::Op &op, RngEngine &rng,
const Method method, const reg_t &mapping,
bool sample_at_runtime,
bool param_bind) const {
bool sample_at_runtime, bool param_bind) const {
// Return operator set
NoiseOps noise_before;
NoiseOps noise_after;
Expand Down
23 changes: 10 additions & 13 deletions src/simulators/circuit_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,9 +803,9 @@ void Executor<state_t>::run_circuit_with_sampling(Circuit &circ,
state.initialize_creg(circ.num_memory, circ.num_registers);

if (circ.num_bind_params > 1) {
run_circuit_with_parameter_binding(state, circ.ops.cbegin(),
circ.ops.cbegin() + first_meas,
result, rng, iparam, nullptr, false, final_ops);
run_circuit_with_parameter_binding(
state, circ.ops.cbegin(), circ.ops.cbegin() + first_meas, result,
rng, iparam, nullptr, false, final_ops);
} else {
state.apply_ops(circ.ops.cbegin(), circ.ops.cbegin() + first_meas,
result, rng, final_ops);
Expand Down Expand Up @@ -848,11 +848,10 @@ void Executor<state_t>::run_circuit_shots(

int max_matrix_qubits = 1;
if (sample_noise) {
if(circ.num_bind_params > 1){
if (circ.num_bind_params > 1) {
noise.set_config(circ, Noise::NoiseModel::Method::circuit);
}
}
else {
} else {
Noise::NoiseModel dummy_noise;
state_t dummy_state;
ExperimentResult fusion_result;
Expand Down Expand Up @@ -935,8 +934,8 @@ void Executor<state_t>::run_circuit_shots(

if (circ.num_bind_params > 1) {
run_circuit_with_parameter_binding(state, circ.ops.cbegin(),
circ.ops.cend(), result, rng,
iparam, &noise, sample_noise, true);
circ.ops.cend(), result, rng, iparam,
&noise, sample_noise, true);
} else {
if (sample_noise) {
state.apply_ops(circ_opt.ops.cbegin(), circ_opt.ops.cend(), result,
Expand Down Expand Up @@ -1013,14 +1012,12 @@ void Executor<state_t>::run_circuit_with_parameter_binding(
// run with parameter bind
if (op->has_bind_params) {
top = Operations::bind_parameter(*op, iparam, num_bind_params_);
}
else{
} else {
top = *op;
}
if(sample_noise){
if (sample_noise) {
ops = noise->sample_noise_at_runtime(top, rng);
}
else{
} else {
ops.push_back(top);
}
state.apply_ops(ops.cbegin(), ops.cend(), result, rng,
Expand Down
5 changes: 3 additions & 2 deletions src/simulators/parallel_state_executor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,8 +924,9 @@ void ParallelStateExecutor<state_t>::apply_cache_blocking_ops(
// fecth chunk in cache
if (Base::states_[iChunk].qreg().fetch_chunk()) {
if (Base::num_bind_params_ > 1) {
Base::run_circuit_with_parameter_binding(
Base::states_[iChunk], first, last, result, rng, iparam, nullptr, false, false);
Base::run_circuit_with_parameter_binding(Base::states_[iChunk], first,
last, result, rng, iparam,
nullptr, false, false);
} else {
Base::states_[iChunk].apply_ops(first, last, result, rng, false);
}
Expand Down

0 comments on commit 9f32502

Please sign in to comment.