diff --git a/oeis.py b/oeis.py index 7a0515c..1f6d1bf 100644 --- a/oeis.py +++ b/oeis.py @@ -1,21 +1,12 @@ """Implementation of a few integer sequences from the OEIS.""" import argparse import math -from itertools import count -from functools import lru_cache, reduce -from random import random, choice -from decimal import Decimal, localcontext -from typing import ( - Callable, - Dict, - Iterable, - Iterator, - List, - Sequence, - Union, - overload, -) import sys +from decimal import Decimal, localcontext +from functools import lru_cache, reduce +from itertools import count +from random import choice, random +from typing import Callable, Dict, Iterable, Iterator, List, Sequence, Union, overload # Version format is YYYY.MM.DD (https://calver.org/) __version__ = "2021.1.3" @@ -144,7 +135,7 @@ def __getitem__(self, key: int) -> int: def __getitem__(self, key: slice) -> Sequence[int]: """Return a slice from an integer sequence.""" - def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: # type: ignore + def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: """Return a value from the sequence (or a slice of it).""" if isinstance(key, slice): key = self.check_slice(key) @@ -185,7 +176,7 @@ def __getitem__(self, key: int) -> int: def __getitem__(self, key: slice) -> Sequence[int]: """Return a slice from an integer sequence.""" - def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: # type: ignore + def __getitem__(self, key: Union[int, slice]) -> Union[int, Sequence[int]]: """Return a value from the sequence (or a slice of it).""" if isinstance(key, slice): self.check_slice(key) @@ -263,7 +254,8 @@ def wrapper(function: SerieGenerator) -> IntegerSequenceFromGenerator: def A000037(n: int) -> int: """Give Numbers that are not squares (or, the nonsquares). - a(n) = A000194(n) + n = floor(1/2 *(1 + sqrt(4*n-3))) + n. - Jaroslav Krizek, Jun 14 2009 + a(n) = A000194(n) + n = floor(1/2 *(1 + sqrt(4*n-3))) + n. + - Jaroslav Krizek, Jun 14 2009 """ from math import floor, sqrt @@ -349,7 +341,7 @@ def A000032() -> Iterable[int]: @oeis.from_function() def A000119(n: int) -> int: - """Give the number of representations of n as a sum of distinct Fibonacci numbers.""" + """Give the number of representations of n as a sum of distinct Fib. numbers.""" def f(x, y, z): if x < y: @@ -679,7 +671,10 @@ def A001969() -> Iterable[int]: @oeis.from_function(offset=1) def A064367(n: int) -> int: - """Show result of a(n) = 2^n mod prime(n), or 2^n = k*prime(n) + a(n) with integer k.""" + """Show result of a(n) = 2^n mod prime(n). + + Or 2^n = k*prime(n) + a(n) with integer k. + """ from sympy.ntheory import prime return 2**n % prime(n) diff --git a/tox.ini b/tox.ini index d3dfedf..1fc2c2d 100644 --- a/tox.ini +++ b/tox.ini @@ -24,7 +24,7 @@ exclude_lines = if __name__ == .__main__.: [tox] -envlist = py3{7,8,9,10}-{low,high}, flake8, mypy, black, pylint, pydocstyle, coverage +envlist = py3{7,8,9,10,11}-{low,high}, flake8, mypy, black, pylint, pydocstyle, coverage, isort, ruff isolated_build = True skip_missing_interpreters = True @@ -77,3 +77,13 @@ commands = pylint --disable import-outside-toplevel,invalid-name oeis.py deps = pydocstyle skip_install = True commands = pydocstyle oeis.py + +[testenv:isort] +deps = isort +skip_install = True +commands = isort --profile=black oeis.py + +[testenv:ruff] +deps = ruff +skip_install = True +commands = ruff check oeis.py \ No newline at end of file