mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-02-07 10:00:55 +00:00
Merge branch 'master' into patch-1
This commit is contained in:
commit
24b3d42ff2
12
.github/workflows/build.yml
vendored
12
.github/workflows/build.yml
vendored
|
@ -10,7 +10,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.12
|
||||
allow-prereleases: true
|
||||
|
@ -25,10 +25,10 @@ jobs:
|
|||
- name: Run tests
|
||||
# TODO: #8818 Re-enable quantum tests
|
||||
run: pytest
|
||||
--ignore=quantum/q_fourier_transform.py
|
||||
--ignore=project_euler/
|
||||
--ignore=scripts/validate_solutions.py
|
||||
--cov-report=term-missing:skip-covered
|
||||
--cov=. .
|
||||
--ignore=quantum/q_fourier_transform.py
|
||||
--ignore=project_euler/
|
||||
--ignore=scripts/validate_solutions.py
|
||||
--cov-report=term-missing:skip-covered
|
||||
--cov=. .
|
||||
- if: ${{ success() }}
|
||||
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
|
||||
|
|
6
.github/workflows/directory_writer.yml
vendored
6
.github/workflows/directory_writer.yml
vendored
|
@ -9,14 +9,14 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
- name: Write DIRECTORY.md
|
||||
run: |
|
||||
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
|
||||
git config --global user.name github-actions
|
||||
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com'
|
||||
git config --global user.name "$GITHUB_ACTOR"
|
||||
git config --global user.email "$GITHUB_ACTOR@users.noreply.github.com"
|
||||
git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
|
||||
- name: Update DIRECTORY.md
|
||||
run: |
|
||||
|
|
4
.github/workflows/project_euler.yml
vendored
4
.github/workflows/project_euler.yml
vendored
|
@ -15,7 +15,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
- name: Install pytest and pytest-cov
|
||||
|
@ -27,7 +27,7 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/setup-python@v4
|
||||
- uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: 3.x
|
||||
- name: Install pytest and requests
|
||||
|
|
6
.github/workflows/ruff.yml
vendored
6
.github/workflows/ruff.yml
vendored
|
@ -11,6 +11,6 @@ jobs:
|
|||
ruff:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- run: pip install --user ruff
|
||||
- run: ruff --output-format=github .
|
||||
- uses: actions/checkout@v4
|
||||
- run: pip install --user ruff
|
||||
- run: ruff --output-format=github .
|
||||
|
|
|
@ -13,10 +13,10 @@ repos:
|
|||
- repo: https://github.com/MarcoGorelli/auto-walrus
|
||||
rev: v0.2.2
|
||||
hooks:
|
||||
- id: auto-walrus
|
||||
- id: auto-walrus
|
||||
|
||||
- repo: https://github.com/astral-sh/ruff-pre-commit
|
||||
rev: v0.1.9
|
||||
rev: v0.1.11
|
||||
hooks:
|
||||
- id: ruff
|
||||
|
||||
|
@ -59,3 +59,9 @@ repos:
|
|||
- --install-types # See mirrors-mypy README.md
|
||||
- --non-interactive
|
||||
additional_dependencies: [types-requests]
|
||||
|
||||
- repo: https://github.com/pre-commit/mirrors-prettier
|
||||
rev: "v3.1.0"
|
||||
hooks:
|
||||
- id: prettier
|
||||
types_or: [toml, yaml]
|
||||
|
|
|
@ -631,7 +631,6 @@
|
|||
* [Floor](maths/floor.py)
|
||||
* [Gamma](maths/gamma.py)
|
||||
* [Gaussian](maths/gaussian.py)
|
||||
* [Gaussian Error Linear Unit](maths/gaussian_error_linear_unit.py)
|
||||
* [Gcd Of N Numbers](maths/gcd_of_n_numbers.py)
|
||||
* [Germain Primes](maths/germain_primes.py)
|
||||
* [Greatest Common Divisor](maths/greatest_common_divisor.py)
|
||||
|
@ -791,6 +790,7 @@
|
|||
* Activation Functions
|
||||
* [Binary Step](neural_network/activation_functions/binary_step.py)
|
||||
* [Exponential Linear Unit](neural_network/activation_functions/exponential_linear_unit.py)
|
||||
* [Gaussian Error Linear Unit](neural_network/activation_functions/gaussian_error_linear_unit.py)
|
||||
* [Leaky Rectified Linear Unit](neural_network/activation_functions/leaky_rectified_linear_unit.py)
|
||||
* [Mish](neural_network/activation_functions/mish.py)
|
||||
* [Rectified Linear Unit](neural_network/activation_functions/rectified_linear_unit.py)
|
||||
|
|
|
@ -11,8 +11,7 @@ from rich import console as rich_console
|
|||
from rich import table as rich_table
|
||||
|
||||
LIMIT = 10
|
||||
TODAY = datetime.now()
|
||||
|
||||
TODAY = datetime.now(tz=UTC)
|
||||
API_URL = (
|
||||
"https://www.forbes.com/forbesapi/person/rtb/0/position/true.json"
|
||||
"?fields=personName,gender,source,countryOfCitizenship,birthDate,finalWorth"
|
||||
|
@ -20,7 +19,7 @@ API_URL = (
|
|||
)
|
||||
|
||||
|
||||
def calculate_age(unix_timestamp: float) -> str:
|
||||
def years_old(unix_timestamp: float) -> str:
|
||||
"""Calculates age from given unix time format.
|
||||
|
||||
Returns:
|
||||
|
@ -46,8 +45,9 @@ def calculate_age(unix_timestamp: float) -> str:
|
|||
return str(age)
|
||||
|
||||
|
||||
def get_forbes_real_time_billionaires() -> list[dict[str, str]]:
|
||||
"""Get top 10 realtime billionaires using forbes API.
|
||||
def get_forbes_real_time_billionaires() -> list[dict[str, int | str]]:
|
||||
"""
|
||||
Get the top 10 real-time billionaires using Forbes API.
|
||||
|
||||
Returns:
|
||||
List of top 10 realtime billionaires data.
|
||||
|
@ -60,21 +60,22 @@ def get_forbes_real_time_billionaires() -> list[dict[str, str]]:
|
|||
"Country": person["countryOfCitizenship"],
|
||||
"Gender": person["gender"],
|
||||
"Worth ($)": f"{person['finalWorth'] / 1000:.1f} Billion",
|
||||
"Age": calculate_age(person["birthDate"]),
|
||||
"Age": years_old(person["birthDate"]),
|
||||
}
|
||||
for person in response_json["personList"]["personsLists"]
|
||||
]
|
||||
|
||||
|
||||
def display_billionaires(forbes_billionaires: list[dict[str, str]]) -> None:
|
||||
"""Display Forbes real time billionaires in a rich table.
|
||||
def display_billionaires(forbes_billionaires: list[dict[str, int | str]]) -> None:
|
||||
"""
|
||||
Display Forbes real-time billionaires in a rich table.
|
||||
|
||||
Args:
|
||||
forbes_billionaires (list): Forbes top 10 real time billionaires
|
||||
forbes_billionaires (list): Forbes top 10 real-time billionaires
|
||||
"""
|
||||
|
||||
table = rich_table.Table(
|
||||
title=f"Forbes Top {LIMIT} Real Time Billionaires at {TODAY:%Y-%m-%d %H:%M}",
|
||||
title=f"Forbes Top {LIMIT} Real-Time Billionaires at {TODAY:%Y-%m-%d %H:%M}",
|
||||
style="green",
|
||||
highlight=True,
|
||||
box=box.SQUARE,
|
||||
|
|
Loading…
Reference in New Issue
Block a user