3

I have a sparse matrix in the form of (inl, outl, 1) that I want to convert into a nxn matrix (value is 1 if there is a link between a and b).

However there are multiple b values for each a, which I believe is why the ValueError message is popping up. I've tried csr, coo, csc, bsr matrixes, to no avail...

M = coo_matrix( (yn, (inl,outl)), shape=(n,n) ).toarray()

ValueError: 'row index exceeds matrix dimensions'

Any help is greatly appreciated. Thanks!

4
  • 1
    I'd check max(inl) to see if you have a row index that's bigger than n. Commented Sep 25, 2017 at 2:58
  • max(inl) equals n... for csr error message is len(self.indptr),major_dim + 1)) -- ValueError: index pointer size 400000 should be 80000 for coo ValueError 'arr.size x arr.dtype.itemsize' is larger than maximum possible size Commented Sep 25, 2017 at 3:25
  • 1
    if you've set n = max(inl), your error is because range(n) goes from 0 to n-1. That one max data point is out of range. set n = max(inl) + 1 Commented Sep 25, 2017 at 12:14
  • nope... tried that. i'm still having problems importing and i think it has something to do with the "index pointer size" which i believe is derived from my data (where there are multiple out values for each in) rather than from my settings? sigh.. is there some other library i can use to work with sparse data? Commented Oct 1, 2017 at 22:12

1 Answer 1

0

I have tried to get the global max from both the intl and outl and it works for me. The code is as follows:

n = max(max(intl), max(outl)) + 1

I hope this would help!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.