-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
fixes: #3956 Cleaned up knapsack and images directory #3972
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
There's this README file as well which probably either needs updating or should we just remove it? |
Perhaps we could get the original poster @tbsschroeder to update the README to reflect that all implementations of the knapsack problem are going to be put in one directory. Let's do this. Move the README along with the code and we will see if someone is willing to update it appropriately. If it is not updated by yearend, we can whack the README. |
Well, then this is good to go. I haven't touched the README so it is present in the |
@@ -1,6 +1,6 @@ | |||
import unittest | |||
|
|||
from . import greedy_knapsack as kp | |||
from knapsack import greedy_knapsack as kp |
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.
Is this a vital change? There are two ways to go. Hardcode the name of the parent directory or use relative imports. Each has its pros and cons. Relative imports are better for easy refactoring and absolute imports are better for libraries and projects that need stability.
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.
Relative import would be like so: from .. import greedy_knapsack as kp
as I created a tests
directory for both test files. Here's the tree:
knapsack/
├── README.md
├── __init__.py
├── greedy_knapsack.py
├── knapsack.py
└── tests
├── __init__.py
├── test_greedy_knapsack.py
└── test_knapsack.py
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 suppose for our use case relative imports should be de facto as we don't know from where the script is going to be called by the user.
Nice work. Thanks for doing this. |
Fixes: #3956
Describe your change:
Checklist:
Fixes: #{$ISSUE_NO}
.