Skip to content

Add gb.MAX_SIZE, which is GrB_INDEX_MAX + 1 #519

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

Merged
merged 4 commits into from
Nov 6, 2023
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
5 changes: 5 additions & 0 deletions graphblas/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ def get_config():
backend = None
_init_params = None
_SPECIAL_ATTRS = {
"MAX_SIZE", # The maximum size of Vector and Matrix dimensions (GrB_INDEX_MAX + 1)
"Matrix",
"Recorder",
"Scalar",
Expand Down Expand Up @@ -205,6 +206,10 @@ def _load(name):
if name in {"Matrix", "Vector", "Scalar", "Recorder"}:
module = _import_module(f".core.{name.lower()}", __name__)
globals()[name] = getattr(module, name)
elif name == "MAX_SIZE":
from .core import lib

globals()[name] = lib.GrB_INDEX_MAX + 1
else:
# Everything else is a module
globals()[name] = _import_module(f".{name}", __name__)
Expand Down
4 changes: 4 additions & 0 deletions graphblas/tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,3 +90,7 @@ def test_packages():
assert (
pkgs == pkgs2
), "If there are extra items on the left, add them to pyproject.toml:tool.setuptools.packages"


def test_index_max():
assert gb.MAX_SIZE == 2**60 # True for all current backends
2 changes: 1 addition & 1 deletion scripts/test_imports.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ if ! python -c "from graphblas.select import tril" ; then exit 1 ; fi
if ! python -c "from graphblas.semiring import plus_times" ; then exit 1 ; fi
if ! python -c "from graphblas.unary import exp" ; then exit 1 ; fi
if ! (for attr in Matrix Scalar Vector Recorder agg binary dtypes exceptions \
init io monoid op select semiring tests unary ss viz
init io monoid op select semiring tests unary ss viz MAX_SIZE
do echo python -c \"from graphblas import $attr\"
if ! python -c "from graphblas import $attr"
then exit 1
Expand Down