[pre-commit.ci] pre-commit autoupdate -- ruff 2025 stable format (#12521)

* [pre-commit.ci] pre-commit autoupdate

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.8.6 → v0.9.1](https://github.com/astral-sh/ruff-pre-commit/compare/v0.8.6...v0.9.1)

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update maths/dual_number_automatic_differentiation.py

* Update maths/dual_number_automatic_differentiation.py

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Update dual_number_automatic_differentiation.py

* Update dual_number_automatic_differentiation.py

* No <fin-streamer> tag with the specified data-test attribute found.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Christian Clauss <cclauss@me.com>
This commit is contained in:
pre-commit-ci[bot]
2025-01-13 21:52:12 +01:00
committed by GitHub
parent cfcc84edf7
commit 4fe50bc1fc
23 changed files with 93 additions and 91 deletions

View File

@@ -17,10 +17,8 @@ class Dual:
self.duals = rank
def __repr__(self):
return (
f"{self.real}+"
f"{'+'.join(str(dual)+'E'+str(n+1)for n,dual in enumerate(self.duals))}"
)
s = "+".join(f"{dual}E{n}" for n, dual in enumerate(self.duals, 1))
return f"{self.real}+{s}"
def reduce(self):
cur = self.duals.copy()

View File

@@ -43,4 +43,6 @@ if __name__ == "__main__":
testmod()
array = [randint(-1000, 1000) for i in range(100)]
k = randint(0, 110)
print(f"The maximum sum of {k} consecutive elements is {max_sum_in_array(array,k)}")
print(
f"The maximum sum of {k} consecutive elements is {max_sum_in_array(array, k)}"
)

View File

@@ -88,18 +88,18 @@ def simpson_integration(function, a: float, b: float, precision: int = 4) -> flo
AssertionError: precision should be positive integer your input : -1
"""
assert callable(
function
), f"the function(object) passed should be callable your input : {function}"
assert callable(function), (
f"the function(object) passed should be callable your input : {function}"
)
assert isinstance(a, (float, int)), f"a should be float or integer your input : {a}"
assert isinstance(function(a), (float, int)), (
"the function should return integer or float return type of your function, "
f"{type(a)}"
)
assert isinstance(b, (float, int)), f"b should be float or integer your input : {b}"
assert (
isinstance(precision, int) and precision > 0
), f"precision should be positive integer your input : {precision}"
assert isinstance(precision, int) and precision > 0, (
f"precision should be positive integer your input : {precision}"
)
# just applying the formula of simpson for approximate integration written in
# mentioned article in first comment of this file and above this function

View File

@@ -73,12 +73,12 @@ class Test(unittest.TestCase):
def test_not_primes(self):
with pytest.raises(ValueError):
is_prime(-19)
assert not is_prime(
0
), "Zero doesn't have any positive factors, primes must have exactly two."
assert not is_prime(
1
), "One only has 1 positive factor, primes must have exactly two."
assert not is_prime(0), (
"Zero doesn't have any positive factors, primes must have exactly two."
)
assert not is_prime(1), (
"One only has 1 positive factor, primes must have exactly two."
)
assert not is_prime(2 * 2)
assert not is_prime(2 * 3)
assert not is_prime(3 * 3)

View File

@@ -66,9 +66,9 @@ def is_prime(number: int) -> bool:
"""
# precondition
assert isinstance(number, int) and (
number >= 0
), "'number' must been an int and positive"
assert isinstance(number, int) and (number >= 0), (
"'number' must been an int and positive"
)
status = True
@@ -254,9 +254,9 @@ def greatest_prime_factor(number):
"""
# precondition
assert isinstance(number, int) and (
number >= 0
), "'number' must been an int and >= 0"
assert isinstance(number, int) and (number >= 0), (
"'number' must been an int and >= 0"
)
ans = 0
@@ -296,9 +296,9 @@ def smallest_prime_factor(number):
"""
# precondition
assert isinstance(number, int) and (
number >= 0
), "'number' must been an int and >= 0"
assert isinstance(number, int) and (number >= 0), (
"'number' must been an int and >= 0"
)
ans = 0
@@ -399,9 +399,9 @@ def goldbach(number):
"""
# precondition
assert (
isinstance(number, int) and (number > 2) and is_even(number)
), "'number' must been an int, even and > 2"
assert isinstance(number, int) and (number > 2) and is_even(number), (
"'number' must been an int, even and > 2"
)
ans = [] # this list will returned
@@ -525,9 +525,9 @@ def kg_v(number1, number2):
done.append(n)
# precondition
assert isinstance(ans, int) and (
ans >= 0
), "'ans' must been from type int and positive"
assert isinstance(ans, int) and (ans >= 0), (
"'ans' must been from type int and positive"
)
return ans
@@ -574,9 +574,9 @@ def get_prime(n):
ans += 1
# precondition
assert isinstance(ans, int) and is_prime(
ans
), "'ans' must been a prime number and from type int"
assert isinstance(ans, int) and is_prime(ans), (
"'ans' must been a prime number and from type int"
)
return ans
@@ -705,9 +705,9 @@ def is_perfect_number(number):
"""
# precondition
assert isinstance(number, int) and (
number > 1
), "'number' must been an int and >= 1"
assert isinstance(number, int) and (number > 1), (
"'number' must been an int and >= 1"
)
divisors = get_divisors(number)