Comments (8)
@russelljjarvis
I've just fixed this in the backend-refactor
branch (the one with the open PR). So now I can do:
m = StaticModel(vm) # Make a static model based on this response
t = InputResistanceTest({'mean': 450*pq.MOhm, 'std': 50*pq.MOhm})
s = t.judge(m)
and get the expected score for a given vm
, in the backend-refactor
branch of this fork.
Origin of the problem and its solution:
Yes ProtocolToFeaturesTest
requires a run
method, and the easy way to achieve that is to make StaticModel
inherit from sciunit.models.runnable.RunnableModel
instead of from just sciunit.Model
. But the other issue is that the tests itself (e.g. InputResistanceTest
) requires the ability to call methods of the backend (like set_stop_time
). Most of the backends have this, but of course the whole point of StaticModel
is to not have to have any actual backend. And I noticed that all of those methods (like set_stop_time
) where defined in all of the backends but without a reference backend class which defines the signatures of those methods. So I created an empty Backend
class which StaticModel
can use, which doesn't do anything at all (those methods are implemented as pass
), consistent with the nature of StaticModel
.
So if this is a blocking issue for you, I propose that we merge that branch today in our meeting, and see then address any new issues that arise from that.
from neuronunit.
With the newer version of sciunit dev installed
RheobaseTest
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
~/git/sciunit/sciunit/models/base.py in __getattr__(self, attr)
108 try:
--> 109 result = super(Model, self).__getattribute__(attr)
110 except AttributeError:
AttributeError: 'StaticModel' object has no attribute 'run_params'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
~/git/sciunit/sciunit/models/base.py in __getattr__(self, attr)
111 try:
--> 112 result = self._backend.__getattribute__(attr)
113 except:
AttributeError: 'EmptyBackend' object has no attribute 'run_params'
During handling of the above exception, another exception occurred:
AttributeError Traceback (most recent call last)
<ipython-input-7-9eeb01b46f3a> in <module>
8 for t in tt:
9 print(t.name)
---> 10 score = t.judge(SM)
11 #tt = switch_logic(tt)
12 #not_suite = TSD({t.name:t for t in tt.tests})
~/git/sciunit/sciunit/tests.py in judge(self, model, skip_incapable, stop_on_error, deep_error)
330 score.test = self
331 if isinstance(score, ErrorScore) and stop_on_error:
--> 332 raise score.score # An exception.
333 return score
334
~/git/sciunit/sciunit/tests.py in judge(self, model, skip_incapable, stop_on_error, deep_error)
319 else:
320 try:
--> 321 score = self._judge(model, skip_incapable=skip_incapable)
322 except CapabilityError as e:
323 score = NAScore(str(e))
~/git/sciunit/sciunit/tests.py in _judge(self, model, skip_incapable)
259
260 # 2.
--> 261 prediction = self.generate_prediction(model)
262 self.check_prediction(prediction)
263 self.last_model = model
~/safe2/neuronunit/neuronunit/tests/fi.py in generate_prediction(self, model)
103 # Method implementation guaranteed by
104 # ProducesActionPotentials capability.
--> 105 self.condition_model(model)
106 prediction = {'value': None}
107 model.rerun = True
~/safe2/neuronunit/neuronunit/tests/fi.py in condition_model(self, model)
97 self.params['tmax'] = 2000.0*pq.ms
98 else:
---> 99 model.set_run_params(t_stop=self.params['tmax'])
100
101 def generate_prediction(self, model):
~/git/sciunit/sciunit/models/runnable.py in set_run_params(self, **run_params)
84 def set_run_params(self, **run_params):
85 """Set run-time parameters, e.g. the somatic current to inject."""
---> 86 self.run_params.update(run_params)
87 self.check_run_params()
88 self._backend.set_run_params(**run_params)
~/git/sciunit/sciunit/models/base.py in __getattr__(self, attr)
113 except:
114 raise AttributeError("Model %s has no attribute %s"
--> 115 % (self, attr))
116 return result
117
AttributeError: Model None has no attribute run_params```
from neuronunit.
@russelljjarvis I don't know what you are doing to get this because you printed the traceback but not the code that produced it.
from neuronunit.
@russelljjarvis OK, I think I figured it out based on the traceback. RheobaseTest does not inherit from TestPulseTest so it needed a few bug fixes to work. I applied them in the rick
branch of this repository, so check that out and it should work (or at least you shouldn't get that bug). For example, I can run a RheobaseTest on a static model (whereas it resulted an error before). Be aware that if you are running a RheobaseTest on a static model, you'll need to have a cached waveform for every value of current injected -- not sure that is actually possible?
I am assuming you were running a RheobaseTest since that is what was printed at the very top of the stack trace.
from neuronunit.
Its down the bottom of this file:
from neuronunit.
@russelljjarvis Does the fix in the rick branch work for you? I am able to run most of your notebook above with that branch, although I needed to make a few changes in the notebook:
Specific to me:
import os; os.environ['NEURON_HOME'] = '/opt/conda' # The path to my NEURON installation
- In terminal:
cd ~/neuronunit/neuronunit/models/NeuroML2; nrnivmodl
General
- Replace all calls to
set_params(var)
withset_params(**var)
(set_params takes key-value pairs, so a dict much be passed with **). - Replace all calls to
model.inject_square_current(iparams)
withmodel.inject_square_current(iparams['injected_square_current'])
(inject_square_current
expects an injected_square_current dict, not a whole dict of all params) - Not sure where
model.results['sim_time']
is coming from, so I just got rid of all of those. - Several cells need to be reordered since earlier cells use variables created in later cells.
- Fixes required in
get_neab
.
I'll push a new version of the notebook to my branch soon.
from neuronunit.
Actually, I cannot finish because of an issue in get_neab
. You wouldn't have encountered it because you have the all_tests.p
pickle file, but I cannot reconstruct it because of this line, which I don't understand, and which raises an Exception (you are trying to call a dictionary as a function). I see that you are trying to build a list of observations and tests. I get the observations (lists of NeuroElectroSummary objects for each cell), but I'm not sure whether you are actually trying instantiate tests here or what.
In any case, if you want to move forward, you can apply the same fixes as above in my last message, on the rick branch (which has all of your commits from master) and see if it works for you, since you already have all_tests.p
.
from neuronunit.
The method get_neab.process_all_cells()
. Seems to be the only method that runs without failing. Even then, it can't access every cell data set it was designed to obtain.
I put in a link to the wrong file.
https://github.com/russelljjarvis/NeuronunitOpt/blob/master/neuronunit/unit_test/working/NeuroML2_HH.ipynb
I will test out the rick branch later tonight.
from neuronunit.
Related Issues (20)
- newer test class for passive elephant tests breaks parallelism in dask, in the case of brian2 backend. HOT 4
- Documenting all Score edge cases that break optimization gradients HOT 3
- A document Notice to debug set PARALLEL_CONFIDENT=False
- Test Suites should be dictionaries not lists. HOT 7
- Use standardized units throughout
- Druckmann Tests are not proper tests
- Confirm that NeuronUnits jNeuromLB backend really can be regarded as a ground truth. HOT 7
- NU test.protocol should be flat or more predictable to traverse.
- Major NU interface redesigns could come with interface diagrams.
- documentation chapters of NeuronUnit should be upgraded to Unit Tests via pytest-ipynb
- 2.5 different code locations that determine sim_length need to be collapsed into one.
- Duplicated content injected current test protocol/parameter
- Installation Fails on Windows HOT 1
- create branch optimization based on dev, that I can merge pull requests into. HOT 2
- Migrate away from travis HOT 2
- Merge error in backend __init__.py HOT 2
- Missing closing ' HOT 1
- Relax constraints on install requirements HOT 1
- unresolved merge conflict in requirements.txt
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from neuronunit.