-
Notifications
You must be signed in to change notification settings - Fork 215
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
Devices2 #127
Devices2 #127
Conversation
Conflicts: brian2/monitors/ratemonitor.py brian2/monitors/spikemonitor.py brian2/synapses/synapses.py
… for standalone. Closes #122
…lso deriving from BrianObject). Rename Group.__init__ to Group._enable_group_attributes to avoid confusion between the two constructors
…daters etc. all work fine with changing dt. Closes #84
Wasn't patient enough for the travis run to finish, so I added two more changes which should close #84: |
Great. I think we should roll back the dt change though. It's not written in #84 (I guess we discussed by email), but there's an unresolved issue with |
Also I'm not sure that having |
Sorry, I did not express this very clearly. It's not about class NeuronGroup(BrianObject, Group):
def __init__(self, ...):
BrianObject.__init__(self, name=..., when=...)
....
Group.__init__(self) New: class NeuronGroup(Group):
def __init__(self, ...):
Group.__init__(self, name=..., when=...)
....
self._enable_group_attributes() |
Yep, understood. Just wondering if maybe we should keep |
…nserting all spikes from/into the SpikeQueue between runs
About the changing dt: It turned out to be easier than expected to make it work. I pushed a change that reads out all the spikes from the queue and reinserts them using the new dt. It seems to be working fine (I added a test). Of course it's not retrospectively using a finer temporal resolution if dt got smaller. But I don't see any way to make this work with any reasonable effort and it's a real corner case. About That all said: I'm not sure whether we really need |
Cool! I thought this would be a lot more work to get the changing dt thing going. OK, let's keep this then. For Basically, you use a metaclass to define group attribute access rather than a class, and this metaclass automatically modifies the def group_metaclass(name, parents, attributes):
if Group not in parents:
parents = parents+(Group,)
obj = type(name, parents, attributes)
obj._orig_init = obj.__init__
def newinit(self, *args, **kwds):
self._orig_init(*args, **kwds)
self._after_init()
obj.__init__ = newinit
return obj
class Group(object):
def _after_init(self):
print 'AfterInit'
class Base(object):
pass
class X(Base):
__metaclass__ = group_metaclass
def __init__(self):
print 'XInit'
x = X() This could be used in standard cases, and in cases where you needed more control you could not use the metaclass but rather derive from On the last point, yes we'll definitely want to simplify the whole |
variable initialisations
I was surprised myself -- but apparently a lot of the code already took a possibly changing dt into account, it was really only about the spikes in the queue. The code is not performance optimised at all ( About And I agree that we shouldn't do the cleaning up now. If you prefer, we can also revert the |
.spikes attribute
Good idea, class decorator is a much nicer idea than metaclass. Happy to keep the |
Actually I'm going to commit some changes to this branch that we won't want to merge immediately so I'm going to merge this now. |
It's too late now, but I am happy :) I filed an issue for the metaclass/class decorator idea at #130. |
How about merging this into master, to close #114 and #122?