Skip to content

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

Merged
merged 1 commit into from
Nov 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file removed images/Travis_CI_fail_1.png
Binary file not shown.
Binary file removed images/Travis_CI_fail_2.png
Binary file not shown.
Empty file removed images/__init__.py
Empty file.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import unittest

from . import greedy_knapsack as kp
from knapsack import greedy_knapsack as kp
Copy link
Member

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.

Copy link
Member Author

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

Copy link
Member Author

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.



class TestClass(unittest.TestCase):
Expand Down
File renamed without changes.