Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
arbor
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Repository analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
arbor-sim
arbor
Commits
bae9e9a3
Unverified
Commit
bae9e9a3
authored
3 years ago
by
Robin De Schepper
Committed by
GitHub
3 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Added an empty catalogue (#1677)
Expose default (empty) catalogue constructor to Python
parent
b7ba25a1
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
doc/python/mechanisms.rst
+9
-0
9 additions, 0 deletions
doc/python/mechanisms.rst
python/mechanism.cpp
+1
-0
1 addition, 0 deletions
python/mechanism.cpp
python/test/unit/test_catalogues.py
+26
-0
26 additions, 0 deletions
python/test/unit/test_catalogues.py
with
36 additions
and
0 deletions
doc/python/mechanisms.rst
+
9
−
0
View file @
bae9e9a3
...
...
@@ -257,6 +257,15 @@ Mechanism catalogues
2. A further hierarchy of *derived* mechanisms, that allow specialization of
global parameters, ion bindings, and implementations.
.. py:method:: __init__(catalogue=None)
Create an empty or copied catalogue.
:param catalogue: ``catalogue`` to copy
:type catalogue: :class:`catalogue`
:return: empty or copied catalogue
:rtype: :class:`catalogue`
.. py:method:: __contains__(name)
Test if mechanism with *name* is in the catalogue.
...
...
This diff is collapsed.
Click to expand it.
python/mechanism.cpp
+
1
−
0
View file @
bae9e9a3
...
...
@@ -152,6 +152,7 @@ void register_mechanisms(pybind11::module& m) {
.
def
(
"__next__"
,
&
py_mech_cat_item_iterator
::
next
);
cat
.
def
(
pybind11
::
init
())
.
def
(
pybind11
::
init
<
const
arb
::
mechanism_catalogue
&>
())
.
def
(
"__contains__"
,
&
arb
::
mechanism_catalogue
::
has
,
"name"
_a
,
"Is 'name' in the catalogue?"
)
...
...
This diff is collapsed.
Click to expand it.
python/test/unit/test_catalogues.py
+
26
−
0
View file @
bae9e9a3
...
...
@@ -70,6 +70,32 @@ class Catalogues(unittest.TestCase):
sim
=
arb
.
simulation
(
rcp
,
dom
,
ctx
)
sim
.
run
(
tfinal
=
30
)
def
test_empty
(
self
):
def
len
(
cat
):
return
sum
(
1
for
_
in
cat
)
def
hash_
(
cat
):
return
hash
(
"
"
.
join
(
sorted
(
cat
)))
cat
=
arb
.
catalogue
()
ref
=
arb
.
default_catalogue
()
other
=
arb
.
default_catalogue
()
# Test empty constructor
self
.
assertEqual
(
0
,
len
(
cat
),
"
Expected no mechanisms in `arbor.catalogue()`.
"
)
# Test empty extend
other
.
extend
(
cat
,
""
)
self
.
assertEqual
(
hash_
(
ref
),
hash_
(
other
),
"
Extending cat with empty should not change cat.
"
)
self
.
assertEqual
(
0
,
len
(
cat
),
"
Extending cat with empty should not change empty.
"
)
other
.
extend
(
cat
,
"
prefix/
"
)
self
.
assertEqual
(
hash_
(
ref
),
hash_
(
other
),
"
Extending cat with prefixed empty should not change cat.
"
)
self
.
assertEqual
(
0
,
len
(
cat
),
"
Extending cat with prefixed empty should not change empty.
"
)
cat
.
extend
(
other
,
""
)
self
.
assertEqual
(
hash_
(
other
),
hash_
(
cat
),
"
Extending empty with cat should turn empty into cat.
"
)
cat
=
arb
.
catalogue
()
cat
.
extend
(
other
,
"
prefix/
"
)
self
.
assertNotEqual
(
hash_
(
other
),
hash_
(
cat
),
"
Extending empty with prefixed cat should not yield cat
"
)
def
suite
():
# specify class and test functions in tuple (here: all tests starting with 'test' from class Contexts
...
...
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