-
Notifications
You must be signed in to change notification settings - Fork 61
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
Consistency in Naming #2239
Comments
@Helveg maybe something for you? |
I kind of like that arbor is slightly terse there. It's very consistent and explicit. If you allow this interchangability I think it will mostly just increase the cognitive load. What advantage do you see from it?
I can try, but if my IDE's refactor button doesn't find an occurence, neither will I ;) |
We do allow this conversion for
|
Added an even more annoying example. |
My vague voice from beyond says: I'd like to keep the 'm' prefix because the terms segment etc. are so overloaded in the literature that leaving the 'm' off invites more confusion. But with iclamp in particular, we should offer the C++ functionality in the Python API, ideally with the same names, and definitely with the same parameter orders. |
Hey @halfflat, thanks for the input. I agree on the conceptual overload and the need for disambiguation. These items could About i_clamp: I'd personally prefer to adjust the C++ API to the Python API, reasoning here is that we have a // NB. consistent naming with Python
iclamp(mA amplitude, Hz freq=0, rad=phase);
iclamp(ms from, ms duration, mA amplitude, Hz freq=0, rad phase=0);
iclamp([(ms, mA)] envelope, Hz freq=0, rad phase=0); Problem being, the first and second c'tors are ambiguous, so this would be my compromise: // NB. consistent naming with Python
iclamp(mA amplitude);
iclamp(ms from, ms duration, mA amplitude, Hz freq=0, rad phase=0);
iclamp([(ms, mA)] envelope, Hz freq=0, rad phase=0); although still a bit miffy. If I were designing this from scratch, I'd put the amplitude first 🤷. iclamp(ms from=0, ms duration=forever, mA amplitude=0, **, Hz freq=0, rad phase=0)
iclamp([(ms, mA)] envelope, **, Hz freq=0, rad phase=0) Again, I'd love to put the amplitude first, but that'd break too much existing code in my book. |
If we're aligning the APIs, we're going to have a version incompatibility regardless; perhaps it is better to break both in a way that will fail to compile (C++) or raise an exception if the old API is used? We could throw out the As things stand, I think the C++ API is currently the saner of the two though. |
The core issue here is to add units to the user facing API. I decided on using the LLNL/units library, which offers conversion and checking at runtime. Runtime is a requirement -- as much as I love static guarantees --, but keeping the interface uniform between Python and C++ is a must. While setting this up, I noticed the severe lack of IDE/LSP support for Arbor, so I added typing stubs using https://github.com/sizmailov/pybind11-stubgen. The conjunction of typing and units exposed misuse of pybind11 in several places, so next I had to massage the ordering of bindings, adjust the specification of default arguments, and add the odd missing binding. The schedule/event generator interface was tightened up, hiding the `*_impl` structs and exposing only the type erased `schedule` object. That in turn required de-generification of the Poisson schedule. Now, Mersenne twister is the only choice and I will remove that later on for the CBRNG we are already using elsewhere. Currently, units are used for: - [X] simulation - [X] schedule/generator - [x] paintables - [X] placeables - [X] iclamp - [X] threshold - [X] connections - [X] gap junctions Adding units to mechanism interfaces is _interesting_ but requires more work and thought, so I'll defer that to a later point in time. We'd need to adjust modcc to expose and **check** units and devise a scheme to handle missing units. Generic TODOs; some might spin off into separate issues. - [x] ~~rename py::iclamp OR cpp::i_clamp for consistency~~ covered by #2239 - [x] use scale/base for iexpr paintables for consistency with scaled_mech - [x] ~~Use CBRNG for Poisson schedule~~ covered by #2243 - [ ] Automate stub generation. A wishlist item, requires installing extra software. - [x] Properly integrate units w/ spack. NB. Units doesn't have a spackage. Closes #1983 Closes #2032 --------- Co-authored-by: boeschf <[email protected]>
Currently we have a few hooplas in C++/Python API consistency:
Current clamps
i_clamp ./. iclamp: Either the C++ or the Python member needs to be renamed.
In Python
iclamp(1, 2, 3)
will give a 3nA current starting at 1ms and ending at 3ms. InC++
i_clamp(1, 2, 3)
will result in a 1nA current with a sine profile of 2kHz phase shiftedby 3rad. Python's behaviour is handled by
i_clamp::box
in C++. Clearly, this needs to change.Morphology
Some morphology primitive have the
m
prefix, some not.Things to consider
m
prefix, iemcable
->cable
cable { branch, from, to}
<>(branch, from, to)
The text was updated successfully, but these errors were encountered: