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

[BUG] AssertionError sometimes raised in Nastran float -> string conversion #1428

Open
whophil opened this issue Aug 2, 2023 · 1 comment

Comments

@whophil
Copy link

whophil commented Aug 2, 2023

Describe the bug
AssertionError is sometimes raised in Nastran float -> string conversion

To Reproduce

from meshio.nastran._nastran import _float_to_nastran_string

f = -167.99725341796875 # a float that fails; originally it was the result of some upstream operation
_float_to_nastran_string(f)  # raises `AssertionError`

Diagnose
meshio=5.3.4

@adtzlr
Copy link

adtzlr commented Dec 6, 2023

Yes, I encountered that too. This is related to afcdfe0. It happens because the negative sign produces a string which does not meet the requirements.

Possible Solution

Change the output precision from 11 to 10 to take the possible negative sign into account.

out = np.format_float_scientific(value, exp_digits=1, precision=11).replace(

or an "adaptive" solution as proposed in #1350.

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