diff --git a/hvcc/core/hv2ir/HLangAdc.py b/hvcc/core/hv2ir/HLangAdc.py index 261e74d..6f0d3fe 100644 --- a/hvcc/core/hv2ir/HLangAdc.py +++ b/hvcc/core/hv2ir/HLangAdc.py @@ -35,7 +35,7 @@ def __init__( assert obj_type == "adc" super().__init__(obj_type, args, graph, num_inlets=0, - num_outlets=len(args[self._HEAVY_LANG_DICT.root[obj_type].args[0].name]), + num_outlets=len(args[self._HEAVY_LANG_DICT[obj_type].args[0].name]), annotations=annotations) def _resolved_outlet_type(self, outlet_index: int = 0) -> str: diff --git a/hvcc/core/hv2ir/HLangDac.py b/hvcc/core/hv2ir/HLangDac.py index a4c02ec..92313c7 100644 --- a/hvcc/core/hv2ir/HLangDac.py +++ b/hvcc/core/hv2ir/HLangDac.py @@ -33,7 +33,7 @@ def __init__( ) -> None: assert obj_type == "dac" super().__init__(obj_type, args, graph, - num_inlets=len(args[self._HEAVY_LANG_DICT.root[obj_type].args[0].name]), + num_inlets=len(args[self._HEAVY_LANG_DICT[obj_type].args[0].name]), num_outlets=0, annotations=annotations) diff --git a/hvcc/core/hv2ir/HLangSequence.py b/hvcc/core/hv2ir/HLangSequence.py index cc734f6..e078a38 100644 --- a/hvcc/core/hv2ir/HLangSequence.py +++ b/hvcc/core/hv2ir/HLangSequence.py @@ -33,7 +33,7 @@ def __init__( annotations: Optional[Dict] = None ) -> None: # get the number of outlets that this object has - num_outlets = len(args[self._HEAVY_LANG_DICT.root[obj_type].args[0].name]) + num_outlets = len(args[self._HEAVY_LANG_DICT[obj_type].args[0].name]) super().__init__(obj_type, args, graph, num_inlets=1, num_outlets=num_outlets, diff --git a/hvcc/core/hv2ir/HeavyIrObject.py b/hvcc/core/hv2ir/HeavyIrObject.py index f26fe98..4c7a9af 100644 --- a/hvcc/core/hv2ir/HeavyIrObject.py +++ b/hvcc/core/hv2ir/HeavyIrObject.py @@ -37,7 +37,7 @@ class HeavyIrObject(HeavyLangObject): # load the HeavyIR object definitions with open(os.path.join(os.path.dirname(__file__), "../json/heavy.ir.json"), "r") as f: - __HEAVY_OBJS_IR_DICT = HeavyIRType(json.load(f)) + __HEAVY_OBJS_IR_DICT = HeavyIRType(json.load(f)).root def __init__( self, @@ -49,11 +49,11 @@ def __init__( annotations: Optional[Dict] = None ) -> None: # allow the number of inlets and outlets to be overridden - num_inlets = (len(self.__HEAVY_OBJS_IR_DICT.root[obj_type].inlets) + num_inlets = (len(self.__HEAVY_OBJS_IR_DICT[obj_type].inlets) if num_inlets < 0 else num_inlets) - num_outlets = (len(self.__HEAVY_OBJS_IR_DICT.root[obj_type].outlets) + num_outlets = (len(self.__HEAVY_OBJS_IR_DICT[obj_type].outlets) if num_outlets < 0 else num_outlets) @@ -74,7 +74,7 @@ def __resolve_default_ir_args(self) -> None: """ Resolves missing default arguments. Also checks to make sure that all required arguments are present. """ - if self.type in self.__HEAVY_OBJS_IR_DICT.root.keys(): + if self.type in self.__HEAVY_OBJS_IR_DICT.keys(): for arg in self.__obj_desc.args: if arg.name not in self.args: # if a defined argument is not in the argument dictionary @@ -96,7 +96,7 @@ def __resolve_default_ir_args(self) -> None: def is_ir(cls, obj_type: str) -> bool: """Returns true if the type is an IR object. False otherwise. """ - return obj_type in cls.__HEAVY_OBJS_IR_DICT.root.keys() + return obj_type in cls.__HEAVY_OBJS_IR_DICT.keys() @property def does_process_signal(self) -> bool: @@ -108,7 +108,7 @@ def does_process_signal(self) -> bool: def __obj_desc(self) -> IRNode: """ Returns the original HeavyIR object description. """ - return self.__HEAVY_OBJS_IR_DICT.root[self.type] + return self.__HEAVY_OBJS_IR_DICT[self.type] def inlet_requires_signal(self, inlet_index: int = 0) -> bool: """ Returns True if the indexed inlet requires a signal connection. False otherwise. diff --git a/hvcc/core/hv2ir/HeavyLangObject.py b/hvcc/core/hv2ir/HeavyLangObject.py index 80f05a9..6b1f379 100644 --- a/hvcc/core/hv2ir/HeavyLangObject.py +++ b/hvcc/core/hv2ir/HeavyLangObject.py @@ -41,7 +41,7 @@ class HeavyLangObject: # load the Heavy object definitions with open(os.path.join(os.path.dirname(__file__), "../json/heavy.lang.json"), "r") as f: - _HEAVY_LANG_DICT = HeavyLangType(json.load(f)) + _HEAVY_LANG_DICT = HeavyLangType(json.load(f)).root def __init__( self, @@ -111,7 +111,7 @@ def name(self) -> Optional[str]: def _obj_desc(self) -> LangNode: """ Returns the HeavyLang object description. """ - return self._HEAVY_LANG_DICT.root[self.type] + return self._HEAVY_LANG_DICT[self.type] def inlet_connection_type(self, index: int) -> Inlet: return self._obj_desc.inlets[index] @@ -196,7 +196,7 @@ def __resolve_default_lang_args(self) -> None: """ Resolves missing default arguments. Also checks to make sure that all required arguments are present. Does nothing if the object is IR. """ - if self.type in HeavyLangObject._HEAVY_LANG_DICT.root.keys(): + if self.type in HeavyLangObject._HEAVY_LANG_DICT.keys(): for arg in self._obj_desc.args: if arg.name not in self.args: # if a defined argument is not in the argument dictionary diff --git a/hvcc/generators/ir2c/ir2c_perf.py b/hvcc/generators/ir2c/ir2c_perf.py index 6bb1769..7907e31 100644 --- a/hvcc/generators/ir2c/ir2c_perf.py +++ b/hvcc/generators/ir2c/ir2c_perf.py @@ -31,7 +31,7 @@ class ir2c_perf: def perf(cls, ir: Dict, blocksize: int = 512, mhz: int = 1000, verbose: bool = False) -> Dict: # read the hv.ir.json file with open(os.path.join(os.path.dirname(__file__), "../../core/json/heavy.ir.json"), "r") as f: - HEAVY_IR_JSON = HeavyIRType(json.load(f)) + HEAVY_IR_JSON = HeavyIRType(json.load(f)).root objects: Counter = Counter() perf: Counter = Counter() @@ -39,9 +39,9 @@ def perf(cls, ir: Dict, blocksize: int = 512, mhz: int = 1000, verbose: bool = F for o in ir["signal"]["processOrder"]: obj_id = o["id"] obj_type = ir["objects"][obj_id]["type"] - if obj_type in HEAVY_IR_JSON.root.keys(): + if obj_type in HEAVY_IR_JSON.keys(): objects[obj_type] += 1 - c = Counter(HEAVY_IR_JSON.root[obj_type].perf) + c = Counter(HEAVY_IR_JSON[obj_type].perf) perf = perf + c per_object_perf[obj_type] = per_object_perf[obj_type] + c else: diff --git a/hvcc/interpreters/pd2hv/HeavyObject.py b/hvcc/interpreters/pd2hv/HeavyObject.py index 1037bd5..c9a1371 100644 --- a/hvcc/interpreters/pd2hv/HeavyObject.py +++ b/hvcc/interpreters/pd2hv/HeavyObject.py @@ -29,11 +29,11 @@ class HeavyObject(PdObject): heavy_lang_json = importlib_resources.files('hvcc') / 'core/json/heavy.lang.json' with open(heavy_lang_json, "r") as f: - __HEAVY_LANG_OBJS = HeavyLangType(json.load(f)) + __HEAVY_LANG_OBJS = HeavyLangType(json.load(f)).root heavy_ir_json = importlib_resources.files('hvcc') / 'core/json/heavy.ir.json' with open(heavy_ir_json, "r") as f: - __HEAVY_IR_OBJS = HeavyIRType(json.load(f)) + __HEAVY_IR_OBJS = HeavyIRType(json.load(f)).root def __init__( self, @@ -48,9 +48,9 @@ def __init__( # get the object dictionary (note that it is NOT a copy) if self.is_hvlang: - self.__obj_dict = self.__HEAVY_LANG_OBJS.root[obj_type] + self.__obj_dict = self.__HEAVY_LANG_OBJS[obj_type] elif self.is_hvir: - self.__obj_dict = self.__HEAVY_IR_OBJS.root[obj_type] + self.__obj_dict = self.__HEAVY_IR_OBJS[obj_type] else: assert False, f"{obj_type} is not a Heavy Lang or IR object." @@ -144,11 +144,11 @@ def force_arg_type( @property def is_hvlang(self) -> bool: - return self.obj_type in self.__HEAVY_LANG_OBJS.root.keys() + return self.obj_type in self.__HEAVY_LANG_OBJS.keys() @property def is_hvir(self) -> bool: - return self.obj_type in self.__HEAVY_IR_OBJS.root.keys() + return self.obj_type in self.__HEAVY_IR_OBJS.keys() def get_inlet_connection_type(self, inlet_index: int) -> Optional[str]: """ Returns the inlet connection type, None if the inlet does not exist.