Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F62111989
__init__.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Fri, May 10, 23:50
Size
1 KB
Mime Type
text/x-python
Expires
Sun, May 12, 23:50 (2 d)
Engine
blob
Format
Raw Data
Handle
17605162
Attached To
R4670 PySONIC (old)
__init__.py
View Options
# -*- coding: utf-8 -*-
# @Author: Theo Lemaire
# @Email: theo.lemaire@epfl.ch
# @Date: 2017-06-06 13:36:00
# @Last Modified by: Theo Lemaire
# @Last Modified time: 2020-04-21 11:33:31
from
types
import
MethodType
import
inspect
import
sys
from
.solvers
import
*
from
.batches
import
*
from
.model
import
*
from
.pneuron
import
*
from
.bls
import
*
from
.translators
import
*
from
.nbls
import
*
from
.vclamp
import
*
from
.lookups
import
*
from
.stimobj
import
*
from
.protocols
import
*
from
.drives
import
*
from
..neurons
import
getPointNeuron
def
getModelsDict
():
''' Construct a dictionary of all model classes, indexed by simulation key. '''
current_module
=
sys
.
modules
[
__name__
]
models_dict
=
{}
for
_
,
obj
in
inspect
.
getmembers
(
current_module
):
if
inspect
.
isclass
(
obj
)
and
hasattr
(
obj
,
'simkey'
)
and
isinstance
(
obj
.
simkey
,
str
):
models_dict
[
obj
.
simkey
]
=
obj
return
models_dict
# Add an initFromMeta method to the Pointneuron class (done here to avoid circular import)
PointNeuron
.
initFromMeta
=
MethodType
(
lambda
self
,
meta
:
getPointNeuron
(
meta
[
'neuron'
]),
PointNeuron
)
models_dict
=
getModelsDict
()
def
getModel
(
meta
):
''' Return appropriate model object based on a dictionary of meta-information. '''
simkey
=
meta
[
'simkey'
]
try
:
return
models_dict
[
simkey
]
.
initFromMeta
(
meta
[
'model'
])
except
KeyError
:
raise
ValueError
(
f
'Unknown model type:{simkey}'
)
Event Timeline
Log In to Comment