Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
ba
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
markn92
ba
Commits
bf73f7e6
Commit
bf73f7e6
authored
5 years ago
by
markn92
Browse files
Options
Downloads
Patches
Plain Diff
test further
parent
59cd815c
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
tests/charge/conftest.py
+19
-1
19 additions, 1 deletion
tests/charge/conftest.py
tests/charge/test_soc_data_structures.py
+3
-0
3 additions, 0 deletions
tests/charge/test_soc_data_structures.py
tests/charge/test_utils.py
+30
-2
30 additions, 2 deletions
tests/charge/test_utils.py
with
52 additions
and
3 deletions
tests/charge/conftest.py
+
19
−
1
View file @
bf73f7e6
import
pytest
import
pytest
from
evrouting.charge.T
import
SoCProfile
,
SoCFunction
,
ChargingFunction
,
Label
from
evrouting.charge.T
import
SoCProfile
,
SoCFunction
,
ChargingFunction
,
Label
from
itertools
import
count
@pytest.fixture
@pytest.fixture
...
@@ -26,6 +27,17 @@ def ch_function():
...
@@ -26,6 +27,17 @@ def ch_function():
return
c
,
capacity
,
ChargingFunction
(
c
,
capacity
)
return
c
,
capacity
,
ChargingFunction
(
c
,
capacity
)
@pytest.fixture
def
ch_function_fast
():
c
=
3
capacity
=
4
return
c
,
capacity
,
ChargingFunction
(
c
,
capacity
)
last_cs_generator
=
count
()
@pytest.fixture
@pytest.fixture
def
label
(
soc_profile_2
):
def
label
(
soc_profile_2
):
_
,
_
,
profile
=
soc_profile_2
_
,
_
,
profile
=
soc_profile_2
...
@@ -33,7 +45,7 @@ def label(soc_profile_2):
...
@@ -33,7 +45,7 @@ def label(soc_profile_2):
t_trip
=
10
,
t_trip
=
10
,
soc_last_cs
=
2
,
soc_last_cs
=
2
,
soc_profile_cs_v
=
profile
,
soc_profile_cs_v
=
profile
,
last_cs
=
1
last_cs
=
next
(
last_cs_generator
)
)
)
...
@@ -41,3 +53,9 @@ def label(soc_profile_2):
...
@@ -41,3 +53,9 @@ def label(soc_profile_2):
def
soc_function
(
label
,
ch_function
):
def
soc_function
(
label
,
ch_function
):
_
,
_
,
cf
=
ch_function
_
,
_
,
cf
=
ch_function
return
SoCFunction
(
label
,
cf
)
return
SoCFunction
(
label
,
cf
)
@pytest.fixture
def
soc_function_fast
(
label
,
ch_function_fast
):
_
,
_
,
cf
=
ch_function_fast
return
SoCFunction
(
label
,
cf
)
This diff is collapsed.
Click to expand it.
tests/charge/test_soc_data_structures.py
+
3
−
0
View file @
bf73f7e6
...
@@ -111,6 +111,9 @@ class TestSoCFunction:
...
@@ -111,6 +111,9 @@ class TestSoCFunction:
assert
soc_function
.
_calc_minimum
()
==
-
inf
assert
soc_function
.
_calc_minimum
()
==
-
inf
def
test_dominance
(
self
,
soc_function
,
soc_function_fast
):
assert
soc_function_fast
.
dominates
(
soc_function
)
class
TestChargingFunction
:
class
TestChargingFunction
:
def
test_creation
(
self
,
ch_function
):
def
test_creation
(
self
,
ch_function
):
...
...
This diff is collapsed.
Click to expand it.
tests/charge/test_utils.py
+
30
−
2
View file @
bf73f7e6
import
pytest
import
pytest
from
copy
import
copy
from
evrouting.charge.utils
import
LabelPriorityQueue
from
evrouting.charge.utils
import
LabelPriorityQueue
from
evrouting.charge.T
import
Label
from
evrouting.charge.T
import
Label
from
evrouting.charge.factories
import
SoCFunctionFactory
from
evrouting.charge.factories
import
SoCFunctionFactory
,
ChargingFunctionMap
@pytest.fixture
@pytest.fixture
def
q
(
label
,
ch_function
):
def
q
(
label
,
ch_function
):
_
,
_
,
cf
=
ch_function
_
,
_
,
cf
=
ch_function
dummy_cf
=
{
label
.
last_cs
:
cf
}
dummy_cf
=
{
label
.
last_cs
:
cf
}
q
=
LabelPriorityQueue
(
SoCFunctionFactory
(
dummy_cf
),
l_set
=
set
({})
)
q
=
LabelPriorityQueue
(
SoCFunctionFactory
(
dummy_cf
),
l_set
=
[]
)
q
.
insert
(
label
)
q
.
insert
(
label
)
# create min
# create min
...
@@ -43,3 +44,30 @@ class TestProrityQueue:
...
@@ -43,3 +44,30 @@ class TestProrityQueue:
label
=
q
.
peak_min
()
label
=
q
.
peak_min
()
q
.
remove_item
(
label
)
q
.
remove_item
(
label
)
q
.
insert
(
label
)
q
.
insert
(
label
)
def
test_dominance_check
(
self
,
label
,
soc_function
,
soc_function_fast
):
label_fast
=
Label
(
t_trip
=
label
.
t_trip
,
soc_last_cs
=
label
.
soc_last_cs
,
last_cs
=
2
,
soc_profile_cs_v
=
label
.
soc_profile_cs_v
,
)
cf
=
{
label
.
last_cs
:
soc_function
.
cf_cs
,
label_fast
.
last_cs
:
soc_function_fast
.
cf_cs
}
f_soc
=
SoCFunctionFactory
(
cf
=
cf
)
# minimum is dominated by lset
l_set
=
[
label
,
label_fast
]
queue
=
LabelPriorityQueue
(
f_soc
=
f_soc
,
l_set
=
l_set
)
queue
.
insert
(
label
)
assert
not
queue
# minimum is not dominated by lset
l_set
=
[
label
]
queue
=
LabelPriorityQueue
(
f_soc
=
f_soc
,
l_set
=
l_set
)
queue
.
insert
(
label_fast
)
assert
queue
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment