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

Nastran long support #1099

Merged
merged 2 commits into from
May 8, 2021
Merged

Nastran long support #1099

merged 2 commits into from
May 8, 2021

Conversation

Spectre5
Copy link
Contributor

@Spectre5 Spectre5 commented May 8, 2021

I've added a new test with a valid Nastran grid in long format that currently fails. The issue is that chunks2[1:3]] in the code below will only be length 1 since the second line in the test grid card is not long enough (not more than 16 characters long). This leads leads to ValueError: not enough values to unpack (expected 2, got 1).

            chunks2 = _chunk_line(next_line)
            next_line = f.readline()
            points.append(
                [
                    _nastran_string_to_float(i + j)
                    for i, j in [chunks[5:7], chunks[7:9], chunks2[1:3]]
                ]
            )

The solution I've added here is to simply use 72 for the line length instead of len(line), which will result in the fixed format line "chunks" always having 9 fields. It fills the empty ones with empty strings, ''.

@nschloe
Copy link
Owner

nschloe commented May 8, 2021

Very nice, thank you!

@nschloe nschloe merged commit d900512 into nschloe:main May 8, 2021
@Spectre5 Spectre5 deleted the nastran-long-support branch January 6, 2022 07:49
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

Successfully merging this pull request may close these issues.

2 participants