Skip to content

Commit

Permalink
Merge branch 'main' into actions-tests
Browse files Browse the repository at this point in the history
  • Loading branch information
benjimaclellan committed Feb 1, 2025
2 parents 3636dca + a2ba5ba commit e4c6b31
Show file tree
Hide file tree
Showing 8 changed files with 300 additions and 80 deletions.
1 change: 0 additions & 1 deletion mkdocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ plugins:
import:
- https://docs.python.org/3/objects.inv
- https://docs.pydantic.dev/latest/objects.inv
- https://qutip.readthedocs.io/en/qutip-4.7.x/objects.inv
- https://pandas.pydata.org/docs/objects.inv
- https://matplotlib.org/stable/objects.inv
- https://numpy.org/doc/stable/objects.inv
Expand Down
22 changes: 15 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,16 @@ name = "oqd-core"
version = "0.1.0"
requires-python = ">=3.10"
readme = "README.md"
license = {text = "Apache 2.0"}
keywords = ["quantum", "computing", "analog", "digital", "compiler", "transpilation", "atomic",]
license = { text = "Apache 2.0" }
keywords = [
"quantum",
"computing",
"analog",
"digital",
"compiler",
"transpilation",
"atomic",
]
classifiers = [
"Development Status :: 3 - Alpha",

Expand All @@ -33,11 +41,11 @@ dependencies = [

[project.optional-dependencies]
docs = [
"pymdown-extensions",
"mkdocstrings",
"mkdocs-material",
"mkdocstrings-python",
"mdx_truly_sane_lists",
"pymdown-extensions",
"mkdocstrings",
"mkdocs-material",
"mkdocstrings-python",
"mdx_truly_sane_lists",
]
test = ["pytest"]

Expand Down
3 changes: 2 additions & 1 deletion src/oqd_core/interface/atomic/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

########################################################################################
from oqd_core.interface.atomic.system import System
from oqd_core.interface.atomic.protocol import ProtocolSubTypes

########################################################################################

Expand All @@ -40,4 +41,4 @@ class AtomicCircuit(TypeReflectBaseModel):
"""

system: System
protocol: Protocol
protocol: ProtocolSubTypes
9 changes: 7 additions & 2 deletions src/oqd_core/interface/atomic/protocol.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from __future__ import annotations

from typing import List, Union

from oqd_compiler_infrastructure import TypeReflectBaseModel
Expand Down Expand Up @@ -87,7 +89,7 @@ class ParallelProtocol(Protocol):
sequence: List of pulses or subprotocols to compose together in a parallel fashion.
"""

sequence: List[Union[Pulse, Protocol]]
sequence: List[Union[Pulse, ProtocolSubTypes]]


class SequentialProtocol(Protocol):
Expand All @@ -98,4 +100,7 @@ class SequentialProtocol(Protocol):
sequence: List of pulses or subprotocols to compose together in a sequntial fashion.
"""

sequence: List[Union[Pulse, Protocol]]
sequence: List[Union[Pulse, ProtocolSubTypes]]


ProtocolSubTypes = Union[SequentialProtocol, ParallelProtocol]
6 changes: 3 additions & 3 deletions src/oqd_core/interface/digital/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from pydantic import field_validator, model_validator, ConfigDict
from typing import List, Union

from oqd_compiler_infrastructure import VisitableBaseModel
Expand All @@ -32,15 +33,14 @@


class DigitalCircuit(VisitableBaseModel):
model_config = ConfigDict(extra="forbid")

qreg: List[QuantumRegister] = []
creg: List[ClassicalRegister] = []

declarations: List = []
sequence: List[Union[Gate, Statement]] = []

class Config:
extra = "forbid"

@field_validator("creg", mode="before")
@classmethod
def convert_creg(cls, v):
Expand Down
23 changes: 21 additions & 2 deletions src/oqd_core/interface/math.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ class MathExpr(TypeReflectBaseModel):

@classmethod
def cast(cls, value: Any):
if isinstance(value, dict):
return value
if isinstance(value, MathExpr):
return value
if isinstance(value, (int, float)):
Expand Down Expand Up @@ -123,8 +125,23 @@ def is_varname(value: str) -> str:


VarName = Annotated[str, AfterValidator(is_varname)]
CastMathExpr = Annotated[MathExpr, BeforeValidator(MathExpr.cast)]
Functions = Literal["sin", "cos", "tan", "exp", "log", "sinh", "cosh", "tanh"]
Functions = Literal[
"sin",
"cos",
"tan",
"exp",
"log",
"sinh",
"cosh",
"tanh",
"atan",
"acos",
"asin",
"atanh",
"asinh",
"acosh",
"heaviside",
]


########################################################################################
Expand Down Expand Up @@ -327,3 +344,5 @@ class MathPow(MathBinaryOp):
"""
Alias for the union of concrete MathExpr subtypes
"""

CastMathExpr = Annotated[MathExprSubtypes, BeforeValidator(MathExpr.cast)]
64 changes: 0 additions & 64 deletions tests/test_analog/test_serialization.py

This file was deleted.

Loading

0 comments on commit e4c6b31

Please sign in to comment.