Skip to content

Commit

Permalink
Error in Global and Local
Browse files Browse the repository at this point in the history
  • Loading branch information
a-corni committed Jul 24, 2023
1 parent db87c19 commit 4ca5a20
Showing 1 changed file with 12 additions and 15 deletions.
27 changes: 12 additions & 15 deletions pulser-core/pulser/channels/base_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,8 @@

import warnings
from abc import ABC, abstractmethod
from dataclasses import dataclass, field, fields
from typing import (
Any,
Literal,
Optional,
Type,
TypeVar,
cast,
get_args,
get_type_hints,
)
from dataclasses import MISSING, dataclass, field, fields
from typing import Any, Literal, Optional, Type, TypeVar, cast

import numpy as np
from numpy.typing import ArrayLike
Expand Down Expand Up @@ -271,8 +262,11 @@ def Local(
min_avg_amp: The minimum average amplitude of a pulse (when not
zero).
"""
print(get_type_hints(cls)["addressing"])
if len(get_args(get_type_hints(cls)["addressing"])) == 1:
# Can't initialize a channel whose addressing is determined internally
for cls_field in fields(cls):
if cls_field.name == "addressing":
break
if not cls_field.init and not cls_field.default == MISSING:
raise NotImplementedError(
f"{cls} cannot be initialized from `Local` method."
)
Expand Down Expand Up @@ -313,8 +307,11 @@ def Global(
min_avg_amp: The minimum average amplitude of a pulse (when not
zero).
"""
print(get_args(get_type_hints(cls)["addressing"]))
if len(get_args(get_type_hints(cls)["addressing"])) == 1:
# Can't initialize a channel whose addressing is determined internally
for cls_field in fields(cls):
if cls_field.name == "addressing":
break
if not cls_field.init and not cls_field.default == MISSING:
raise NotImplementedError(
f"{cls} cannot be initialized from `Global` method."
)
Expand Down

0 comments on commit 4ca5a20

Please sign in to comment.