-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Fix fortran char array #196
Fix fortran char array #196
Conversation
This commit addresses problems with Fortran character arrays passed to Python. The first was that the length of the character string was too short (20). The second was that only 1D arrays were managed and if the length of the character string is equal to the limit then the values in the array are not splited correctly. The max length has been increased from 20 to 128 and the associated decorator to handle character arrays has been modified to managed any nD arrays and max character length. A few tests have been added, but they don't allow you to check all the decorators correctly. It would be necessary to create a Fortran file specific to the test case.
Can't unpack tuple indices directly in arrays
setup.descriptor_name = descriptor_name | ||
assert np.array_equal(setup.descriptor_name, descriptor_name), "char_array.ndarray_nd_value" | ||
|
||
with pytest.raises(ValueError, match="could not broadcast"): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a ValueError could happen ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When a ValueError could happen ?
>>> setup, mesh = smash.factory.load_dataset('cance')
>>> model = smash.Model(setup, mesh)
>>> model.setup.nd
2
>>> model.setup.descriptor_name = ["Riri", "Fifi", "Loulou"]
ValueError: could not broadcast input array from shape (3,) into (2,)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a check when the size lchar > 128 ?
--> ok :
arr[slc] = item line 77 of _f90wrap_decorator.py
I will ! |
This commit addresses problems with Fortran character arrays passed to Python. The first was that the length of the character string was too short (20). The second was that only 1D arrays were managed and if the length of the character string is equal to the limit then the values in the array are not split correctly.
The max length has been increased from 20 to 128 and the associated decorator to handle character arrays has been modified to managed any nD arrays and max character length.
A few tests have been added, but they don't allow you to check all the decorators correctly. It would be necessary to create a Fortran file specific to the test case.