m-labs / artiq

A leading-edge control system for quantum information experiments
https://m-labs.hk/artiq
GNU Lesser General Public License v3.0
426 stars 197 forks source link

HasEnvironment: Ensure that kernel_invariants always exists #2465

Open charlesbaynham opened 3 months ago

charlesbaynham commented 3 months ago

ARTIQ Pull Request

Description of Changes

A simple usability tweak. Ensures that kernel_invariants always exists, so that user code doesn't need to add the usual boilerplate of self.kernel_invariants = getattr(self, "kernel_invariants", set()) before each addition.

Related Issue

Type of Changes

Type
:sparkles: New feature

Steps (Choose relevant, delete irrelevant before submitting)

All Pull Requests

Code Changes

Documentation Changes

Git Logistics

Licensing

See copyright & licensing for more info. ARTIQ files that do not contain a license header are copyrighted by M-Labs Limited and are licensed under LGPLv3+.

sbourdeauducq commented 3 months ago

This breaks abstraction layers, HasEnvironment does not otherwise know about kernels. Note that NAC3 does not use kernel_invariants.

charlesbaynham commented 3 months ago

This breaks abstraction layers, HasEnvironment does not otherwise know about kernels. Note that NAC3 does not use kernel_invariants.

True. Is there a better place for it you can think of?