-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fe410d8
commit a6b5fd7
Showing
9 changed files
with
206 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: main | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Python | ||
uses: actions/setup-python@v2 | ||
with: | ||
python-version: 3.x | ||
|
||
- name: Install dependencies | ||
run: pip install -r requirements.txt | ||
|
||
- name: Run tests | ||
run: python -m unittest |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
[{"id": 1, "distance": 90.0}, {"id": 4, "distance": 50.0}, {"id": 5, "distance": 102.95630140987001}], | ||
[{"id": 0, "distance": 90.0}, {"id": 24, "distance": 90.0}, {"id": 6, "distance": 102.95630140987001}, {"id": 4, "distance": 102.95630140987001}, {"id": 5, "distance": 50.0}, {"id": 2, "distance": 90.0}], | ||
[{"id": 7, "distance": 102.95630140987001}, {"id": 3, "distance": 90.0}, {"id": 6, "distance": 50.0}, {"id": 1, "distance": 90.0}, {"id": 25, "distance": 90.0}, {"id": 5, "distance": 102.95630140987001}], | ||
[{"id": 7, "distance": 50.0}, {"id": 6, "distance": 102.95630140987001}, {"id": 2, "distance": 90.0}], | ||
[{"id": 0, "distance": 50.0}, {"id": 1, "distance": 102.95630140987001}, {"id": 24, "distance": 98.48857801796105}, {"id": 5, "distance": 90.0}], | ||
[{"id": 0, "distance": 102.95630140987001}, {"id": 24, "distance": 40.0}, {"id": 6, "distance": 90.0}, {"id": 1, "distance": 50.0}, {"id": 25, "distance": 98.48857801796105}, {"id": 4, "distance": 90.0}, {"id": 2, "distance": 102.95630140987001}], | ||
[{"id": 7, "distance": 90.0}, {"id": 24, "distance": 98.48857801796105}, {"id": 3, "distance": 102.95630140987001}, {"id": 25, "distance": 40.0}, {"id": 5, "distance": 90.0}, {"id": 1, "distance": 102.95630140987001}, {"id": 2, "distance": 50.0}], | ||
[{"id": 3, "distance": 50.0}, {"id": 6, "distance": 90.0}, {"id": 2, "distance": 102.95630140987001}, {"id": 25, "distance": 98.48857801796105}], | ||
[{"id": 26, "distance": 90.0}, {"id": 13, "distance": 102.95630140987001}, {"id": 12, "distance": 50.0}, {"id": 9, "distance": 90.0}], | ||
[{"id": 24, "distance": 70.0}, {"id": 13, "distance": 50.0}, {"id": 12, "distance": 102.95630140987001}, {"id": 8, "distance": 90.0}, {"id": 14, "distance": 102.95630140987001}, {"id": 10, "distance": 90.0}] | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
[ | ||
[{"id": 1, "distance": 90.0, "angle": 0}, {"id": 4, "distance": 50.0, "angle": 90}, {"id": 5, "distance": 102.95630140987001, "angle": 29}], | ||
[{"id": 0, "distance": 90.0, "angle": 180}, {"id": 24, "distance": 90.0, "angle": 90}, {"id": 6, "distance": 102.95630140987001, "angle": 29}, {"id": 4, "distance": 102.95630140987001, "angle": 150}, {"id": 5, "distance": 50.0, "angle": 90}, {"id": 2, "distance": 90.0, "angle": 0}], | ||
[{"id": 7, "distance": 102.95630140987001, "angle": 29}, {"id": 3, "distance": 90.0, "angle": 0}, {"id": 6, "distance": 50.0, "angle": 90}, {"id": 1, "distance": 90.0, "angle": 180}, {"id": 25, "distance": 90.0, "angle": 90}, {"id": 5, "distance": 102.95630140987001, "angle": 150}], | ||
[{"id": 7, "distance": 50.0, "angle": 90}, {"id": 6, "distance": 102.95630140987001, "angle": 150}, {"id": 2, "distance": 90.0, "angle": 180}], | ||
[{"id": 0, "distance": 50.0, "angle": 270}, {"id": 24, "distance": 98.48857801796105, "angle": 23}, {"id": 5, "distance": 90.0, "angle": 0}], | ||
[{"id": 0, "distance": 102.95630140987001, "angle": 210}, {"id": 24, "distance": 40.0, "angle": 90}, {"id": 6, "distance": 90.0, "angle": 0}, {"id": 1, "distance": 50.0, "angle": 270}, {"id": 25, "distance": 98.48857801796105, "angle": 23}, {"id": 4, "distance": 90.0, "angle": 180}], | ||
[{"id": 7, "distance": 90.0, "angle": 0}, {"id": 24, "distance": 98.48857801796105, "angle": 156}, {"id": 25, "distance": 40.0, "angle": 90}, {"id": 5, "distance": 90.0, "angle": 180}, {"id": 1, "distance": 102.95630140987001, "angle": 210}, {"id": 2, "distance": 50.0, "angle": 270}], | ||
[{"id": 3, "distance": 50.0, "angle": 270}, {"id": 6, "distance": 90.0, "angle": 180}, {"id": 2, "distance": 102.95630140987001, "angle": 210}, {"id": 25, "distance": 98.48857801796105, "angle": 156}], | ||
[{"id": 26, "distance": 90.0, "angle": 90}, {"id": 13, "distance": 102.95630140987001, "angle": 29}, {"id": 12, "distance": 50.0, "angle": 90}, {"id": 9, "distance": 90.0, "angle": 0}], | ||
[{"id": 24, "distance": 70.0, "angle": 270}, {"id": 13, "distance": 50.0, "angle": 90}, {"id": 12, "distance": 102.95630140987001, "angle": 150}, {"id": 8, "distance": 90.0, "angle": 180}, {"id": 14, "distance": 102.95630140987001, "angle": 29}, {"id": 10, "distance": 90.0, "angle": 0}] | ||
] |
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import unittest | ||
from retailtree.retailtree import Annotation, RetailTree | ||
import json | ||
|
||
|
||
class TestAnnotation(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# Build tree before every test case | ||
file_path = './tests/test_data/test_data.json' | ||
file_path_output = './tests/test_data/neighbors_output.json' | ||
# Annotations data2 | ||
with open(file_path, 'r') as file: | ||
self.annotation_data_json = json.load(file) | ||
|
||
with open(file_path_output, 'r') as file: | ||
self.annotation_output_data = json.load(file) | ||
|
||
self.RT = RetailTree() | ||
for data in self.annotation_data_json: | ||
ann = Annotation(data['id'], data['x_min'], | ||
data['y_min'], data['x_max'], data['y_max']) | ||
self.RT.add_annotation(ann) | ||
|
||
self.RT.build_tree() | ||
self.assertIsNotNone(self.RT.tree) | ||
|
||
def test_find_neighbors_0(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=0, radius=1.2), self.annotation_output_data[0]) | ||
|
||
def test_find_neighbors_1(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=1, radius=1.2), self.annotation_output_data[1]) | ||
|
||
def test_find_neighbors_2(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=2, radius=1.2), self.annotation_output_data[2]) | ||
|
||
def test_find_neighbors_3(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=3, radius=1.2), self.annotation_output_data[3]) | ||
|
||
def test_find_neighbors_4(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=4, radius=1.2), self.annotation_output_data[4]) | ||
|
||
def test_find_neighbors_5(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=5, radius=1.2), self.annotation_output_data[5]) | ||
|
||
def test_find_neighbors_6(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=6, radius=1.2), self.annotation_output_data[6]) | ||
|
||
def test_find_neighbors_7(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=7, radius=1.2), self.annotation_output_data[7]) | ||
|
||
def test_find_neighbors_8(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=8, radius=1.2), self.annotation_output_data[8]) | ||
|
||
def test_find_neighbors_9(self): | ||
self.assertEqual(self.RT.neighbors( | ||
id=9, radius=1.2), self.annotation_output_data[9]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
import unittest | ||
from retailtree.retailtree import Annotation, RetailTree | ||
import json | ||
|
||
|
||
class TestAnnotation(unittest.TestCase): | ||
|
||
def setUp(self): | ||
# Build tree before every test case | ||
file_path = './tests/test_data/test_data.json' | ||
file_path_output = './tests/test_data/neighbors_wa_output.json' | ||
# Annotations data2 | ||
with open(file_path, 'r') as file: | ||
self.annotation_data_json = json.load(file) | ||
|
||
with open(file_path_output, 'r') as file: | ||
self.annotation_output_data = json.load(file) | ||
|
||
self.RT = RetailTree() | ||
for data in self.annotation_data_json: | ||
ann = Annotation(data['id'], data['x_min'], | ||
data['y_min'], data['x_max'], data['y_max']) | ||
self.RT.add_annotation(ann) | ||
|
||
self.RT.build_tree() | ||
self.assertIsNotNone(self.RT.tree) | ||
|
||
def test_find_neighbors_0(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=0, radius=1.2, amin=0, amax=270), self.annotation_output_data[0]) | ||
|
||
def test_find_neighbors_1(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=1, radius=1.2, amin=0, amax=270), self.annotation_output_data[1]) | ||
|
||
def test_find_neighbors_2(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=2, radius=1.2, amin=0, amax=270), self.annotation_output_data[2]) | ||
|
||
def test_find_neighbors_3(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=3, radius=1.2, amin=0, amax=270), self.annotation_output_data[3]) | ||
|
||
def test_find_neighbors_4(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=4, radius=1.2, amin=0, amax=270), self.annotation_output_data[4]) | ||
|
||
def test_find_neighbors_5(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=5, radius=1.2, amin=0, amax=270), self.annotation_output_data[5]) | ||
|
||
def test_find_neighbors_6(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=6, radius=1.2, amin=0, amax=270), self.annotation_output_data[6]) | ||
|
||
def test_find_neighbors_7(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=7, radius=1.2, amin=0, amax=270), self.annotation_output_data[7]) | ||
|
||
def test_find_neighbors_8(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=8, radius=1.2, amin=0, amax=270), self.annotation_output_data[8]) | ||
|
||
def test_find_neighbors_9(self): | ||
self.assertEqual(self.RT.neighbors_wa( | ||
id=9, radius=1.2, amin=0, amax=270), self.annotation_output_data[9]) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |