dwavesystems / dwave-gate

dwave-gate is a software package for constructing, modifying and running quantum circuits on the provided state-vector simulator.
Apache License 2.0
12 stars 7 forks source link

Update context manager to return a `NamedTuple` #13

Closed thisac closed 1 year ago

thisac commented 1 year ago

Updates the context manager so that it returns a NamedTuple instead of a regular tuple. This allows for easy access to the registers without having to always unpack the tuple on context enter.

with circuit.context as reg:
    X(reg.q[0])
    RX(0.5, reg.q[1])

works as well as

with circuit.context as (q, c):
    X(q[0])
    RX(0.5, q[1])
codecov-commenter commented 1 year ago

Codecov Report

Merging #13 (1822f9d) into master (6566ce2) will increase coverage by 0.05%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master      #13      +/-   ##
==========================================
+ Coverage   89.84%   89.89%   +0.05%     
==========================================
  Files          15       15              
  Lines        1142     1148       +6     
  Branches      179      179              
==========================================
+ Hits         1026     1032       +6     
  Misses        116      116              
Impacted Files Coverage Δ
dwave/gate/circuit.py 100.00% <100.00%> (ø)
dwave/gate/registers/registers.py 100.00% <100.00%> (ø)

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more