• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

Qiskit / qiskit / 6512119538
87%
main: 88%

Build:
Build:
LAST BUILD BRANCH: correct-approximation-degree
DEFAULT BRANCH: main
Ran 13 Oct 2023 07:37PM UTC
Jobs 1
Files 1266
Run time 30s
Badge
Embed ▾
README BADGES
x

If you need to use a raster PNG badge, change the '.svg' to '.png' in the link

Markdown

Textile

RDoc

HTML

Rst

13 Oct 2023 07:04PM UTC coverage: 87.042% (-0.02%) from 87.059%
6512119538

push

github

web-flow
Rewrite singleton handling including `SingletonInstruction` (#11014)

* Rewrite singleton handling including `SingletonInstruction`

This is a large rewrite of the singleton gate handling, building off the
work done across the library to make the initial implementation work.

There are two main purposes to this commit:

* Make `SingletonInstruction` available in addition to `SingletonGate`,
  and have these be easy to maintain in conjunction, not need to
  duplicate overrides between them, and not require inheritors to do any
  nasty multiple inheritance or the like.

* Fix regressions in the construction time of `SingletonGate` instances.

In the end, this turned into a fairly complete rewrite that completely
switches out the method of defining the classes; it transpires that the
previous way of having the "immutable overrides" on _all_ instances of
the classes was the main source of slowdown, with `__setattr__` being a
large problem.  The previous method was far easier from an
implementation perspective, but the runtime costs ended up being too
high.

This new form takes a vastly different strategy, explained in detail in
`qiskit/circuit/singleton.py`.  The gist is that we instead make the
singleton instance a _subclass_ of the class object we're creating, and
only it contains the overrides to make itself immutable.  We get around
the instantiation problem (`__init__` isn't special and doesn't
skip the forbidden `__setattr__`) by constructing an instance of the
_base_ class, and then dynamically switching in the overrides
afterwards.  Since the overrides and the dynamic singleton type of the
instance are designed to be co-operative (including in `__slots__`
layout), this can be done safely.

* Make singleton documentation public

* Add tests of new singleton behaviour

* Fix typos

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

---------

Co-authored-by: Matthew Treinish <mtreinish@kortar.org>

139 of 139 new or added lines in 24 files covered. (100.0%)

74341 of 85408 relevant lines covered (87.04%)

91196.9 hits per line

Jobs
ID Job ID Ran Files Coverage
1 6512119538.1 13 Oct 2023 07:37PM UTC 0
87.04
GitHub Action Run
Source Files on build 6512119538
Detailed source file information is not available for this build.
  • Back to Repo
  • bcf5ce49 on github
  • Prev Build on gh-readonly-queue/main/pr-11015-7a550adb50009712a2ee95c1f7bbb068029d124f (#6507954618)
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc