fix misc tests and mypy errors #10
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Some misc fixes to remove remaining test failures for coo-1d.
Mypy error on
dtype
not being defined in _spbase.We could set it to something expecting it to be overwritten by the subclass.
But
self.dtype.type
appeared before this PR. Turns out adding-> str
typing in the function signature line caused more strict checking by mypy. I removed the-> str
thinking we can fix the mypy error on dtype in a different PR. If you prefer we can define it to be a vaccuous value that will be overwritten. I think with typing you can also set the type without assigning a value, but that choice is yours to make. :)Mypy error on
max_size = np.prod(shape)
because the result might not be an integer. I changed it to manually multiplying the values (which is 100 times faster anyway, but is very fast for both).den.resize(arg)
was raising due to references of this array not allowing resize. So I addedrefcheck=False
which was suggested by the test message. Also the reference is what we are creating:res
and we know it isn't going to cause problems. [This occurs in 3 tests ofresize
withintest_coo.py
.]test error complaining about
intc
not equalingint32
when we usedtype(res) == type(exp)
. That idiom is used in a few other tests to check that they are both ndarrays. But in the1d_mul_vector
case, the result is a scalar. So the type becomes the dtype of the original arrays, and that can beintc
for scipy andint32
for numpy. I don't think we need to test the type of the results. We should check it is a scalar and then check that the values are equal. Checking for scalar is suggested to be done (in the np.isscalar documentation) by testing thatres.ndim == 0
. So I replace the existing test with that test. The next line checks thatres equals
exp` so they both must be scalars.errors due to bounds exceeded within
np.revel_multi_index
inside_coo_base.reshape()
. This had aTODO
comment, that took me way too long to notice, pointing to a PR where the code to handle reshaping accounts for this limitation onrevel_multi_index
. The 1d case was actually easy to handle (index is already flat). So I added code to mimic what was there before (withindices
instead ofrow
andcol
). It is passing tests and hopefully OK.I removed white space on two empty lines in
test_coo.py
.I think this could fix the failed tests in Linux Meson, Windows and Mypy. That should give us a green check if all goes well. Finger's crossed.
The upstream main can "fast-foward pull" after these changes except for some submodule updates. As far as I can tell that won't affect anything, but I don't know anything about submodule repos (except how to update them using git).