Skip to content
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

ValueError: Buffer dtype mismatch, expected 'Py_ssize_t' but got 'long' #39

Open
iop04329 opened this issue Jul 14, 2020 · 2 comments
Open

Comments

@iop04329
Copy link

iop04329 commented Jul 14, 2020

My environment is windows10 and install all package the project need.
Cython 0.29.20
numpy 1.19.0
scipy 1.5.1
scikit-learn 0.23.1
nose 1.3.7

I have been setup ok already ,and after successfully installing the ristretto library.
The unit tests can be run by: python setup.py test
When i run this code and show an error below:

(rnmf) C:\Users\tsai\Desktop\ristretto-master>python setup.py test
running test
WARNING: Testing via this command is deprecated and will be removed in a future version. Users looking for a generic test entry point independent of test runner are encouraged to use tox.
running egg_info
writing ristretto.egg-info\PKG-INFO
writing dependency_links to ristretto.egg-info\dependency_links.txt
writing requirements to ristretto.egg-info\requires.txt
writing top-level names to ristretto.egg-info\top_level.txt
reading manifest file 'ristretto.egg-info\SOURCES.txt'
reading manifest template 'MANIFEST.in'
warning: no files found matching '.c' under directory 'ristretto'
warning: no files found matching '
.pyx' under directory 'ristretto'
warning: no files found matching 'README.md'
writing manifest file 'ristretto.egg-info\SOURCES.txt'
running build_ext
C:\Users\tsai\anaconda3\envs\rnmf\lib\site-packages\sklearn\utils\deprecation.py:143: FutureWarning: The sklearn.decomposition.cdnmf_fast module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.decomposition. Anything that cannot be imported from sklearn.decomposition is now part of the private API.
warnings.warn(message, FutureWarning)
C:\Users\tsai\anaconda3\envs\rnmf\lib\site-packages\sklearn\utils\deprecation.py:143: FutureWarning: The sklearn.decomposition.nmf module is deprecated in version 0.22 and will be removed in version 0.24. The corresponding classes / functions should instead be imported from sklearn.decomposition. Anything that cannot be imported from sklearn.decomposition is now part of the private API.
warnings.warn(message, FutureWarning)
test_sketches.test_random_axis_sample ... ok
test_sketches.test_random_gaussian_map ... ok
test_sketches.test_sparse_random_map ... ok
test_transforms.test_randomized_uniform_sampling ... ok
test_transforms.test_johnson_linderstrauss ... ok
test_transforms.test_sparse_johnson_linderstrauss ... ok
test_transforms.test_fast_johnson_linderstrauss ... ok
test_utils.test_orthonormalize ... ok
test_utils.test_perform_subspace_iterations ... ok
ristretto.tests.test_cur.test_compute_cur ... C:\Users\tsai\Desktop\ristretto-master\ristretto\utils.py:12: DeprecationWarning: Converting np.complex to a dtype is deprecated. The current result is complex128 which is not strictly correct.
if A.dtype == np.complexfloating:
ok
ristretto.tests.test_cur.test_compute_rcur ... ok
ristretto.tests.test_dmd.test_dmd ... ok
ristretto.tests.test_dmd.test_compute_rdmd ... ok
ristretto.tests.test_dmd.test_DMD ... ok
ristretto.tests.test_dmd.test_RDMD ... ok
ristretto.tests.test_eigen.test_compute_reigh_float64 ... ok
ristretto.tests.test_eigen.test_compute_reigh_complex128 ... ok
ristretto.tests.test_eigen.test_reig_nystroem_float64 ... ok
ristretto.tests.test_eigen.test_reig_nystroem_complex128 ... ok
ristretto.tests.test_eigen.test_reig_nystroem_col_float64 ... ok
ristretto.tests.test_eigen.test_reig_nystroem_col_complex128 ... ok
ristretto.tests.test_interp_decomp.test_id_col ... ok
ristretto.tests.test_interp_decomp.test_id_row ... ok
ristretto.tests.test_interp_decomp.test_rid_col ... ok
ristretto.tests.test_interp_decomp.test_rid_row ... ok
ristretto.tests.test_lu.test_compute_rlu_float64 ... ok
ristretto.tests.test_lu.test_compute_rlu_complex128 ... ok
ristretto.tests.test_nmf.test_nmf_fhals ... ERROR
ristretto.tests.test_nmf.test_rnmf_fhals ... ERROR
ristretto.tests.test_pca.test_spca ... ok
ristretto.tests.test_pca.test_robspca ... ok
ristretto.tests.test_pca.test_rspca ... ok
ristretto.tests.test_qb.test_rqb_float64 ... ok
ristretto.tests.test_qb.test_rqb_complex128 ... ok
ristretto.tests.test_qb.test_rqb_block_float64 ... ok
ristretto.tests.test_qb.test_rqb_block_wide_float64 ... ok
ristretto.tests.test_qb.test_rqb_block_complex128 ... ok
ristretto.tests.test_qb.test_rqb_block_wide_complex128 ... ok
ristretto.tests.test_svd.test_compute_rsvd_float64 ... ok
ristretto.tests.test_svd.test_compute_rsvd_complex128 ... ok

======================================================================
ERROR: ristretto.tests.test_nmf.test_nmf_fhals

Traceback (most recent call last):
File "C:\Users\tsai\anaconda3\envs\rnmf\lib\site-packages\nose\case.py", line 198, in runTest
self.test(*self.arg)
File "C:\Users\tsai\Desktop\ristretto-master\ristretto\tests\test_nmf.py", line 15, in test_nmf_fhals
W, H = compute_nmf(Anoisy, rank=10)
File "C:\Users\tsai\Desktop\ristretto-master\ristretto\nmf.py", line 154, in compute_nmf
violation = _update_cdnmf_fast(Ht, WtW, AtW, permutation)
File "sklearn\decomposition_cdnmf_fast.pyx", line 13, in sklearn.decomposition._cdnmf_fast._update_cdnmf_fast
ValueError: Buffer dtype mismatch, expected 'Py_ssize_t' but got 'long'

======================================================================
ERROR: ristretto.tests.test_nmf.test_rnmf_fhals

Traceback (most recent call last):
File "C:\Users\tsai\anaconda3\envs\rnmf\lib\site-packages\nose\case.py", line 198, in runTest
self.test(*self.arg)
File "C:\Users\tsai\Desktop\ristretto-master\ristretto\tests\test_nmf.py", line 26, in test_rnmf_fhals
W, H = compute_rnmf(Anoisy, rank=10)
File "C:\Users\tsai\Desktop\ristretto-master\ristretto\nmf.py", line 335, in compute_rnmf
violation = _update_cdnmf_fast(Ht, WtW, BtW, permutation)
File "sklearn\decomposition_cdnmf_fast.pyx", line 13, in sklearn.decomposition._cdnmf_fast._update_cdnmf_fast
ValueError: Buffer dtype mismatch, expected 'Py_ssize_t' but got 'long'


Ran 40 tests in 0.850s

FAILED (errors=2)
Test failed: <unittest.runner.TextTestResult run=40 errors=2 failures=0>
error: Test failed: <unittest.runner.TextTestResult run=40 errors=2 failures=0>

@iop04329
Copy link
Author

iop04329 commented Jul 14, 2020

I debug the problem from this issue
https://stackoverflow.com/questions/61369007/expected-py-ssize-t-but-got-long
The variable permutation the type is Array of int32 is error
Using this code to change type to Array of int64:
permutation = permutation.astype(np.intp) under the permutation = random_state.permutation(rank) if shuffle else np.arange(rank)
It will work !
nmf is also.

@erichson
Copy link
Owner

@tsaigaga thanks for spotting this. Do you like to push the fix to the package?

Best,
ben

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants