MCPcopy
hub / github.com/Qiskit/qiskit / has_identifier

Method has_identifier

qiskit/circuit/quantumcircuit.py:3286–3313  ·  view source on GitHub ↗

Check whether an identifier is accessible in this scope. Args: name_or_ident: the instance, or name of the identifier to check. If this is a :class:`.expr.Var` or :class:`.expr.Stretch` node, the matched instance must be exactly the given one for

(self, name_or_ident: str | expr.Var | expr.Stretch, /)

Source from the content-addressed store, hash-verified

3284 return default
3285
3286 def has_identifier(self, name_or_ident: str | expr.Var | expr.Stretch, /) -> bool:
3287 """Check whether an identifier is accessible in this scope.
3288
3289 Args:
3290 name_or_ident: the instance, or name of the identifier to check. If this is a
3291 :class:`.expr.Var` or :class:`.expr.Stretch` node, the matched instance must
3292 be exactly the given one for this function to return ``True``.
3293
3294 Returns:
3295 whether a matching identifier is accessible.
3296
3297 See also:
3298 :meth:`QuantumCircuit.get_identifier`
3299 Retrieve the :class:`.expr.Var` or :class:`.expr.Stretch` instance from this
3300 circuit by name.
3301 :meth:`QuantumCircuit.has_var`
3302 The same as this method, but ignoring anything that isn't a
3303 run-time :class:`expr.Var` variable.
3304 :meth:`QuantumCircuit.has_stretch`
3305 The same as this method, but ignoring anything that isn't a
3306 run-time :class:`expr.Stretch` variable.
3307 :meth:`QuantumCircuit.has_parameter`
3308 A similar method to this, but for compile-time :class:`.Parameter`\\ s instead of
3309 run-time :class:`.expr.Var` variables.
3310 """
3311 if isinstance(name_or_ident, str):
3312 return self.get_identifier(name_or_ident, None) is not None
3313 return self.get_identifier(name_or_ident.name, None) == name_or_ident
3314
3315 def _prepare_new_var(
3316 self, name_or_var: str | expr.Var, type_: types.Type | None, /

Callers 2

appendMethod · 0.95
copy_with_remappingMethod · 0.80

Calls 1

get_identifierMethod · 0.95

Tested by

no test coverage detected