-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Test Suites should be dictionaries not lists. #233
Comments
This would be a fundamental SciUnit change that I cannot easily make while other libraries depend on it. However, you can always access an element of a list by its attributes, e.g. There are several candidates for that attribute. If you name the tests in your suite (with the |
Actually, I can make this even easier. I'll just change the |
OK, that was easy. In sciunit dev branch (implemented in scidash/sciunit@deb589d), you can now do this:
Which will print |
Okay, can we keep this issue open until I establish if this syntax works? Now that you have changed suites internal code, maybe method binding would be a better solution. from sciunit import TestSuite
class TSD(TestSuite):
def __init__(self,tests={},use_rheobase_score=False):
self.DO = None
super(TSD,self).__init__(tests)
self.update(tests)
if 'name' in self.keys():
self.cell_name = tests['name']
self.pop('name',None)
else:
self.cell_name = 'simulated data'
self.use_rheobase_score = use_rheobase_score
self.elaborate_plots = elaborate_plots
self.backend = None
def optimize(self,param_edges,backend=None,protocol={'allen': False, 'elephant': True},\ |
Sure, I've reopened it. But based on the changes I made above in scidash/sciunit@deb589d, you won't need to call
where I took out |
Hey Rick, to properly fit my use case, I may need a bit more developmental support. My use case is cell 11. I may need you to help design a derived class TSS. That inherits from TestSuite, but has an optimize method. You can see my stumbling attempt to do that here. What I want to do is take a collection of sciunit tests, that are already dictionaries and to construct a test suite out of it (something that behaves like a dictionary). I think the constructor should be able to accept both lists and dictionaries. It should sense if it receives a dictionary type and just converts dict to list if appropriate. I think what exists now, is a suite, that has key,value behavior (like a dictionary), but its constructed only from lists. The other thing that would help is if upon construction if I could pass in the user-defined optimization method to the constructor as a constructor method? That would help to circumvent messy post hoc method binding, that you can see in the notebooks here. tests= test_frame['Neocortex pyramidal cell layer 5-6']
tests['name'] = 'Neocortex pyramidal cell layer 5-6'
tt = list(tests.values())[0:-1]
tt = TestSuite(tt)
TD = TSD(tests)
tt.optimize = MethodType(TD.optimize,tt)
return tt
def optimize_selection(backend,cell_id= None):
#code;
NGEN = 8
MU = 4
"""
tests= self.test_frame['Hippocampus CA1 pyramidal cell']
tests['name'] = 'Hippocampus CA1 pyramidal cell'
a = TestSuite(tests)
a.optimize = MethodType(optimize,a)
tests = TSD(tests = tests,use_rheobase_score=True)
"""
tt = process_tests()backend,protocol={'allen': False, 'elephant': True
param_edges = model_parameters.MODEL_PARAMS[backend]
out = tt.optimize(param_edges,MU=5,NGEN=5,free_params=param_edges.keys())
return out
#return optimized_models, passive_ |
Addressed in russelljjarvis/neuronunit_opt@3ee0f2db709252dc02e34c8518a74f845238e90e and subsequent commits. |
I think it is better to have test suites be dictionaries rather than a list. When using NU tests for optimization, you often want to know how one particular test in the suite is going, you want a way to refer to that test programmatically without keeping track of the list index for that test, which should be arbitrary.
The text was updated successfully, but these errors were encountered: