brian-team/brian2 — pull request #316 by mstimberg (2014-08-25 13:47:41+00:00)
Title: check_units fix

The `@check_units` decorator fulfills two roles: in addition to making a function check the units of its arguments it also stores this information into the function object so that it can be accessed by code generation -- this way, numpy code generation can directly make use of any Python function that is annotated with `@check_units`.

In our testing, we only used functions with a single argument, and in fact `@check_units` screwed the information up for more than one argument (thanks to Maurizio De Pittà for reporting this). Basically, it stored the units in the `_arg_units` list simply in the (undefined) order of the keywords dictionary, instead of in the order of the arguments.

This pull request fixes this, improves the error messages around all this and adds a few tests.