Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
L
libsonata
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BlueBrain
libsonata
Commits
ab6c6ee1
Unverified
Commit
ab6c6ee1
authored
2 years ago
by
Matthias Wolf
Committed by
GitHub
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Fix #226 for empty selections (#232)
parent
c34c7c4a
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
python/tests/test.py
+10
-0
10 additions, 0 deletions
python/tests/test.py
src/population.hpp
+3
-1
3 additions, 1 deletion
src/population.hpp
tests/test_nodes.cpp
+2
-0
2 additions, 0 deletions
tests/test_nodes.cpp
with
15 additions
and
1 deletion
python/tests/test.py
+
10
−
0
View file @
ab6c6ee1
...
@@ -163,6 +163,14 @@ class TestNodePopulation(unittest.TestCase):
...
@@ -163,6 +163,14 @@ class TestNodePopulation(unittest.TestCase):
)
)
def
test_enumeration_values
(
self
):
def
test_enumeration_values
(
self
):
self
.
assertEqual
(
self
.
test_obj
.
get_attribute
(
"
E-mapping-good
"
,
Selection
([])
).
tolist
(),
[]
)
self
.
assertEqual
(
self
.
assertEqual
(
self
.
test_obj
.
get_attribute
(
self
.
test_obj
.
get_attribute
(
"
E-mapping-good
"
,
"
E-mapping-good
"
,
...
@@ -240,10 +248,12 @@ class TestEdgePopulation(unittest.TestCase):
...
@@ -240,10 +248,12 @@ class TestEdgePopulation(unittest.TestCase):
def
test_source_nodes
(
self
):
def
test_source_nodes
(
self
):
self
.
assertEqual
(
self
.
test_obj
.
source_node
(
1
),
1
)
self
.
assertEqual
(
self
.
test_obj
.
source_node
(
1
),
1
)
self
.
assertEqual
(
self
.
test_obj
.
source_nodes
(
Selection
([
0
,
1
,
2
,
4
])).
tolist
(),
[
1
,
1
,
2
,
3
])
self
.
assertEqual
(
self
.
test_obj
.
source_nodes
(
Selection
([
0
,
1
,
2
,
4
])).
tolist
(),
[
1
,
1
,
2
,
3
])
self
.
assertEqual
(
self
.
test_obj
.
source_nodes
(
Selection
([])).
tolist
(),
[])
def
test_target_nodes
(
self
):
def
test_target_nodes
(
self
):
self
.
assertEqual
(
self
.
test_obj
.
target_node
(
1
),
2
)
self
.
assertEqual
(
self
.
test_obj
.
target_node
(
1
),
2
)
self
.
assertEqual
(
self
.
test_obj
.
target_nodes
(
Selection
([
0
,
1
,
2
,
4
])).
tolist
(),
[
1
,
2
,
1
,
0
])
self
.
assertEqual
(
self
.
test_obj
.
target_nodes
(
Selection
([
0
,
1
,
2
,
4
])).
tolist
(),
[
1
,
2
,
1
,
0
])
self
.
assertEqual
(
self
.
test_obj
.
target_nodes
(
Selection
([])).
tolist
(),
[])
def
test_afferent_edges
(
self
):
def
test_afferent_edges
(
self
):
self
.
assertEqual
(
self
.
test_obj
.
afferent_edges
([
1
,
2
]).
ranges
,
[(
0
,
4
),
(
5
,
6
)])
self
.
assertEqual
(
self
.
test_obj
.
afferent_edges
([
1
,
2
]).
ranges
,
[(
0
,
4
),
(
5
,
6
)])
...
...
This diff is collapsed.
Click to expand it.
src/population.hpp
+
3
−
1
View file @
ab6c6ee1
...
@@ -89,7 +89,9 @@ std::vector<T> _readSelection(const HighFive::DataSet& dset, const Selection& se
...
@@ -89,7 +89,9 @@ std::vector<T> _readSelection(const HighFive::DataSet& dset, const Selection& se
template
<
typename
T
,
typename
std
::
enable_if
<
std
::
is_pod
<
T
>
::
value
>::
type
*
=
nullptr
>
template
<
typename
T
,
typename
std
::
enable_if
<
std
::
is_pod
<
T
>
::
value
>::
type
*
=
nullptr
>
std
::
vector
<
T
>
_readSelection
(
const
HighFive
::
DataSet
&
dset
,
const
Selection
&
selection
)
{
std
::
vector
<
T
>
_readSelection
(
const
HighFive
::
DataSet
&
dset
,
const
Selection
&
selection
)
{
if
(
selection
.
ranges
().
size
()
==
1
)
{
if
(
selection
.
ranges
().
empty
())
{
return
{};
}
else
if
(
selection
.
ranges
().
size
()
==
1
)
{
return
_readChunk
<
T
>
(
dset
,
selection
.
ranges
().
front
());
return
_readChunk
<
T
>
(
dset
,
selection
.
ranges
().
front
());
}
}
...
...
This diff is collapsed.
Click to expand it.
tests/test_nodes.cpp
+
2
−
0
View file @
ab6c6ee1
...
@@ -38,6 +38,8 @@ TEST_CASE("NodePopulation", "[base]") {
...
@@ -38,6 +38,8 @@ TEST_CASE("NodePopulation", "[base]") {
REQUIRE
(
population
.
enumerationNames
()
==
REQUIRE
(
population
.
enumerationNames
()
==
std
::
set
<
std
::
string
>
{
"E-mapping-good"
,
"E-mapping-bad"
});
std
::
set
<
std
::
string
>
{
"E-mapping-good"
,
"E-mapping-bad"
});
CHECK
(
population
.
getAttribute
<
double
>
(
"attr-X"
,
Selection
({}))
==
std
::
vector
<
double
>
{});
CHECK
(
population
.
getAttribute
<
double
>
(
"attr-X"
,
Selection
({{
0
,
1
},
{
5
,
6
}}))
==
CHECK
(
population
.
getAttribute
<
double
>
(
"attr-X"
,
Selection
({{
0
,
1
},
{
5
,
6
}}))
==
std
::
vector
<
double
>
{
11.0
,
16.0
});
std
::
vector
<
double
>
{
11.0
,
16.0
});
CHECK
(
population
.
getAttribute
<
float
>
(
"attr-X"
,
Selection
({{
0
,
1
}}))
==
CHECK
(
population
.
getAttribute
<
float
>
(
"attr-X"
,
Selection
({{
0
,
1
}}))
==
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
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