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

feat: initial array object implementation #1

Merged
merged 10 commits into from
Dec 27, 2023
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jobs:
strategy:
fail-fast: false
matrix:
python-version: ["3.8", "3.12"]
python-version: ["3.9", "3.12"]
runs-on: [ubuntu-latest, macos-latest, windows-latest]

include:
Expand Down
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,14 +65,6 @@ repos:
hooks:
- id: shellcheck

- repo: local
hooks:
- id: disallow-caps
name: Disallow improper capitalization
language: pygrep
entry: PyBind|Numpy|Cmake|CCache|Github|PyTest
exclude: .pre-commit-config.yaml

- repo: https://github.com/abravalheri/validate-pyproject
rev: v0.15
hooks:
Expand Down
27 changes: 22 additions & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ authors = [
description = "Ragged array library, complying with Python API specification."
readme = "README.md"
license.file = "LICENSE"
requires-python = ">=3.8"
requires-python = ">=3.9"
classifiers = [
"Development Status :: 1 - Planning",
"Intended Audience :: Science/Research",
Expand All @@ -21,7 +21,6 @@ classifiers = [
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
Expand All @@ -30,7 +29,9 @@ classifiers = [
"Typing :: Typed",
]
dynamic = ["version"]
dependencies = []
dependencies = [
"awkward",
]

[project.optional-dependencies]
test = [
Expand Down Expand Up @@ -87,7 +88,7 @@ report.exclude_also = [

[tool.mypy]
files = ["src", "tests"]
python_version = "3.8"
python_version = "3.9"
warn_unused_configs = true
strict = true
enable_error_code = ["ignore-without-code", "redundant-expr", "truthy-bool"]
Expand All @@ -100,6 +101,17 @@ module = "ragged.*"
disallow_untyped_defs = true
disallow_incomplete_defs = true

[[tool.mypy.overrides]]
module = "numpy.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "cupy.*"
ignore_missing_imports = true

[[tool.mypy.overrides]]
module = "awkward.*"
ignore_missing_imports = true

[tool.ruff]
src = ["src"]
Expand Down Expand Up @@ -132,6 +144,8 @@ ignore = [
"PLR09", # Too many <...>
"PLR2004", # Magic value used in comparison
"ISC001", # Conflicts with formatter
"RET505", # I like my if (return) elif (return) else (return) pattern
"PLR5501", # I like my if (return) elif (return) else (return) pattern
]
isort.required-imports = ["from __future__ import annotations"]
# Uncomment if using a _compat.typing backport
Expand All @@ -143,7 +157,7 @@ isort.required-imports = ["from __future__ import annotations"]


[tool.pylint]
py-version = "3.8"
py-version = "3.9"
ignore-paths = [".*/_version.py"]
reports.output-format = "colorized"
similarities.ignore-imports = "yes"
Expand All @@ -153,4 +167,7 @@ messages_control.disable = [
"line-too-long",
"missing-module-docstring",
"wrong-import-position",
"missing-class-docstring",
"missing-function-docstring",
"R1705", # I like my if (return) elif (return) else (return) pattern
]
13 changes: 7 additions & 6 deletions src/ragged/__init__.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
"""
Copyright (c) 2023 Jim Pivarski. All rights reserved.
# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE

ragged: Ragged array library, complying with Python API specification.
"""
Ragged array module.

FIXME: needs more documentation!

from __future__ import annotations
Version 2022.12 is current, so `ragged.v202212.*` is identical to `ragged.*`.
"""

from ._version import version as __version__
from __future__ import annotations

__all__ = ["__version__"]
from .v202212 import * # noqa: F403
14 changes: 14 additions & 0 deletions src/ragged/common/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE

"""
Generic definitions used by the version-specific modules, such as
`ragged.v202212`.

https://data-apis.org/array-api/latest/API_specification/
"""

from __future__ import annotations

from ._obj import array

__all__ = ["array"]
22 changes: 22 additions & 0 deletions src/ragged/common/_import.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# BSD 3-Clause License; see https://github.com/scikit-hep/ragged/blob/main/LICENSE

from __future__ import annotations

from typing import Any


def cupy() -> Any:
try:
import cupy as cp # pylint: disable=C0415

return cp
except ModuleNotFoundError as err:
error_message = """to use the "cuda" backend, you must install cupy:

pip install cupy

or

conda install -c conda-forge cupy
"""
raise ModuleNotFoundError(error_message) from err
Loading