diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 8852f09..1ea575d 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -27,20 +27,18 @@ jobs: - name: Test minimums run: pytest - - name: Install SciPy - # --only-binary disables compiling the package from source if a binary wheel is not available, such as PyPy - run: pip install --only-binary ":all:" scipy || true - - - name: Install python-graphblas - if: ${{ !contains(matrix.python-version, 'pypy') && matrix.python-version != '3.7' }} # no wheels for PyPy or old Python - run: | - pip install suitesparse-graphblas==7.4.4.1a1 - pip install python-graphblas - - - name: Install pydata sparse - if: ${{ !contains(matrix.python-version, 'pypy') && matrix.python-version != '3.7' }} # no wheels for PyPy or old Python + - name: Install optional dependencies + # --only-binary disables compiling the package from source if a binary wheel is not available, such as old Python or PyPy run: | - pip install sparse + echo "" + echo "=== Install SciPy =============================" + pip install --only-binary ":all:" scipy || true + echo "" + echo "=== Install python-graphblas ==================" + pip install --only-binary ":all:" python-graphblas || true + echo "" + echo "=== Install PyData/Sparse =====================" + pip install --only-binary ":all:" sparse || true - name: Test without Jupyter run: pytest diff --git a/matspy/adapters/__init__.py b/matspy/adapters/__init__.py index a33d0ee..5dac00a 100644 --- a/matspy/adapters/__init__.py +++ b/matspy/adapters/__init__.py @@ -8,7 +8,7 @@ import numpy as np -def describe(shape: tuple = None, nnz: int = None, nz_type=None, notes: str = None) -> str: +def describe(shape: tuple = None, nnz: int = None, nz_type=None, layout: str = None, notes: str = None) -> str: """ Create a simple description string from potentially interesting pieces of metadata. """ @@ -27,6 +27,9 @@ def describe(shape: tuple = None, nnz: int = None, nz_type=None, notes: str = No elif nz_type is not None: parts.append(f"'{str(nz_type)}' elements") + if layout is not None: + parts.append(str(layout)) + if notes: parts.append(notes) diff --git a/matspy/adapters/graphblas_impl.py b/matspy/adapters/graphblas_impl.py index 01ea9e1..be78387 100644 --- a/matspy/adapters/graphblas_impl.py +++ b/matspy/adapters/graphblas_impl.py @@ -56,12 +56,9 @@ def get_format(self, is_transposed=False): def describe(self) -> str: parts = [f"gb.{type(self.mat).__name__}", f"'{self.mat.dtype}'"] - fmt = self.get_format() - if fmt: - parts.append(fmt) - return describe(shape=self.mat.shape, nnz=self.mat.nvals, + layout=self.get_format(), notes=", ".join(parts)) def get_spy(self, spy_shape: tuple) -> np.array: diff --git a/matspy/adapters/numpy_impl.py b/matspy/adapters/numpy_impl.py index 97af8fb..e8fb75d 100644 --- a/matspy/adapters/numpy_impl.py +++ b/matspy/adapters/numpy_impl.py @@ -20,10 +20,7 @@ def get_shape(self) -> tuple: return self.arr.shape def describe(self) -> str: - format_name = "array" - - return describe(shape=self.arr.shape, nz_type=self.arr.dtype, - notes=f"{format_name}") + return describe(shape=self.arr.shape, nz_type=self.arr.dtype, layout="array") def get_spy(self, spy_shape: tuple) -> np.array: precision = self.get_option("precision", None) diff --git a/matspy/adapters/scipy_impl.py b/matspy/adapters/scipy_impl.py index b9c1a4b..c058f34 100644 --- a/matspy/adapters/scipy_impl.py +++ b/matspy/adapters/scipy_impl.py @@ -31,10 +31,8 @@ def get_shape(self) -> tuple: return self.mat.shape def describe(self) -> str: - format_name = self.mat.getformat() - return describe(shape=self.mat.shape, nnz=self.mat.nnz, nz_type=self.mat.dtype, - notes=f"{format_name}") + layout=self.mat.getformat()) def get_spy(self, spy_shape: tuple) -> np.array: # construct a triple product that will scale the matrix diff --git a/matspy/adapters/sparse_impl.py b/matspy/adapters/sparse_impl.py index 2682c57..079bd65 100644 --- a/matspy/adapters/sparse_impl.py +++ b/matspy/adapters/sparse_impl.py @@ -31,13 +31,14 @@ def get_shape(self) -> tuple: return self.mat.shape def describe(self) -> str: - parts = [ - self.mat.format, - ] + try: + fmt = self.mat.format + except AttributeError: + fmt = self.mat.__class__.__name__ return describe(shape=self.mat.shape, nnz=self.mat.nnz, nz_type=self.mat.dtype, - notes=", ".join(parts)) + layout=fmt) def get_spy(self, spy_shape: tuple) -> np.array: if isinstance(self.mat, sparse.DOK):