-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
numpy.f2py produces wrong results for arrays of strings #4519
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
Labels
Comments
Hi, sorry to resurrect an old issue but this problem persists. Using the >>> from Fortran import chararraytest
>>> import numpy
>>> chararraytest.chararrayin(numpy.array(['1', '2', '3'], numpy.dtype(numpy.string_)))
Called "charArrayIn" with args:
1 123
2 n"
3 `
>>> I'm not sure if there's a recommended way to treat arrays of string in f2py. Sorry I can't help more as I'm not sure what's happening under the hood. |
pearu
added a commit
to pearu/numpy
that referenced
this issue
Jul 3, 2021
pearu
added a commit
to pearu/numpy
that referenced
this issue
Sep 1, 2021
pearu
added a commit
to pearu/numpy
that referenced
this issue
Sep 6, 2021
TST: added test for issue numpy#18684 ENH: f2py opens files with correct encoding, fixes numpy#635 TST: added test for issue numpy#6308 TST: added test for issue numpy#4519 TST: added test for issue numpy#3425 ENH: Implement user-defined hooks support for post-processing f2py data structure. Implement character BC hook. ENH: Add support for detecting utf-16 and utf-32 encodings.
melissawm
pushed a commit
to pearu/numpy
that referenced
this issue
Apr 4, 2022
TST: added test for issue numpy#18684 ENH: f2py opens files with correct encoding, fixes numpy#635 TST: added test for issue numpy#6308 TST: added test for issue numpy#4519 TST: added test for issue numpy#3425 ENH: Implement user-defined hooks support for post-processing f2py data structure. Implement character BC hook. ENH: Add support for detecting utf-16 and utf-32 encodings.
HaoZeke
pushed a commit
to pearu/numpy
that referenced
this issue
Jun 5, 2022
TST: added test for issue numpy#18684 ENH: f2py opens files with correct encoding, fixes numpy#635 TST: added test for issue numpy#6308 TST: added test for issue numpy#4519 TST: added test for issue numpy#3425 ENH: Implement user-defined hooks support for post-processing f2py data structure. Implement character BC hook. ENH: Add support for detecting utf-16 and utf-32 encodings.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have tried several variants with arrays of fortran-character strings and none of them did work (fixed/variable string length and array dimension).
I even tried to use iso_c_binding with 2-dimensional character(kind=C_CHAR) array, but this seemed to produces strided strings (row-/column-major reordering of the data).
I could not really find anything helpful related to this problem. In http://cens.ioc.ee/projects/f2py2e/README.html there's a remark from 2004 that this should work.
So here a simple example:
Obviously calling this function from Fortran works fine.
I can compile it using
But with my small test program I obtain strange results:
I get the following output:
When I use fixed character length strings, e.g. character(len=20), the results look similar.
System:
Debian testing, 64 bit
I also tried an installation of numpy 1.8 on another 64 bit Linux machine.
The text was updated successfully, but these errors were encountered: