diff --git a/AUTHORS.md b/AUTHORS.md index a554cc4..1912492 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -15,6 +15,7 @@ - [@sadrasabouri](https://github.com/sadrasabouri) - [@engnadeau](https://github.com/engnadeau) - [@grosa1](https://github.com/grosa1) +- [@maroba](https://github.com/maroba) ++ **Graphic designer** diff --git a/CHANGELOG.md b/CHANGELOG.md index 04ae9fd..40589fb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,6 +22,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. - `Python 3.13` added to `test.yml` - `Python 3.14` added to `test.yml` - Restart mode updated +### Fixed +- `filter_lambda` function bug (values below 14 were set to 23) +- `get_precision` function bug with scientific notation steps +- Infinite loop with zero current step ## [1.4] - 2024-03-16 ### Added - `feature_request.yml` template diff --git a/opem/Functions.py b/opem/Functions.py index ce19692..38908f8 100644 --- a/opem/Functions.py +++ b/opem/Functions.py @@ -163,6 +163,9 @@ def get_precision(input_number): :return: precision as int """ input_string = str(input_number) + if "e" in input_string.lower(): + mantissa, exponent = input_string.lower().split("e") + return max(0, get_precision(mantissa) - int(exponent)) if "." in input_string: splitted_input = input_string.split(".") return len(splitted_input[1]) @@ -583,7 +586,7 @@ def filter_lambda(Input_Dict): print( "[Warning] Opem Automatically Set Lambda To Maximum Value (23) ") elif Input_Dict["lambda"] < 14: - Input_Dict["lambda"] = 23 + Input_Dict["lambda"] = 14 print( "[Warning] Opem Automatically Set Lambda To Minimum Value (14) ") return Input_Dict @@ -739,6 +742,8 @@ def filter_range(IStart, IEnd, IStep): :type IStep: float :return: filtered range as list """ + if IStep == 0: + raise ValueError("[Error] Current step must not be zero") temp = None IStartO = IStart IEndO = IEnd diff --git a/test/test_Functions.py b/test/test_Functions.py index b1c5e2c..a1949f0 100644 --- a/test/test_Functions.py +++ b/test/test_Functions.py @@ -18,6 +18,12 @@ 0 >>> get_precision(2.55) 2 +>>> get_precision(1e-05) +5 +>>> get_precision(1.5e-05) +6 +>>> get_precision(1e+20) +0 >>> warning_check_1(-0.2, 10, 20, True) [True, 10] >>> warning_check_1(-0.2, 10, 20, False) @@ -42,7 +48,7 @@ {'alpha': 1} >>> filter_lambda({"lambda":13}) [Warning] Opem Automatically Set Lambda To Minimum Value (14) -{'lambda': 23} +{'lambda': 14} >>> filter_alpha({"alpha":-0.1}) [Warning] Opem Automatically Set Alpha To Maximum Value (0) {'alpha': 0} @@ -52,6 +58,10 @@ [0, 500, 0.1] >>> filter_range(500,0,-0.1) [0, 500, 0.1] +>>> filter_range(0,100,0) +Traceback (most recent call last): + ... +ValueError: [Error] Current step must not be zero >>> Input_dict=Get_Input({"T": "Cell Operation Temperature [K]", "PH2": "Partial Pressure [atm]", "PO2": "Partial Pressure [atm]"},input_item=input_test) >>> Input_keys=list(Input_dict) >>> Input_keys.sort()