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

Buffer dtype mismatch, expected 'long' but got 'long long' #14

Closed
malkwax opened this issue Feb 9, 2018 · 8 comments
Closed

Buffer dtype mismatch, expected 'long' but got 'long long' #14

malkwax opened this issue Feb 9, 2018 · 8 comments

Comments

@malkwax
Copy link

malkwax commented Feb 9, 2018

hi, there is an error when I get nodal stress using NodalStress() method. I use the rst file in your closed issues "test_pyansys.rst".
I guess there is something wrong with numpy.int64 type.

the code is below:

stress = result.NodalStress(0)
Traceback (most recent call last):

  File "<ipython-input-12-6342d70f8bcd>", line 1, in <module>
    stress = result.NodalStress(0)

  File "C:\Users\zxmy\Anaconda3\lib\site-packages\pyansys\binary_reader.py", line 977, in NodalStress
    self.edge_idx.astype(np.int64))

  File "pyansys/cython/_rstHelper.pyx", line 158, in pyansys._rstHelper.LoadStress

ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'
@akaszynski
Copy link
Collaborator

Didn't test the latest release on windows. I'll post an update shortly.

@malkwax
Copy link
Author

malkwax commented Feb 9, 2018

thanks for your effort. I like it .

@akaszynski
Copy link
Collaborator

Fixed the code. Thanks for posting the bug reports!

@malkwax
Copy link
Author

malkwax commented Feb 10, 2018

I install the update, but the bug is still there.
`stress=result.NodalStress(0)
Traceback (most recent call last):

File "", line 1, in
stress=result.NodalStress(0)

File "C:\Users\zxmy\Anaconda3\lib\site-packages\pyansys\binary_reader.py", line 979, in NodalStress
self.edge_idx.astype(c_long))

File "pyansys\cython_rstHelper.pyx", line 192, in pyansys._rstHelper.LoadStress

ValueError: Buffer dtype mismatch, expected 'long' but got 'long long'`

@akaszynski
Copy link
Collaborator

Try the new version 0.22.3 please. It’s here and on pypi.

@malkwax
Copy link
Author

malkwax commented Feb 10, 2018

yes. it is perfect. thank you very much.

@akaszynski
Copy link
Collaborator

Ok. I'm closing this issue then. Thanks for testing it out. I'll be a bit more diligent about keeping cython platform independent. To anyone out there who's looking to make platform independent code when using numpy and cython, use the following:

from libc.stdint cimport int32_t, int64_t
# instead of int and long

Otherwise, you'll run into issues where an np.int64 is a long for linux and a long long for windows.

@jay-thakur
Copy link

Ok. I'm closing this issue then. Thanks for testing it out. I'll be a bit more diligent about keeping cython platform independent. To anyone out there who's looking to make platform independent code when using numpy and cython, use the following:

from libc.stdint cimport int32_t, int64_t
# instead of int and long

Otherwise, you'll run into issues where an np.int64 is a long for linux and a long long for windows.

Hi @akaszynski ,

I am facing similar issue while running a git code on windows, posted issue here . Could you please help me.

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

3 participants