Skip to content

Commit

Permalink
⏫ Upgrade dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
spapanik committed Oct 18, 2024
1 parent a39fd77 commit e10370e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 64 deletions.
25 changes: 15 additions & 10 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ keywords = [
classifiers = [
"Development Status :: 4 - Beta",
"Operating System :: OS Independent",
"Intended Audience :: Developers",
"Programming Language :: Python :: 3 :: Only",
"License :: OSI Approved :: BSD License",
"Intended Audience :: Science/Research",
"Topic :: Scientific/Engineering :: Mathematics",
]
Expand All @@ -40,9 +41,9 @@ dev = [
"ipython~=8.18",
]
lint = [
"black~=24.8",
"mypy~=1.11",
"ruff~=0.6",
"black~=24.10",
"mypy~=1.12",
"ruff~=0.7",
]
test = [
"pytest~=8.3",
Expand All @@ -52,8 +53,8 @@ docs = [
"mkdocs~=1.6",
"mkdocs-material~=9.5",
"mkdocs-material-extensions~=1.3",
"pygments~=2.17",
"pymdown-extensions~=10.9",
"pygments~=2.18",
"pymdown-extensions~=10.11",
]

[tool.black]
Expand Down Expand Up @@ -119,9 +120,7 @@ select = [
"PGH",
"PERF",
"PIE",
"PLC",
"PLE",
"PLW",
"PL",
"PT",
"PTH",
"PYI",
Expand Down Expand Up @@ -149,6 +148,7 @@ ignore = [
"COM812",
"E501",
"FIX002",
"PLR09",
"TD002",
"TD003",
"TRY003",
Expand All @@ -157,6 +157,7 @@ ignore = [
[tool.ruff.lint.per-file-ignores]
"tests/**" = [
"FBT001",
"PLR2004",
"PT011",
"S101",
]
Expand All @@ -176,16 +177,20 @@ forced-separate = [
split-on-trailing-comma = false

[tool.pytest.ini_options]
addopts = "-vv"
addopts = "-ra -v --cov"
testpaths = "tests"

[tool.coverage.run]
branch = true
source = [
"src/",
]
data_file = ".cov_cache/coverage.dat"

[tool.coverage.report]
exclude_also = [
"if TYPE_CHECKING:",
]
show_missing = true
skip_covered = true
skip_empty = true
24 changes: 0 additions & 24 deletions src/mathlib/_seven.py

This file was deleted.

2 changes: 0 additions & 2 deletions src/mathlib/_seven.pyi

This file was deleted.

12 changes: 2 additions & 10 deletions src/mathlib/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import math
from typing import TYPE_CHECKING

from mathlib import _seven

if TYPE_CHECKING:
from collections.abc import Iterator

Expand All @@ -17,7 +15,7 @@ def gcd(*integers: int) -> int:
coincides with gcd to be the greatest lower bound in the
lattice of divisibility.
"""
return _seven.gcd(*integers)
return math.gcd(*integers)


def lcm(*integers: int) -> int:
Expand All @@ -28,7 +26,7 @@ def lcm(*integers: int) -> int:
coincides with lcm to be the least upper bound in the
lattice of divisibility.
"""
return _seven.lcm(*integers)
return math.lcm(*integers)


def isqrt(n: int) -> int:
Expand All @@ -39,12 +37,6 @@ def isqrt(n: int) -> int:
def modular_inverse(n: int, mod: int) -> int:
"""
Find the modular inverse of n modulo mod.
In python 3.6 and 3.7, the algorithm is based on using
the Extended Euclid Algorithm, to solve the diophantine
equation n*x + mod*y = 1.
In later versions this is just a wrapper over the pow function.
"""
return pow(n, -1, mod)

Expand Down
36 changes: 18 additions & 18 deletions src/mathlib/primes.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,11 +78,11 @@ def sieve(upper_bound: int) -> Iterator[int]:
This method uses the sieve of Eratosthenes to return the
primes.
"""
if upper_bound <= 5:
if upper_bound > 2:
if upper_bound <= 5: # noqa: PLR2004
if upper_bound > 2: # noqa: PLR2004
yield 2

if upper_bound > 3:
if upper_bound > 3: # noqa: PLR2004
yield 3

return
Expand Down Expand Up @@ -112,51 +112,51 @@ def _miller_rabin_loop(witness: int, mantissa: int, power: int, n: int) -> bool:


def _miller_rabin_witnesses(n: int) -> Iterator[int]:
if n < 2047:
if n < 2047: # noqa: PLR2004
yield from [2]
return

if n < 1373653:
if n < 1373653: # noqa: PLR2004
yield from [2, 3]
return

if n < 9080191:
if n < 9080191: # noqa: PLR2004
yield from [31, 73]
return

if n < 25326001:
if n < 25326001: # noqa: PLR2004
yield from [2, 3, 5]
return

if n < 4759123141:
if n < 4759123141: # noqa: PLR2004
yield from [2, 7, 61]
return

if n < 1122004669633:
if n < 1122004669633: # noqa: PLR2004
yield from [2, 13, 23, 1662803]
return

if n < 2152302898747:
if n < 2152302898747: # noqa: PLR2004
yield from [2, 3, 5, 7, 11]
return

if n < 3474749660383:
if n < 3474749660383: # noqa: PLR2004
yield from [2, 3, 5, 7, 11, 13]
return

if n < 341550071728321:
if n < 341550071728321: # noqa: PLR2004
yield from [2, 3, 5, 7, 11, 13, 17]
return

if n < 3825123056546413051:
if n < 3825123056546413051: # noqa: PLR2004
yield from [2, 3, 5, 7, 11, 13, 17, 19, 23]
return

if n < 318665857834031151167461:
if n < 318665857834031151167461: # noqa: PLR2004
yield from [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37]
return

if n < 3317044064679887385961981:
if n < 3317044064679887385961981: # noqa: PLR2004
yield from [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41]
return

Expand All @@ -172,7 +172,7 @@ def is_prime(n: int) -> bool:
integers, after which it is starts slowing down, due to the fact
that we need to check for all possible Miller-Rabin witnesses.
"""
if n < 256:
if n < 256: # noqa: PLR2004
return n in SMALL_PRIMES

if n % 2 == 0:
Expand All @@ -194,10 +194,10 @@ def next_prime(n: int) -> int:
"""
Get the smallest prime that is larger than n.
"""
if n < 2:
if n < 2: # noqa: PLR2004
return 2

if n == 2:
if n == 2: # noqa: PLR2004
return 3

if n & 1 == 1:
Expand Down

0 comments on commit e10370e

Please sign in to comment.