Merge branch 'master' into patch-1

This commit is contained in:
Charlie Miller 2024-01-15 09:20:38 +00:00 committed by GitHub
commit 24b3d42ff2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 34 additions and 27 deletions

View File

@ -10,7 +10,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v4 - uses: actions/setup-python@v5
with: with:
python-version: 3.12 python-version: 3.12
allow-prereleases: true allow-prereleases: true
@ -25,10 +25,10 @@ jobs:
- name: Run tests - name: Run tests
# TODO: #8818 Re-enable quantum tests # TODO: #8818 Re-enable quantum tests
run: pytest run: pytest
--ignore=quantum/q_fourier_transform.py --ignore=quantum/q_fourier_transform.py
--ignore=project_euler/ --ignore=project_euler/
--ignore=scripts/validate_solutions.py --ignore=scripts/validate_solutions.py
--cov-report=term-missing:skip-covered --cov-report=term-missing:skip-covered
--cov=. . --cov=. .
- if: ${{ success() }} - if: ${{ success() }}
run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md run: scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md

View File

@ -9,14 +9,14 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
fetch-depth: 0 fetch-depth: 0
- uses: actions/setup-python@v4 - uses: actions/setup-python@v5
with: with:
python-version: 3.x python-version: 3.x
- name: Write DIRECTORY.md - name: Write DIRECTORY.md
run: | run: |
scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md scripts/build_directory_md.py 2>&1 | tee DIRECTORY.md
git config --global user.name github-actions git config --global user.name "$GITHUB_ACTOR"
git config --global user.email '${GITHUB_ACTOR}@users.noreply.github.com' 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 git remote set-url origin https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY
- name: Update DIRECTORY.md - name: Update DIRECTORY.md
run: | run: |

View File

@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v4 - uses: actions/setup-python@v5
with: with:
python-version: 3.x python-version: 3.x
- name: Install pytest and pytest-cov - name: Install pytest and pytest-cov
@ -27,7 +27,7 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: actions/setup-python@v4 - uses: actions/setup-python@v5
with: with:
python-version: 3.x python-version: 3.x
- name: Install pytest and requests - name: Install pytest and requests

View File

@ -11,6 +11,6 @@ jobs:
ruff: ruff:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- run: pip install --user ruff - run: pip install --user ruff
- run: ruff --output-format=github . - run: ruff --output-format=github .

View File

@ -13,10 +13,10 @@ repos:
- repo: https://github.com/MarcoGorelli/auto-walrus - repo: https://github.com/MarcoGorelli/auto-walrus
rev: v0.2.2 rev: v0.2.2
hooks: hooks:
- id: auto-walrus - id: auto-walrus
- repo: https://github.com/astral-sh/ruff-pre-commit - repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.1.9 rev: v0.1.11
hooks: hooks:
- id: ruff - id: ruff
@ -59,3 +59,9 @@ repos:
- --install-types # See mirrors-mypy README.md - --install-types # See mirrors-mypy README.md
- --non-interactive - --non-interactive
additional_dependencies: [types-requests] additional_dependencies: [types-requests]
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.1.0"
hooks:
- id: prettier
types_or: [toml, yaml]

View File

@ -631,7 +631,6 @@
* [Floor](maths/floor.py) * [Floor](maths/floor.py)
* [Gamma](maths/gamma.py) * [Gamma](maths/gamma.py)
* [Gaussian](maths/gaussian.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) * [Gcd Of N Numbers](maths/gcd_of_n_numbers.py)
* [Germain Primes](maths/germain_primes.py) * [Germain Primes](maths/germain_primes.py)
* [Greatest Common Divisor](maths/greatest_common_divisor.py) * [Greatest Common Divisor](maths/greatest_common_divisor.py)
@ -791,6 +790,7 @@
* Activation Functions * Activation Functions
* [Binary Step](neural_network/activation_functions/binary_step.py) * [Binary Step](neural_network/activation_functions/binary_step.py)
* [Exponential Linear Unit](neural_network/activation_functions/exponential_linear_unit.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) * [Leaky Rectified Linear Unit](neural_network/activation_functions/leaky_rectified_linear_unit.py)
* [Mish](neural_network/activation_functions/mish.py) * [Mish](neural_network/activation_functions/mish.py)
* [Rectified Linear Unit](neural_network/activation_functions/rectified_linear_unit.py) * [Rectified Linear Unit](neural_network/activation_functions/rectified_linear_unit.py)

View File

@ -11,8 +11,7 @@ from rich import console as rich_console
from rich import table as rich_table from rich import table as rich_table
LIMIT = 10 LIMIT = 10
TODAY = datetime.now() TODAY = datetime.now(tz=UTC)
API_URL = ( API_URL = (
"https://www.forbes.com/forbesapi/person/rtb/0/position/true.json" "https://www.forbes.com/forbesapi/person/rtb/0/position/true.json"
"?fields=personName,gender,source,countryOfCitizenship,birthDate,finalWorth" "?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. """Calculates age from given unix time format.
Returns: Returns:
@ -46,8 +45,9 @@ def calculate_age(unix_timestamp: float) -> str:
return str(age) return str(age)
def get_forbes_real_time_billionaires() -> list[dict[str, str]]: def get_forbes_real_time_billionaires() -> list[dict[str, int | str]]:
"""Get top 10 realtime billionaires using forbes API. """
Get the top 10 real-time billionaires using Forbes API.
Returns: Returns:
List of top 10 realtime billionaires data. List of top 10 realtime billionaires data.
@ -60,21 +60,22 @@ def get_forbes_real_time_billionaires() -> list[dict[str, str]]:
"Country": person["countryOfCitizenship"], "Country": person["countryOfCitizenship"],
"Gender": person["gender"], "Gender": person["gender"],
"Worth ($)": f"{person['finalWorth'] / 1000:.1f} Billion", "Worth ($)": f"{person['finalWorth'] / 1000:.1f} Billion",
"Age": calculate_age(person["birthDate"]), "Age": years_old(person["birthDate"]),
} }
for person in response_json["personList"]["personsLists"] for person in response_json["personList"]["personsLists"]
] ]
def display_billionaires(forbes_billionaires: list[dict[str, str]]) -> None: def display_billionaires(forbes_billionaires: list[dict[str, int | str]]) -> None:
"""Display Forbes real time billionaires in a rich table. """
Display Forbes real-time billionaires in a rich table.
Args: Args:
forbes_billionaires (list): Forbes top 10 real time billionaires forbes_billionaires (list): Forbes top 10 real-time billionaires
""" """
table = rich_table.Table( 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", style="green",
highlight=True, highlight=True,
box=box.SQUARE, box=box.SQUARE,