diff --git a/nada_algebra/array.py b/nada_algebra/array.py index 7112552..0387dc8 100644 --- a/nada_algebra/array.py +++ b/nada_algebra/array.py @@ -434,8 +434,27 @@ def wrapper(*args, **kwargs): return attr - def __setattr__(self, name, value): + def __setattr__(self, name: str, value: Any): + """ + Overrides the default behavior of setting attributes. + + If the attribute name is "inner", it sets the attribute value directly. + Otherwise, it sets the attribute value on the inner object. + + Args: + name (str): The name of the attribute. + value: The value to set for the attribute. + """ if name == "inner": super().__setattr__(name, value) else: setattr(self.inner, name, value) + + def __len__(self): + """ + Overrides the default behavior of returning the length of the object. + + Returns: + int: The length of the inner numpy array. + """ + return len(self.inner) diff --git a/nada_algebra/funcs.py b/nada_algebra/funcs.py index 60bfef8..96749b6 100644 --- a/nada_algebra/funcs.py +++ b/nada_algebra/funcs.py @@ -216,3 +216,29 @@ def output(arr: NadaArray, party: Party, prefix: str): list: A list of Output objects. """ return NadaArray.output_array(arr, party, prefix) + + +def vstack(arr_list: list) -> NadaArray: + """ + Stack arrays in sequence vertically (row wise). + + Args: + arr_list (list): A list of NadaArray objects to stack. + + Returns: + NadaArray: The stacked NadaArray. + """ + return NadaArray(np.vstack(arr_list)) + + +def hstack(arr_list: list) -> NadaArray: + """ + Stack arrays in sequence horizontally (column wise). + + Args: + arr_list (list): A list of NadaArray objects to stack. + + Returns: + NadaArray: The stacked NadaArray. + """ + return NadaArray(np.hstack(arr_list)) diff --git a/pyproject.toml b/pyproject.toml index d1aae49..f435bba 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "nada-algebra" -version = "0.1.1" +version = "0.2.0" description = "" authors = ["José Cabrero-Holgueras "] readme = "README.md"