fixes: #3956 Cleaned up knapsack and images directory #3972
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 |
cclauss
Nov 27, 2020
Member
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.
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.
dhruvmanila
Nov 27, 2020
Author
Member
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
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
dhruvmanila
Nov 27, 2020
Author
Member
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.
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}
.