-
Notifications
You must be signed in to change notification settings - Fork 31
new clawutil.util module containing fullpath_import #186
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
Conversation
mandli
left a comment
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.
I think this will be nice to have! There were a couple of thoughts I had, but I think the only question I would have is what would happen if say topotools was already imported and you called fullpath_import('/path/to/my/topotools.py')? I don't think it will import the new one, which may be confusing.
|
@mandli and I played around with this a bit and it seems to work fairly robustly, although we don't really understand how I did a test where I copied Note that Also, as expected, Reloading by using |
|
I should have pointed to this earlier, but could we use this function instead of what is in the |
|
Wow, this has actually uncovered a significant bug! One that has been in my code probably since I wrote it back during my PhD. Not sure how this didn't cause problems before. It's a rather annoying issue: in SharpClaw, there are different options for limiting -- you can limit based on waves, or based on conserved quantities. But that means that the size of the I guess the right thing would be to make this array get resized based on which kind of limiting is selected, but that seems awkward and the truth is we almost never use the flexibility of applying different limiters to different fields. So I'm tempted to just say that if you limit conserved quantities, then you can only choose one limiter (i.e. |
I think you meant this for clawpack/pyclaw#748? |
Yes, you're right. I'll move the comment there. |
@mandli: I think you are referring to the way we need to make sure that |
|
I made the change suggested by @mandli to use Also, if it is a string that starts with Slightly simpler than having to evaluate |
|
I searched around a bit for something like I am a bit torn as to whether to suggest that we include something that would expand environment variables as I can see the argument for not doing this without explicitly doing so by the user. That being said, the security and odd path strings that would come up are probably minimal as long as we do not use this in code that will be executed often. |
|
Thanks @mandli, it's now much cleaner and also handles |
|
Last thing, may want to switch the default |
This seems to be the correct way to import a module based on its path, if it's not part of clawpack or some other package, but it has enough steps that it seems worthwhile having a function to do it. I often want to do this since I have various utility modules that I use in many different projects.
Suggestions welcome if others know more about the best way to do this.