Repository: pydata/sparse (python)

Issue:
Change CodeCov to only run if tests pass.
              > Hmm, why code coverage is dropping so much?

Because the tests didn't actually run. Speaking of, we should change it to run only if tests succeed.

_Originally posted by @hameerabbasi in https://github.com/pydata/sparse/issues/573#issuecomment-1381788687_
            

Pull request description:
Running codecov only when tests pass
<!--
# Thanks for contributing a pull request!
## Please make sure you see our contribution guidelines: https://github.com/pydata/sparse/blob/main/docs/contributing.md

Your PR title should start with any of these abbreviatons: `build`, `chore`, `ci`, `depr`, `docs`, `feat`, `fix`, `perf`, `refactor`, `release`, `test`. Add a `!`at the end, if it is a breaking change.
-->

## What type of PR is this? (check all applicable)

- [ ] 💾 Refactor
- [ ] 🪄 Feature
- [ ] 🐞 Bug Fix
- [ ] 🔧 Optimization
- [ ] 📚 Documentation
- [ ] 🧪 Test
- [x] 🛠️ Other

## Related issues

- Closes #574 

## Checklist

- [ ] Code follows style guide
- [ ] Tests added
- [ ] Documented the changes

***

## Please explain your changes below.
CodeCov will run only when all of the above steps pass.

Patch:
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index e34182d..492b67d 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -50,7 +50,6 @@ jobs:
       - name: Run tests
         run: ci/test_backends.sh
       - uses: codecov/codecov-action@v5
-        if: always()
         with:
           token: ${{ secrets.CODECOV_TOKEN }}
           files: ./**/coverage*.xml
diff --git a/sparse/numba_backend/_utils.py b/sparse/numba_backend/_utils.py
index 6fb1479..a6360a5 100644
--- a/sparse/numba_backend/_utils.py
+++ b/sparse/numba_backend/_utils.py
@@ -588,6 +588,8 @@ def check_zero_fill_value(*args, loose=True):
     ValueError: This operation requires zero fill values, but argument 1 had a fill value of 0.5.
     """
     for i, arg in enumerate(args):
+        if arg.size == 0:
+            continue
         if hasattr(arg, "fill_value") and not equivalent(arg.fill_value, _zero_of_dtype(arg.dtype), loose=loose):
             raise ValueError(
                 f"This operation requires zero fill values, but argument {i:d} had a fill value of {arg.fill_value!s}."


Test patch:
diff --git a/sparse/numba_backend/tests/test_coo.py b/sparse/numba_backend/tests/test_coo.py
index 5074088..c5882e1 100644
--- a/sparse/numba_backend/tests/test_coo.py
+++ b/sparse/numba_backend/tests/test_coo.py
@@ -6,7 +6,7 @@ import sys
 import sparse
 from sparse import COO, DOK
 from sparse.numba_backend._settings import NEP18_ENABLED
-from sparse.numba_backend._utils import assert_eq, html_table, random_value_array
+from sparse.numba_backend._utils import assert_eq, check_zero_fill_value, html_table, random_value_array
 
 import pytest
 
@@ -1918,6 +1918,16 @@ def test_to_invalid_device():
         s.to_device("invalid_device")
 
 
+# regression test for gh-877
+def test_check_zero_fill_value():
+    a = sparse.zeros((1, 0))
+    b = a - sparse.mean(a, axis=1)
+    b @ b.T  # should not raise an error
+    with pytest.raises(ValueError, match="This operation requires zero fill values"):
+        s1 = sparse.random((10,), density=0.5, fill_value=1.0)
+        check_zero_fill_value(s1)
+
+
 # regression test for gh-869
 def test_xH_x():
     Y = np.array([[0, -1j], [+1j, 0]])