replace_floating_point_literals function

(Shortest import: from brian2cuda.utils import replace_floating_point_literals)

brian2cuda.utils.stringtools.replace_floating_point_literals(code)[source]

Replace double-precision floating-point literals in code by single-precision literals.

Parameters:

code : str

A string to replace the literals in. C++ syntax is assumed, s.t. e.g. a1.b would not be replaced.

Returns:

str :

A copy of code, with double-precision floating point literals replaced by single-precision flaoting-point literals (with an f appended).

Examples

>>> replace_floating_point_literals('1.|.2=3.14:5e6>.5E-2<7.e-8==a1.b')
1.f|.2f=3.14f:5e6f>.5E-2f<7.e-8f==a1.b