polyfemos.parser.functionparser¶
Functions to parse filepaths from strings following the internal function syntax
- copyright
2019, University of Oulu, Sodankyla Geophysical Observatory
- license
GNU Lesser General Public License v3.0 or later (https://spdx.org/licenses/LGPL-3.0-or-later.html)
Public Functions
-
polyfemos.parser.functionparser.function_from_str(functionstr)[source]¶ Creates a simple function from given string.
The
functionstrmay or may not be inside parentheses, thefunctionstrmay not contain any other brackets (except curly brackets intead of<=and>=operations if wanted).Available operations in execution order, Order of execution of same operations is from left to right. Note that all of the operations take two arguments.
Operation
Alias
Description
**^power
*multiplication
/division
+addition
-substracion
<lesser than
<={lesser or equal
>greater than
>=}greater or equal
===equal
!=!not equal
&and
|or
rround, <num>r<decimals>
Available values
Value
Alias
Description
XThe variable/argument in the resulting function
FalseFboolean False
TrueTboolean False
Example
functionstrvalues(False) (X<4.0|X>7|X==5) (X<4.0|X>7) (X<=4.0|X>=7) (X*0.001r3) (X*10./27.+5.r3) (X<=-1)
- Parameters
functionstr (str) –
- Return type
func
- Returns
A one-argument function which returns either boolean or numeral depending on the used operations