Skip to content

Remove deprecated gb.io.from_numpy (and to_numpy) #528

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 3 commits into from
Dec 17, 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
12 changes: 3 additions & 9 deletions .github/workflows/test_and_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -173,12 +173,12 @@ jobs:
# Randomly choosing versions of dependencies based on Python version works surprisingly well...
if [[ ${{ startsWith(steps.pyver.outputs.selected, '3.9') }} == true ]]; then
npver=$(python -c 'import random ; print(random.choice(["=1.21", "=1.22", "=1.23", "=1.24", "=1.25", "=1.26", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", "=1.11", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
pdver=$(python -c 'import random ; print(random.choice(["=1.2", "=1.3", "=1.4", "=1.5", "=2.0", "=2.1", ""]))')
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", "=2.3", "=2.4", "=2.5", ""]))')
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.10') }} == true ]]; then
npver=$(python -c 'import random ; print(random.choice(["=1.21", "=1.22", "=1.23", "=1.24", "=1.25", "=1.26", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.8", "=1.9", "=1.10", "=1.11", ""]))')
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
pdver=$(python -c 'import random ; print(random.choice(["=1.3", "=1.4", "=1.5", "=2.0", "=2.1", ""]))')
akver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=2.0", "=2.1", "=2.2", "=2.3", "=2.4", "=2.5", ""]))')
elif [[ ${{ startsWith(steps.pyver.outputs.selected, '3.11') }} == true ]]; then
Expand All @@ -196,9 +196,6 @@ jobs:
if [[ ${pdver} == "=2.1" && ${npver} == "=1.21" ]]; then
pdver="=2.0"
fi
if [[ ${nxver} == "=3.2" && ${spver} == "=1.8" ]]; then
spver="=1.9"
fi
if [[ ${{ steps.sourcetype.outputs.selected }} == "source" || ${{ steps.sourcetype.outputs.selected }} == "upstream" ]]; then
# TODO: there are currently issues with some numpy versions when
# installing python-suitesparse-grphblas from source or upstream.
Expand Down Expand Up @@ -230,14 +227,11 @@ jobs:
fi
if [[ ${npver} == "=1.26" ]] ; then
numbaver=""
if [[ ${spver} == "=1.8" || ${spver} == "=1.9" ]] ; then
if [[ ${spver} == "=1.9" ]] ; then
spver=$(python -c 'import random ; print(random.choice(["=1.10", "=1.11", ""]))')
fi
elif [[ ${npver} == "=1.25" ]] ; then
numbaver=""
if [[ ${spver} == "=1.8" ]] ; then
spver=$(python -c 'import random ; print(random.choice(["=1.9", "=1.10", "=1.11", ""]))')
fi
elif [[ ${npver} == "=1.24" || ${{ startsWith(steps.pyver.outputs.selected, '3.11') }} == true ]] ; then
numbaver=$(python -c 'import random ; print(random.choice(["=0.57", "=0.58", ""]))')
elif [[ ${npver} == "=1.21" ]] ; then
Expand Down
13 changes: 8 additions & 5 deletions docs/api_reference/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,18 @@ These methods require `networkx <https://networkx.org/>`_ to be installed.

.. autofunction:: graphblas.io.to_networkx

Numpy
NumPy
~~~~~

These methods require `scipy <https://scipy.org/>`_ to be installed, as some
of the scipy.sparse machinery is used during the conversion process.
These methods convert to and from dense arrays. For more, see :ref:`IO in the user guide <from-to-values>`.

.. autofunction:: graphblas.io.from_numpy
.. automethod:: graphblas.core.matrix.Matrix.from_dense

.. autofunction:: graphblas.io.to_numpy
.. automethod:: graphblas.core.matrix.Matrix.to_dense

.. automethod:: graphblas.core.vector.Vector.from_dense

.. automethod:: graphblas.core.vector.Vector.to_dense

Scipy Sparse
~~~~~~~~~~~~
Expand Down
2 changes: 1 addition & 1 deletion docs/user_guide/collections.rst
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ The shape and dtype remain unchanged, but the collection will be fully sparse (i
to_coo
~~~~~~

To go from a collection back to the index and values, ``.to_coo()`` can be called. Numpy arrays
To go from a collection back to the index and values, ``.to_coo()`` can be called. NumPy arrays
will be returned in a tuple.

.. code-block:: python
Expand Down
2 changes: 2 additions & 0 deletions docs/user_guide/io.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ Input/Output

There are several ways to get data into and out of python-graphblas.

.. _from-to-values:

From/To Values
--------------

Expand Down
1 change: 0 additions & 1 deletion graphblas/io/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from ._awkward import from_awkward, to_awkward
from ._matrixmarket import mmread, mmwrite
from ._networkx import from_networkx, to_networkx
from ._numpy import from_numpy, to_numpy # deprecated
from ._scipy import from_scipy_sparse, to_scipy_sparse
from ._sparse import from_pydata_sparse, to_pydata_sparse
104 changes: 0 additions & 104 deletions graphblas/io/_numpy.py

This file was deleted.

11 changes: 0 additions & 11 deletions graphblas/tests/test_io.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,17 +38,6 @@
suitesparse = gb.backend == "suitesparse"


@pytest.mark.skipif("not ss")
def test_deprecated():
a = np.array([0.0, 2.0, 4.1])
with pytest.warns(DeprecationWarning):
v = gb.io.from_numpy(a)
assert v.isequal(gb.Vector.from_coo([1, 2], [2.0, 4.1]), check_dtype=True)
with pytest.warns(DeprecationWarning):
a2 = gb.io.to_numpy(v)
np.testing.assert_array_equal(a, a2)


@pytest.mark.skipif("not ss")
def test_vector_to_from_numpy():
a = np.array([0.0, 2.0, 4.1])
Expand Down