Skip to content

Commit d3ef5d9

Browse files
Merge pull request #186 from python-accelerator-middle-layer/fix-repr-accelerator-and-arrays
Fix repr accelerator and arrays
2 parents 02bb4e8 + befd49b commit d3ef5d9

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

pyaml/accelerator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import os
66

7-
from pydantic import BaseModel, ConfigDict
7+
from pydantic import BaseModel, ConfigDict, Field
88

99
from .arrays.array import ArrayConfig
1010
from .common.element import Element
@@ -55,8 +55,8 @@ class ConfigModel(BaseModel):
5555
simulators: list[Simulator] = None
5656
data_folder: str
5757
description: str | None = None
58-
arrays: list[ArrayConfig] = None
59-
devices: list[Element]
58+
arrays: list[ArrayConfig] = Field(default=None, repr=False)
59+
devices: list[Element] = Field(repr=False)
6060

6161

6262
class Accelerator(object):

pyaml/arrays/array.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,8 @@ def __init__(self, cfg: ArrayConfigModel):
3737

3838
def fill_array(self, holder: ElementHolder):
3939
raise PyAMLException("Array.fill_array() is not subclassed")
40+
41+
def __repr__(self):
42+
# ArrayConfigModel is a super class
43+
# ConfigModel is expected from sub classes
44+
return repr(self._cfg).replace("ConfigModel", self.__class__.__name__)

0 commit comments

Comments
 (0)