Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
S
SMART
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
3
Issues
3
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
UNI-KLU
SMART
Commits
b3e1053d
Commit
b3e1053d
authored
Jul 14, 2020
by
Bogdan
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/developBogdan' into developBogdan
parents
a039212b
8d27f825
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
48 additions
and
60 deletions
+48
-60
.gitignore
.gitignore
+0
-2
main.py
src/data-hub/role-stage-discovery-microservice/app/main.py
+0
-1
similarityMain.py
...b/role-stage-discovery-microservice/app/similarityMain.py
+0
-7
test_cluster.py
...le-stage-discovery-microservice/app/tests/test_cluster.py
+2
-1
test_similarity.py
...stage-discovery-microservice/app/tests/test_similarity.py
+46
-49
No files found.
.gitignore
View file @
b3e1053d
...
...
@@ -4,5 +4,3 @@
*.log
**/env
**/venv
src/data-hub/role-stage-discovery-microservice/app/resultSimilarityDictN14992C221.json
src/data-hub/role-stage-discovery-microservice/app/main.py
View file @
b3e1053d
...
...
@@ -14,7 +14,6 @@ LOGGER = logging.getLogger(__name__)
#############################
import
connexion
# load swagger config
app
=
connexion
.
App
(
__name__
,
specification_dir
=
'configs/'
)
app
.
add_api
(
'swagger.yml'
)
...
...
src/data-hub/role-stage-discovery-microservice/app/similarityMain.py
View file @
b3e1053d
...
...
@@ -32,10 +32,6 @@ from processing.similarityFiles.miscFunctions import *
from
processing.similarityFiles.dataOutput
import
*
#####TEST ONLY#####
from
processing.similarityFiles.testSimilarity
import
*
def
main
():
print
(
"
\n
Entered Main"
)
...
...
@@ -110,9 +106,6 @@ def main():
return
def
test
():
testInputData
()
##########START##########
main
()
#test()
#########FINISH##########
src/data-hub/role-stage-discovery-microservice/app/tests/test_cluster.py
View file @
b3e1053d
import
unittest
import
sys
sys
.
path
.
insert
(
1
,
'../'
)
for
path
in
[
'../'
,
'./'
]:
sys
.
path
.
insert
(
1
,
path
)
# python -m unittest discover
from
db.entities
import
Cluster
...
...
src/data-hub/role-stage-discovery-microservice/app/
processing/similarityFiles/testS
imilarity.py
→
src/data-hub/role-stage-discovery-microservice/app/
tests/test_s
imilarity.py
View file @
b3e1053d
import
unittest
import
sys
for
path
in
[
'../'
,
'./'
,
'../../../modules/'
]:
sys
.
path
.
insert
(
1
,
path
)
from
db.entities.connected_node
import
NodeC
from
db.entities.connected_cluster
import
ClusterC
from
db.entities.connected_layer
import
LayerC
import
os
import
sys
import
math
import
datetime
from
typing
import
Dict
...
...
@@ -12,23 +16,14 @@ from processing.similarityFiles.dataInput import *
from
processing.similarityFiles.calculateWeights
import
*
from
processing.similarityFiles.calculateSimilarity
import
*
from
processing.similarityFiles.miscFunctions
import
*
from
processing.similarityFiles.dataOutput
import
*
import
json
import
requests
modules_path
=
'../../../modules/'
if
os
.
path
.
exists
(
modules_path
):
sys
.
path
.
insert
(
1
,
modules_path
)
from
db.repository
import
*
repo
=
Repository
()
class
TestSimilarity
(
unittest
.
TestCase
):
'''Tests the similarity calculation which works without object orientation.'''
def
testInputData
():
#ONLY FOR TESTING
def
test_integration_similarityCalculation
(
self
):
'''
Only for testing, can be deleted at any time.
\n
Served as a testing example to make sure the computations are correct
...
...
@@ -37,7 +32,7 @@ def testInputData():#ONLY FOR TESTING
limitNrNodes
=
100000
layerDict
=
dict
()
print
(
"Creating Connected_cluster dict and similarity dict"
)
(
"Creating Connected_cluster dict and similarity dict"
)
inputLayerLocation
=
getTestLocationLayerData
()
inputLayerTime
=
getTestTimeLayerData
()
inputLayerPrice
=
getTestPriceLayerData
()
...
...
@@ -48,26 +43,26 @@ def testInputData():#ONLY FOR TESTING
layerDict
=
calculateWeights
(
layerDict
)
similarityDict
=
calculateSimilarity
(
layerDict
)
print
(
"Asserting if the calculated values are true"
)
(
"Asserting if the calculated values are true"
)
#assert x == "hello"
# SYNTAX:
#similarityDict[(clusterLabel1,clusterLabel2,layerOfTheClusters)][layerToWhichTheClustersAreCompared] == ExpectedSimilarityValue
#checking if the cluster "1" and cluster "2" from the "Location" layer have the sqrt(2) similarity values for when compared with 'Price'and 'Time'layers
assert
similarityDict
[(
1
,
2
,
'Location'
)][
'Price'
]
==
math
.
sqrt
(
2
)
assert
similarityDict
[(
1
,
2
,
'Location'
)][
'Time'
]
==
math
.
sqrt
(
2
)
assert
similarityDict
[(
1
,
3
,
'Location'
)][
'Price'
]
==
math
.
sqrt
(
10
)
assert
similarityDict
[(
1
,
3
,
'Location'
)][
'Time'
]
==
math
.
sqrt
(
16
)
assert
similarityDict
[(
2
,
3
,
'Location'
)][
'Price'
]
==
math
.
sqrt
(
4
)
assert
similarityDict
[(
2
,
3
,
'Location'
)][
'Time'
]
==
math
.
sqrt
(
10
)
assert
similarityDict
[(
4
,
5
,
'Time'
)][
'Location'
]
==
math
.
sqrt
(
19
)
assert
similarityDict
[(
4
,
5
,
'Time'
)][
'Price'
]
==
math
.
sqrt
(
26
)
assert
similarityDict
[(
6
,
7
,
'Price'
)][
'Location'
]
==
math
.
sqrt
(
3
)
assert
similarityDict
[(
6
,
7
,
'Price'
)][
'Time'
]
==
math
.
sqrt
(
8
)
self
.
assertEqual
(
similarityDict
[(
1
,
2
,
'Location'
)][
'Price'
],
math
.
sqrt
(
2
))
self
.
assertEqual
(
similarityDict
[(
1
,
2
,
'Location'
)][
'Time'
],
math
.
sqrt
(
2
)
)
self
.
assertEqual
(
similarityDict
[(
1
,
3
,
'Location'
)][
'Price'
],
math
.
sqrt
(
10
)
)
self
.
assertEqual
(
similarityDict
[(
1
,
3
,
'Location'
)][
'Time'
],
math
.
sqrt
(
16
)
)
self
.
assertEqual
(
similarityDict
[(
2
,
3
,
'Location'
)][
'Price'
],
math
.
sqrt
(
4
)
)
self
.
assertEqual
(
similarityDict
[(
2
,
3
,
'Location'
)][
'Time'
],
math
.
sqrt
(
10
)
)
self
.
assertEqual
(
similarityDict
[(
4
,
5
,
'Time'
)][
'Location'
],
math
.
sqrt
(
19
)
)
self
.
assertEqual
(
similarityDict
[(
4
,
5
,
'Time'
)][
'Price'
],
math
.
sqrt
(
26
)
)
self
.
assertEqual
(
similarityDict
[(
6
,
7
,
'Price'
)][
'Location'
],
math
.
sqrt
(
3
)
)
self
.
assertEqual
(
similarityDict
[(
6
,
7
,
'Price'
)][
'Time'
],
math
.
sqrt
(
8
)
)
# assert similarityDict[(1,2,'Location')]
print
(
"Test Passed Succesfully"
)
(
"Test Passed Succesfully"
)
return
layerDict
...
...
@@ -402,3 +397,5 @@ def getTestPriceLayerData():
if
__name__
==
'__main__'
:
unittest
.
main
()
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment