From ef0e89e8497719888511efa7a322d21120cb6201 Mon Sep 17 00:00:00 2001 From: Franks-labs Date: Mon, 4 Aug 2025 09:32:21 +0000 Subject: [PATCH 1/5] replaced with efficient function --- src/utils.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/utils.py b/src/utils.py index faae9e3..45d46a6 100644 --- a/src/utils.py +++ b/src/utils.py @@ -4,16 +4,16 @@ # TODO: make all functions work with strings as well # TODO: add a new cool calculator function -def sum(a: int, b: int) -> int: +def sum(a: float, b: float) -> float: ''' - This function returns the sum of two numbers + This function returns the sum of two floating-point numbers. Args: - a: float the first number - b: float the second number + a (float): The first number. + b (float): The second number. Returns: - float the sum of a and b + float: The sum of a and b. ''' return a + b From 62585095ece89ebe0a6fdadff9337acbb9676556 Mon Sep 17 00:00:00 2001 From: Hendrik Strauss <107318030+CluelessBaboon@users.noreply.github.com> Date: Mon, 4 Aug 2025 09:46:17 +0000 Subject: [PATCH 2/5] Fix: #6 wrong quantity and type of input args in documentation --- src/utils.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/utils.py b/src/utils.py index faae9e3..00e69ee 100644 --- a/src/utils.py +++ b/src/utils.py @@ -81,8 +81,7 @@ def return_hexadecimal(a: int) -> float: ... Args: - a: float - b: float + a: int Returns: float From d4b47ca9daa34b5a8ac6e14f87d7e4c0cc531dca Mon Sep 17 00:00:00 2001 From: Hendrik Strauss <107318030+CluelessBaboon@users.noreply.github.com> Date: Mon, 4 Aug 2025 13:59:10 +0200 Subject: [PATCH 3/5] Update src/utils.py --- src/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index 00e69ee..0e4de05 100644 --- a/src/utils.py +++ b/src/utils.py @@ -84,7 +84,7 @@ def return_hexadecimal(a: int) -> float: a: int Returns: - float + str ''' return hex(a) From 04df029a69d151d85441a5a71893c2dbbe0ec900 Mon Sep 17 00:00:00 2001 From: Hendrik Strauss <107318030+CluelessBaboon@users.noreply.github.com> Date: Mon, 4 Aug 2025 14:04:32 +0200 Subject: [PATCH 4/5] Update src/utils.py --- src/utils.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/utils.py b/src/utils.py index 0e4de05..6605cb9 100644 --- a/src/utils.py +++ b/src/utils.py @@ -81,7 +81,7 @@ def return_hexadecimal(a: int) -> float: ... Args: - a: int +a: float Returns: str From fb48a85dcbce0493090a702dc07cfc2316fba6d3 Mon Sep 17 00:00:00 2001 From: Edogor <63065545+Edogor@users.noreply.github.com> Date: Mon, 4 Aug 2025 12:40:27 +0000 Subject: [PATCH 5/5] bruuuder --- src/utils.py | 35 +++++++++++++++++++++++++---------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/src/utils.py b/src/utils.py index e180372..063958b 100644 --- a/src/utils.py +++ b/src/utils.py @@ -43,6 +43,7 @@ def divide(a: float, b: float) -> float: ''' return a / b + def modulo(a: int, b: int): ''' ... @@ -56,25 +57,39 @@ def modulo(a: int, b: int): ''' # I think this could be made more efficient? - result = a - (np.floor(a / b) * b) + result = a%b return result def element_wise_multiply(a: np.array, b: np.array) -> np.array: ''' - ... - + Performs element-wise multiplication of two numpy arrays. + Args: - a: np.array - b: np.array + a: np.array - first array + b: np.array - second array Returns: - np.array + np.array - element-wise product of a and b + + Raises: + ValueError: if arrays cannot be broadcast together + TypeError: if inputs are not numpy arrays ''' - - # let's hope that both vectors have the same shape - - return np.multiply(a, b) + + try: + # Check if inputs are numpy arrays + if not isinstance(a, np.ndarray) or not isinstance(b, np.ndarray): + raise TypeError("Both inputs must be numpy arrays") + + # Perform element-wise multiplication with automatic broadcasting + result = np.multiply(a, b) + return result + + except ValueError as e: + raise ValueError(f"Arrays cannot be multiplied element-wise: {str(e)}") + except Exception as e: + raise Exception(f"Unexpected error during multiplication: {str(e)}") def return_hexadecimal(a: int) -> float: '''