Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
octeres
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Package Registry
Operate
Terraform modules
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
AIG-public
octeres
Commits
c4aeb10e
Commit
c4aeb10e
authored
3 months ago
by
Eric Pershey
Browse files
Options
Downloads
Patches
Plain Diff
adding tests for data.py
parent
dc583365
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/main/python/Octeres/data.py
+1
-0
1 addition, 0 deletions
src/main/python/Octeres/data.py
src/test/python/test_data.py
+33
-0
33 additions, 0 deletions
src/test/python/test_data.py
with
34 additions
and
0 deletions
src/main/python/Octeres/data.py
+
1
−
0
View file @
c4aeb10e
...
...
@@ -24,6 +24,7 @@ def merge_dictionaries(dct_a: Dict[K, V], dct_b: Dict[K, V], default: object, op
class
partial_arg_kw
:
"""
a helper function to apply arguments and kwargs to a function.
partial args are applied first and kwargs are applied after the partial kwargs.
"""
def
__init__
(
self
,
func
,
*
args
,
**
kwargs
):
self
.
func
=
func
self
.
args
=
args
...
...
This diff is collapsed.
Click to expand it.
src/test/python/test_data.py
+
33
−
0
View file @
c4aeb10e
# Copyright (C) 2024, UChicago Argonne, LLC
# Licensed under the 3-clause BSD license. See accompanying LICENSE.txt file
# in the top-level directory.
import
operator
from
Octeres.data
import
partial_arg_kw
,
merge_dictionaries
def
test_merge_dictionaries_00
():
dct_a
=
dict
(
a
=
1
,
b
=
2
,
e
=
5
)
dct_b
=
dict
(
c
=
3
,
d
=
4
)
dct_c
=
dict
(
a
=
1
,
b
=
2
,
c
=
3
,
d
=
4
,
e
=
5
)
assert
merge_dictionaries
(
dct_a
,
dct_b
,
None
,
lambda
a
,
b
:
b
)
==
dct_c
dct_a
=
dict
(
a
=
1
,
b
=
2
,
e
=
5
)
dct_b
=
dict
(
c
=
3
,
b
=
123
,
d
=
4
)
dct_c
=
dict
(
a
=
1
,
b
=
123
,
c
=
3
,
d
=
4
,
e
=
5
)
assert
merge_dictionaries
(
dct_a
,
dct_b
,
None
,
lambda
a
,
b
:
b
)
==
dct_c
dct_c2
=
dict
(
a
=
1
,
b
=
2
,
c
=
None
,
d
=
None
,
e
=
5
)
# odd case, left gets from dct_a.get(c, None) and returns a which is None
assert
merge_dictionaries
(
dct_a
,
dct_b
,
None
,
lambda
a
,
b
:
a
)
==
dct_c2
dct_c3
=
dict
(
a
=
1
,
b
=
125
,
c
=
3
,
d
=
4
,
e
=
5
)
assert
merge_dictionaries
(
dct_a
,
dct_b
,
0
,
operator
.
add
)
==
dct_c3
dct_c4
=
dict
(
a
=
1
,
b
=
125
,
c
=
13
,
d
=
14
,
e
=
5
)
assert
merge_dictionaries
(
dct_a
,
dct_b
,
10
,
operator
.
add
)
==
dct_c4
def
test_partial_arg_kw_00
():
def
func
(
a
,
b
,
c
,
d
=
1
):
return
a
,
b
,
c
,
d
func2
=
partial_arg_kw
(
func
,
10
,
d
=
2
)
result
=
func2
(
3
,
4
)
assert
result
==
(
10
,
3
,
4
,
2
)
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