About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
qiskit.utils.name_args
name_args(mapping, skip=0)
Decorator to convert unnamed arguments to named ones.
Can be used to deprecate old signatures of a function, e.g.
old_f(a: TypeA, b: TypeB, c: TypeC)
new_f(a: TypeA, d: TypeD, b: TypeB=None, c: TypeC=None)
Then, to support the old signature this decorator can be used as
@name_args([
('a'), # stays the same
('d', {TypeB: 'b'}), # if arg is of type TypeB, call if 'b' else 'd'
('b', {TypeC: 'c'})
])
def new_f(a: TypeA, d: TypeD, b: TypeB=None, c: TypeC=None):
if b is not None:
# raise warning, this is deprecated!
if c is not None:
# raise warning, this is deprecated!
Was this page helpful?
Report a bug or request content on GitHub.