Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding pre-commit (for linting) to test dependencies. #671

Merged
merged 4 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: pre-commit

on:
push:
branches: [main]
pull_request:
branches: [main]

jobs:
checks:
name: pre-commit hooks
runs-on: ubuntu-latest
steps:
- uses: actions/[email protected]

- uses: actions/setup-python@v5
with:
python-version: '3.10'

- uses: pre-commit/[email protected]
26 changes: 22 additions & 4 deletions cubed/array_api/statistical_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def mean(x, /, *, axis=None, keepdims=False, split_every=None):
# pair of fields needed to keep per-chunk counts and totals for computing
# the mean.
dtype = x.dtype
#TODO(#658): Should these be default dtypes?
# TODO(#658): Should these be default dtypes?
intermediate_dtype = [("n", nxp.int64), ("total", nxp.float64)]
extra_func_kwargs = dict(dtype=intermediate_dtype)
return reduction(
Expand Down Expand Up @@ -110,7 +110,16 @@ def min(x, /, *, axis=None, keepdims=False, split_every=None):


def prod(x, /, *, axis=None, dtype=None, keepdims=False, split_every=None, device=None):
dtype = _upcast_integral_dtypes(x, dtype, allowed_dtypes=("numeric", "boolean",), fname="prod", device=device)
dtype = _upcast_integral_dtypes(
x,
dtype,
allowed_dtypes=(
"numeric",
"boolean",
),
fname="prod",
device=device,
)
extra_func_kwargs = dict(dtype=dtype)
return reduction(
x,
Expand All @@ -136,7 +145,16 @@ def std(x, /, *, axis=None, correction=0.0, keepdims=False, split_every=None):


def sum(x, /, *, axis=None, dtype=None, keepdims=False, split_every=None, device=None):
dtype = _upcast_integral_dtypes(x, dtype, allowed_dtypes=("numeric", "boolean",), fname="sum", device=device)
dtype = _upcast_integral_dtypes(
x,
dtype,
allowed_dtypes=(
"numeric",
"boolean",
),
fname="sum",
device=device,
)
extra_func_kwargs = dict(dtype=dtype)
return reduction(
x,
Expand All @@ -163,7 +181,7 @@ def var(
if x.dtype not in _real_floating_dtypes:
raise TypeError("Only real floating-point dtypes are allowed in var")
dtype = x.dtype
#TODO(#658): Should these be default dtypes?
# TODO(#658): Should these be default dtypes?
intermediate_dtype = [("n", nxp.int64), ("mu", nxp.float64), ("M2", nxp.float64)]
extra_func_kwargs = dict(dtype=intermediate_dtype, correction=correction)
return reduction(
Expand Down
Loading