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

Prevent tuple index out of range error #3

Merged
merged 1 commit into from
Sep 13, 2018
Merged

Conversation

tdj28
Copy link
Contributor

@tdj28 tdj28 commented Aug 20, 2018

The original line:

if m.shape[1] > 3:

will error out with IndexError: tuple index out of range. It's an error I get running the example program example2_cdpsPlots.py, for example. If you preface it with the conditional if len(m.shape) > 1 and, this will prevent the tuple index out of range error as Python will move on to the else statement as soon as the first conditional in a chained conditional is false.

Tested on Mac and Linux with example2_cdpsPlots.py.

The original line:

```
if m.shape[1] > 3:
```

will error out with `IndexError: tuple index out of range`. It's an error I get running the example program example2_cdpsPlots.py, for example. If you preface it with the conditional `if len(m.shape) > 1 and`, this will prevent the `tuple index out of range` error as Python will move on to the else statement as soon as the first conditional in a chained conditional is false.

Tested on Mac and Linux with example2_cdpsPlots.py.
@jamienunez jamienunez merged commit a153df5 into pnnl:master Sep 13, 2018
@jamienunez
Copy link
Collaborator

Thanks, Tim!

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.

None yet

2 participants