Skip to content

Commit

Permalink
Allow repr(m.Circuit)
Browse files Browse the repository at this point in the history
  • Loading branch information
cdonovick committed May 14, 2019
1 parent ecc71ff commit 91e9e1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions magma/circuit.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,9 @@ def __str__(cls):
return f"{cls.__name__}{interface}"

def __repr__(cls):
if not hasattr(cls, 'IO'):
return super().__repr__()

name = cls.__name__
args = str(cls.IO)
if hasattr(cls,"instances"):
Expand Down
11 changes: 11 additions & 0 deletions tests/test_circuit/test_inspect.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
import magma as m

def test_str_repr_core():
#Dont care what values they return as long as they retun non empty strings
assert str(m.Circuit)
assert repr(m.Circuit)
assert str(m.circuit.CircuitKind)
assert repr(m.circuit.CircuitKind)
assert str(m.CircuitType)
assert repr(m.CircuitType)
assert str(m.AnonymousCircuitType)
assert repr(m.AnonymousCircuitType)


def test_str_repr():
And2 = m.DeclareCircuit('And2', "I0", m.In(m.Bit), "I1", m.In(m.Bit),
Expand Down

0 comments on commit 91e9e1f

Please sign in to comment.