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

Fixed imports in model files #224

Merged
merged 2 commits into from
Feb 15, 2019
Merged

Fixed imports in model files #224

merged 2 commits into from
Feb 15, 2019

Conversation

mnwhite
Copy link
Contributor

@mnwhite mnwhite commented Feb 14, 2019

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.

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.
@mnwhite
Copy link
Contributor Author

mnwhite commented Feb 14, 2019

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.

@llorracc
Copy link
Collaborator

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.

@mnwhite
Copy link
Contributor Author

mnwhite commented Feb 15, 2019 via email

@llorracc llorracc merged commit 3c3b064 into master Feb 15, 2019
llorracc pushed a commit that referenced this pull request Feb 16, 2019
* 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
@llorracc llorracc deleted the QuickImportFix branch February 16, 2019 16:40
@llorracc
Copy link
Collaborator

llorracc commented Apr 4, 2019

For release notes: "Removed improper local package imports"

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.

3 participants