qiskit-documentation/docs/api/qiskit/qiskit.primitives.Shaped.mdx

39 lines
1.3 KiB
Plaintext

---
title: Shaped
description: API reference for qiskit.primitives.Shaped
in_page_toc_min_heading_level: 1
python_api_type: class
python_api_name: qiskit.primitives.Shaped
---
# Shaped
<Class id="qiskit.primitives.Shaped" isDedicatedPage={true} github="https://github.com/Qiskit/qiskit/tree/stable/1.1/qiskit/primitives/containers/shape.py#L28-L50" signature="qiskit.primitives.Shaped(*args, **kwargs)" modifiers="class">
Bases: [`Protocol`](https://docs.python.org/3/library/typing.html#typing.Protocol "(in Python v3.12)")
Protocol that defines what it means to be a shaped object.
Note that static type checkers will classify `numpy.ndarray` as being [`Shaped`](#qiskit.primitives.Shaped "qiskit.primitives.Shaped"). Moreover, since this protocol is runtime-checkable, we will even have `isinstance(<numpy.ndarray instance>, Shaped) == True`.
## Attributes
### ndim
<Attribute id="qiskit.primitives.Shaped.ndim">
The number of array dimensions of this object.
</Attribute>
### shape
<Attribute id="qiskit.primitives.Shaped.shape">
The array shape of this object.
</Attribute>
### size
<Attribute id="qiskit.primitives.Shaped.size">
The total dimension of this object, i.e. the product of the entries of [`shape`](#qiskit.primitives.Shaped.shape "qiskit.primitives.Shaped.shape").
</Attribute>
</Class>