-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
Fixed imports in model files #224
Conversation
All of the consumption-saving model files used a style of import that didn't work when the file was run directly (rather than called as a module), even though they have a __main__ block (and main() function). This has now been fixed. Also mostly removed extraneous file RepAgentModel.py, which seems to be an old name of ConsRepAgentModel.py. This file now simply imports all of ConsRepAgentModel and warns the user to use that instead.
This addresses #182 , which was also raised by CDC today. We can also consider deleting the main() calls of all of these files and only having them in the examples that we have users put in their working folder. |
My purpose in asking for the fix was to make the various modules like ConsIndShockModel.py "portable" -- so that they would run even if moved to a different filepath. In attempting that with the revised version, I found that the lines containing "import ConsumerParameters" still did not work (from a directory other than ConsumptionSaving), but that everything worked if "import ConsumerParameters" was replaced with "import HARK.ConsumptionSaving.ConsumerParameters". I have done that replacement not only for ConsIndShockModel.py but also for all of the other .py files in the ConsumptionSaving directory, and pushed the changes back up to the QuickImportFix branch. |
Ah yes, I was running them in place. As is, the "from . import blah"
construction did not work.
…On Fri, Feb 15, 2019 at 6:46 AM Christopher Llorracc Carroll < ***@***.***> wrote:
My purpose in asking for the fix was to make the various modules like
ConsIndShockModel.py "portable" -- so that they would run even if moved to
a different filepath. In attempting that with the revised version, I found
that the lines containing "import ConsumerParameters" still did not work
(from a directory other than ConsumptionSaving), but that everything worked
if "import ConsumerParameters" was replaced with "import
HARK.ConsumptionSaving.ConsumerParameters". I have done that replacement
not only for ConsIndShockModel.py but also for all of the other .py files
in the ConsumptionSaving directory, and pushed the changes back up to the
QuickImportFix branch.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#224 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ANUQFdeE2AmFJCJZOvEMPsCTNr2ndMMjks5vNp4TgaJpZM4a8Lg7>
.
|
* Fixed imports in model files All of the consumption-saving model files used a style of import that didn't work when the file was run directly (rather than called as a module), even though they have a __main__ block (and main() function). This has now been fixed. Also mostly removed extraneous file RepAgentModel.py, which seems to be an old name of ConsRepAgentModel.py. This file now simply imports all of ConsRepAgentModel and warns the user to use that instead. * import ConsumerParameters -> import HARK.ConsumptionSaving.ConsumerParameters
For release notes: "Removed improper local package imports" |
All of the consumption-saving model files used a style of import that didn't work when the file was run directly (rather than called as a module), even though they have a main block (and main() function). This has now been fixed.
Also mostly removed extraneous file RepAgentModel.py, which seems to be an old name of ConsRepAgentModel.py. This file now simply imports all of ConsRepAgentModel and warns the user to use that instead.