mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-11-23 21:11:08 +00:00
[pre-commit.ci] pre-commit autoupdate (#6629)
* [pre-commit.ci] pre-commit autoupdate updates: - [github.com/psf/black: 22.6.0 → 22.8.0](https://github.com/psf/black/compare/22.6.0...22.8.0) - [github.com/asottile/pyupgrade: v2.37.0 → v2.38.2](https://github.com/asottile/pyupgrade/compare/v2.37.0...v2.38.2) - https://gitlab.com/pycqa/flake8 → https://github.com/PyCQA/flake8 - [github.com/PyCQA/flake8: 3.9.2 → 5.0.4](https://github.com/PyCQA/flake8/compare/3.9.2...5.0.4) - [github.com/pre-commit/mirrors-mypy: v0.961 → v0.981](https://github.com/pre-commit/mirrors-mypy/compare/v0.961...v0.981) - [github.com/codespell-project/codespell: v2.1.0 → v2.2.1](https://github.com/codespell-project/codespell/compare/v2.1.0...v2.2.1) * Fix a long line * Update sol1.py * Update sol1.py * lambda_ * Update multi_level_feedback_queue.py * Update double_ended_queue.py * Update sequential_minimum_optimization.py * Update .pre-commit-config.yaml 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:
parent
e9862adafc
commit
756bb268eb
|
@ -14,7 +14,7 @@ repos:
|
||||||
- id: requirements-txt-fixer
|
- id: requirements-txt-fixer
|
||||||
|
|
||||||
- repo: https://github.com/psf/black
|
- repo: https://github.com/psf/black
|
||||||
rev: 22.6.0
|
rev: 22.8.0
|
||||||
hooks:
|
hooks:
|
||||||
- id: black
|
- id: black
|
||||||
|
|
||||||
|
@ -26,14 +26,14 @@ repos:
|
||||||
- --profile=black
|
- --profile=black
|
||||||
|
|
||||||
- repo: https://github.com/asottile/pyupgrade
|
- repo: https://github.com/asottile/pyupgrade
|
||||||
rev: v2.37.0
|
rev: v2.38.2
|
||||||
hooks:
|
hooks:
|
||||||
- id: pyupgrade
|
- id: pyupgrade
|
||||||
args:
|
args:
|
||||||
- --py310-plus
|
- --py310-plus
|
||||||
|
|
||||||
- repo: https://gitlab.com/pycqa/flake8
|
- repo: https://github.com/PyCQA/flake8
|
||||||
rev: 3.9.2
|
rev: 5.0.4
|
||||||
hooks:
|
hooks:
|
||||||
- id: flake8
|
- id: flake8
|
||||||
args:
|
args:
|
||||||
|
@ -42,7 +42,7 @@ repos:
|
||||||
- --max-line-length=88
|
- --max-line-length=88
|
||||||
|
|
||||||
- repo: https://github.com/pre-commit/mirrors-mypy
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
||||||
rev: v0.961
|
rev: v0.981
|
||||||
hooks:
|
hooks:
|
||||||
- id: mypy
|
- id: mypy
|
||||||
args:
|
args:
|
||||||
|
@ -52,11 +52,11 @@ repos:
|
||||||
additional_dependencies: [types-requests]
|
additional_dependencies: [types-requests]
|
||||||
|
|
||||||
- repo: https://github.com/codespell-project/codespell
|
- repo: https://github.com/codespell-project/codespell
|
||||||
rev: v2.1.0
|
rev: v2.2.1
|
||||||
hooks:
|
hooks:
|
||||||
- id: codespell
|
- id: codespell
|
||||||
args:
|
args:
|
||||||
- --ignore-words-list=ans,crate,fo,followings,hist,iff,mater,secant,som,sur,tim
|
- --ignore-words-list=ans,crate,damon,fo,followings,hist,iff,mater,secant,som,sur,tim,zar
|
||||||
- --skip="./.*,./strings/dictionary.txt,./strings/words.txt,./project_euler/problem_022/p022_names.txt"
|
- --skip="./.*,./strings/dictionary.txt,./strings/words.txt,./project_euler/problem_022/p022_names.txt"
|
||||||
exclude: |
|
exclude: |
|
||||||
(?x)^(
|
(?x)^(
|
||||||
|
|
|
@ -377,7 +377,7 @@ class Deque:
|
||||||
me = self._front
|
me = self._front
|
||||||
oth = other._front
|
oth = other._front
|
||||||
|
|
||||||
# if the length of the deques are not the same, they are not equal
|
# if the length of the dequeues are not the same, they are not equal
|
||||||
if len(self) != len(other):
|
if len(self) != len(other):
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -52,7 +52,7 @@ def power_iteration(
|
||||||
# or when we have small changes from one iteration to next.
|
# or when we have small changes from one iteration to next.
|
||||||
|
|
||||||
convergence = False
|
convergence = False
|
||||||
lamda_previous = 0
|
lambda_previous = 0
|
||||||
iterations = 0
|
iterations = 0
|
||||||
error = 1e12
|
error = 1e12
|
||||||
|
|
||||||
|
@ -64,21 +64,21 @@ def power_iteration(
|
||||||
# Find rayleigh quotient
|
# Find rayleigh quotient
|
||||||
# (faster than usual b/c we know vector is normalized already)
|
# (faster than usual b/c we know vector is normalized already)
|
||||||
vectorH = vector.conj().T if is_complex else vector.T
|
vectorH = vector.conj().T if is_complex else vector.T
|
||||||
lamda = np.dot(vectorH, np.dot(input_matrix, vector))
|
lambda_ = np.dot(vectorH, np.dot(input_matrix, vector))
|
||||||
|
|
||||||
# Check convergence.
|
# Check convergence.
|
||||||
error = np.abs(lamda - lamda_previous) / lamda
|
error = np.abs(lambda_ - lambda_previous) / lambda_
|
||||||
iterations += 1
|
iterations += 1
|
||||||
|
|
||||||
if error <= error_tol or iterations >= max_iterations:
|
if error <= error_tol or iterations >= max_iterations:
|
||||||
convergence = True
|
convergence = True
|
||||||
|
|
||||||
lamda_previous = lamda
|
lambda_previous = lambda_
|
||||||
|
|
||||||
if is_complex:
|
if is_complex:
|
||||||
lamda = np.real(lamda)
|
lambda_ = np.real(lambda_)
|
||||||
|
|
||||||
return lamda, vector
|
return lambda_, vector
|
||||||
|
|
||||||
|
|
||||||
def test_power_iteration() -> None:
|
def test_power_iteration() -> None:
|
||||||
|
|
|
@ -145,7 +145,7 @@ class SmoSVM:
|
||||||
if self._is_unbound(i2):
|
if self._is_unbound(i2):
|
||||||
self._error[i2] = 0
|
self._error[i2] = 0
|
||||||
|
|
||||||
# Predict test samles
|
# Predict test samples
|
||||||
def predict(self, test_samples, classify=True):
|
def predict(self, test_samples, classify=True):
|
||||||
|
|
||||||
if test_samples.shape[1] > self.samples.shape[1]:
|
if test_samples.shape[1] > self.samples.shape[1]:
|
||||||
|
|
|
@ -8,7 +8,7 @@ Hexagonal H(n) = n * (2 * n − 1) 1, 6, 15, 28, 45, ...
|
||||||
It can be verified that T(285) = P(165) = H(143) = 40755.
|
It can be verified that T(285) = P(165) = H(143) = 40755.
|
||||||
|
|
||||||
Find the next triangle number that is also pentagonal and hexagonal.
|
Find the next triangle number that is also pentagonal and hexagonal.
|
||||||
All trinagle numbers are hexagonal numbers.
|
All triangle numbers are hexagonal numbers.
|
||||||
T(2n-1) = n * (2 * n - 1) = H(n)
|
T(2n-1) = n * (2 * n - 1) = H(n)
|
||||||
So we shall check only for hexagonal numbers which are also pentagonal.
|
So we shall check only for hexagonal numbers which are also pentagonal.
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -62,7 +62,7 @@ def non_bouncy_upto(n: int) -> int:
|
||||||
|
|
||||||
def solution(num_digits: int = 100) -> int:
|
def solution(num_digits: int = 100) -> int:
|
||||||
"""
|
"""
|
||||||
Caclulate the number of non-bouncy numbers less than a googol.
|
Calculate the number of non-bouncy numbers less than a googol.
|
||||||
>>> solution(6)
|
>>> solution(6)
|
||||||
12951
|
12951
|
||||||
>>> solution(10)
|
>>> solution(10)
|
||||||
|
|
|
@ -307,6 +307,6 @@ if __name__ == "__main__":
|
||||||
)
|
)
|
||||||
# print sequence of finished processes
|
# print sequence of finished processes
|
||||||
print(
|
print(
|
||||||
f"sequnece of finished processes:\
|
f"sequence of finished processes:\
|
||||||
{mlfq.calculate_sequence_of_finish_queue()}"
|
{mlfq.calculate_sequence_of_finish_queue()}"
|
||||||
)
|
)
|
||||||
|
|
|
@ -14,7 +14,8 @@ headers = {
|
||||||
|
|
||||||
|
|
||||||
def download_images_from_google_query(query: str = "dhaka", max_images: int = 5) -> int:
|
def download_images_from_google_query(query: str = "dhaka", max_images: int = 5) -> int:
|
||||||
"""Searches google using the provided query term and downloads the images in a folder.
|
"""
|
||||||
|
Searches google using the provided query term and downloads the images in a folder.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
query : The image search term to be provided by the user. Defaults to
|
query : The image search term to be provided by the user. Defaults to
|
||||||
|
|
Loading…
Reference in New Issue
Block a user