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

Generalise kron to an arbitrary number of dimensions. #195

Merged
merged 4 commits into from Sep 20, 2018

Conversation

Projects
None yet
2 participants
@hameerabbasi
Collaborator

hameerabbasi commented Sep 20, 2018

Generalizes kron to an arbitrary number of dimensions.

@hameerabbasi hameerabbasi requested a review from jcrist Sep 20, 2018

@hameerabbasi

This comment has been minimized.

Collaborator

hameerabbasi commented Sep 20, 2018

cc @jcrist for review.

@codecov

This comment has been minimized.

codecov bot commented Sep 20, 2018

Codecov Report

Merging #195 into master will increase coverage by 0.06%.
The diff coverage is 100%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #195      +/-   ##
==========================================
+ Coverage   97.57%   97.63%   +0.06%     
==========================================
  Files          11       11              
  Lines        1444     1440       -4     
==========================================
- Hits         1409     1406       -3     
+ Misses         35       34       -1
Impacted Files Coverage Δ
sparse/coo/common.py 98.03% <100%> (+0.29%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f865a9...e80e957. Read the comment docs.

@@ -334,10 +334,10 @@ def test_kron(a_ndim, b_ndim):
assert_eq(sparse.kron(a, b), sol)
@pytest.mark.parametrize('ndim', [0, 1, 2])

This comment has been minimized.

@hameerabbasi

hameerabbasi Sep 20, 2018

Collaborator

This was, again, a case better handled in the dense regime, so I removed it.

@jcrist

Overall this looks pretty good to me.

a_shape = (10, 11)[:a_ndim]
b_shape = (12, 13)[:b_ndim]
a_shape = (3, 4, 5)[:a_ndim]
b_shape = (4, 5, 3)[:b_ndim]

This comment has been minimized.

@jcrist

jcrist Sep 20, 2018

Collaborator

It'd be maybe good to test:

  • Using dimensions that don't ever match up (len(set(a_shape).intersection(b_shape)) == 0) to ensure no accidental reliance on broadcasting aligning. Perhaps (3, 4, 5), and (6, 7, 8).
  • Cases with a nonzero fill value

This comment has been minimized.

@jcrist

jcrist Sep 20, 2018

Collaborator

The first one might be being overly paranoid though, feel free to ignore.

This comment has been minimized.

@hameerabbasi

hameerabbasi Sep 20, 2018

Collaborator

Ah, yes. My algorithm only works with a zero fill-value.

a_sparse = isinstance(a, SparseArray)
b_sparse = isinstance(b, SparseArray)
a_sparse = isinstance(a, (SparseArray, scipy.sparse.spmatrix))
b_sparse = isinstance(b, (SparseArray, scipy.sparse.spmatrix))

This comment has been minimized.

@jcrist

jcrist Sep 20, 2018

Collaborator

We don't ever test with a scipy.sparse.spmatrix, is this something that should also be added to the tests?

This comment has been minimized.

@hameerabbasi

hameerabbasi Sep 20, 2018

Collaborator

Added a test.

This comment has been minimized.

@hameerabbasi

hameerabbasi Sep 20, 2018

Collaborator

For future references, asCOO and the COO constructor are pretty heavily tested, so we probably don't need to test things like these everywhere.

@hameerabbasi hameerabbasi merged commit 81eccee into pydata:master Sep 20, 2018

3 checks passed

LGTM analysis: Python No alert changes
Details
ci/circleci Your tests passed on CircleCI!
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@hameerabbasi hameerabbasi deleted the hameerabbasi:kron branch Oct 22, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment