Skip to content

Commit

Permalink
Pretty print supported programs enum (unitaryfund#2352)
Browse files Browse the repository at this point in the history
  • Loading branch information
cosenal authored May 8, 2024
1 parent 8b9ba75 commit 1aaa054
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions mitiq/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,31 @@

from collections import Counter
from dataclasses import dataclass
from enum import Enum
from typing import Any, Dict, Iterable, List, Optional, Sequence, Tuple, Union
from enum import Enum, EnumMeta
from typing import (
Any,
Dict,
Iterable,
List,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)

import numpy as np
import numpy.typing as npt
from cirq import Circuit as _Circuit


class EnhancedEnum(Enum):
class EnhancedEnumMeta(EnumMeta):
def __str__(cls) -> str:
return ", ".join([member.value for member in cast(Type[Enum], cls)])


class EnhancedEnum(Enum, metaclass=EnhancedEnumMeta):
# This is for backwards compatibility with the old representation
# of SUPPORTED_PROGRAM_TYPES, which was a dictionary
@classmethod
Expand Down

0 comments on commit 1aaa054

Please sign in to comment.