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

Numpy frame #739

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/pyclaw/solution.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@ def get_clawpack_dot_xxx(modname): return modname.rpartition('.')[0]
if len(arg) == 1:
# Load frame
frame = arg[0]
if not isinstance(frame,int):
raise Exception('Invalid pyclaw.Solution object initialization')
frame = int(frame)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a reason not to just do frame = int(arg[0])?

Copy link
Author

@giboul giboul Dec 6, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that the error traceback is slighly more clear by explicitly saying frame is the issue:

    frame = int(frame)
            ^^^^^^^^^^
ValueError: invalid literal for int() with base 10: '_1_'

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, good point. Not sure what is better I guess then.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well... 'frame' still appears in frame = int(arg[0]) so I commited that change. Funny how it takes me 5 commits to change two lines.

if ('count_from_zero' in kargs):
if (kargs['count_from_zero'] == True):
self._start_frame = 0
Expand Down Expand Up @@ -178,7 +177,7 @@ def get_clawpack_dot_xxx(modname): return modname.rpartition('.')[0]
raise Exception("Invalid arguments for Solution initialization.")
elif len(arg) == 0:
if 'frame' in kargs:
frame = kargs.pop('frame')
frame = int(kargs.pop('frame'))
self.read(frame,**kargs)
elif not kargs:
pass # With no arguments, initialize empty solution
Expand Down
Loading