Skip to content

Commit

Permalink
Add from_dense and to_dense methods (python-graphblas#382)
Browse files Browse the repository at this point in the history
* Add `from_dense` and `to_dense` methods

* Add warning that `to_dense` can create very large arrays

* Add `from_iso_value`, `missing_value=` to `from_dense`, and deprecate `io.from_numpy`

* Rename `from_iso_value` to `from_scalar`

* Update `flake8-bugbear` and make improvements

* Add comment for how to create iso-valued objects with structure and scalar
  • Loading branch information
eriknw authored Feb 17, 2023
1 parent 1bbce69 commit d226a51
Show file tree
Hide file tree
Showing 21 changed files with 660 additions and 152 deletions.
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ repos:
# These versions need updated manually
- flake8==6.0.0
- flake8-comprehensions==3.10.1
- flake8-bugbear==23.1.20
- flake8-bugbear==23.2.13
- flake8-simplify==0.19.3
- repo: https://github.com/asottile/yesqa
rev: v1.4.0
Expand All @@ -71,7 +71,7 @@ repos:
additional_dependencies: [tomli]
files: ^(graphblas|docs)/
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: v0.0.241
rev: v0.0.247
hooks:
- id: ruff
- repo: https://github.com/sphinx-contrib/sphinx-lint
Expand Down
1 change: 1 addition & 0 deletions graphblas/agg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ def __getattr__(key):
f"`{key}` is specific to SuiteSparse:GraphBLAS. "
f"`gb.agg.{key}` will be removed in version 2023.9.0 or later.",
DeprecationWarning,
stacklevel=2,
)
rv = _deprecated[key]
globals()[key] = rv
Expand Down
1 change: 1 addition & 0 deletions graphblas/binary/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ def __getattr__(key):
f"`{key}` is specific to SuiteSparse:GraphBLAS. "
f"`gb.binary.{key}` will be removed in version 2023.9.0 or later.",
DeprecationWarning,
stacklevel=2,
)
rv = _deprecated[key]
globals()[key] = rv
Expand Down
5 changes: 5 additions & 0 deletions graphblas/core/automethods.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,6 +261,10 @@ def to_dcsr(self):
return self._get_value("to_dcsr")


def to_dense(self):
return self._get_value("to_dense")


def to_dict(self):
return self._get_value("to_dict")

Expand Down Expand Up @@ -389,6 +393,7 @@ def _main():
"reposition",
"ss",
"to_coo",
"to_dense",
"to_values",
}
vector = {
Expand Down
2 changes: 2 additions & 0 deletions graphblas/core/infix.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ def dup(self, dtype=None, *, clear=False, mask=None, name=None, **opts):
else:
ss = Vector.__dict__["ss"] # raise if used
to_coo = wrapdoc(Vector.to_coo)(property(automethods.to_coo))
to_dense = wrapdoc(Vector.to_dense)(property(automethods.to_dense))
to_dict = wrapdoc(Vector.to_dict)(property(automethods.to_dict))
to_values = wrapdoc(Vector.to_values)(property(automethods.to_values))
vxm = wrapdoc(Vector.vxm)(property(automethods.vxm))
Expand Down Expand Up @@ -343,6 +344,7 @@ def dup(self, dtype=None, *, clear=False, mask=None, name=None, **opts):
to_csr = wrapdoc(Matrix.to_csr)(property(automethods.to_csr))
to_dcsc = wrapdoc(Matrix.to_dcsc)(property(automethods.to_dcsc))
to_dcsr = wrapdoc(Matrix.to_dcsr)(property(automethods.to_dcsr))
to_dense = wrapdoc(Matrix.to_dense)(property(automethods.to_dense))
to_dicts = wrapdoc(Matrix.to_dicts)(property(automethods.to_dicts))
to_edgelist = wrapdoc(Matrix.to_edgelist)(property(automethods.to_edgelist))
to_values = wrapdoc(Matrix.to_values)(property(automethods.to_values))
Expand Down
Loading

0 comments on commit d226a51

Please sign in to comment.