Ux/units (#2233)
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 <48126478+boeschf@users.noreply.github.com>
Showing
- .github/workflows/test-spack.yml 1 addition, 0 deletions.github/workflows/test-spack.yml
- .gitmodules 3 additions, 0 deletions.gitmodules
- CMakeLists.txt 14 additions, 0 deletionsCMakeLists.txt
- arbor/backends/gpu/threshold_watcher.hpp 1 addition, 1 deletionarbor/backends/gpu/threshold_watcher.hpp
- arbor/cable_cell.cpp 1 addition, 5 deletionsarbor/cable_cell.cpp
- arbor/cable_cell_param.cpp 26 additions, 25 deletionsarbor/cable_cell_param.cpp
- arbor/fvm_layout.cpp 25 additions, 31 deletionsarbor/fvm_layout.cpp
- arbor/include/arbor/cable_cell.hpp 1 addition, 2 deletionsarbor/include/arbor/cable_cell.hpp
- arbor/include/arbor/cable_cell_param.hpp 166 additions, 52 deletionsarbor/include/arbor/cable_cell_param.hpp
- arbor/include/arbor/event_generator.hpp 22 additions, 26 deletionsarbor/include/arbor/event_generator.hpp
- arbor/include/arbor/iexpr.hpp 6 additions, 6 deletionsarbor/include/arbor/iexpr.hpp
- arbor/include/arbor/lif_cell.hpp 11 additions, 8 deletionsarbor/include/arbor/lif_cell.hpp
- arbor/include/arbor/morph/isometry.hpp 1 addition, 1 deletionarbor/include/arbor/morph/isometry.hpp
- arbor/include/arbor/recipe.hpp 13 additions, 7 deletionsarbor/include/arbor/recipe.hpp
- arbor/include/arbor/schedule.hpp 35 additions, 194 deletionsarbor/include/arbor/schedule.hpp
- arbor/include/arbor/simulation.hpp 1 addition, 3 deletionsarbor/include/arbor/simulation.hpp
- arbor/include/arbor/spike_event.hpp 0 additions, 1 deletionarbor/include/arbor/spike_event.hpp
- arbor/include/arbor/units.hpp 189 additions, 0 deletionsarbor/include/arbor/units.hpp
- arbor/lif_cell_group.cpp 2 additions, 2 deletionsarbor/lif_cell_group.cpp
- arbor/lif_cell_group.hpp 41 additions, 1 deletionarbor/lif_cell_group.hpp
Please register or sign in to comment