modelpattern module
Created on Mon Sep 02 19:32:22 2013
This module defines a number of pattern used in PYFS. If a new function is intruduced in the model definition language it should added to the function names in funkname
All functions in the module modeluserfunk will be added to the language and incorporated in the Business Logic language
@author: Ib
- class modelpattern.nterm(number, op, var, lag)
Bases:
tupleCreate new instance of nterm(number, op, var, lag)
- lag
Alias for field number 3
- number
Alias for field number 0
- op
Alias for field number 1
- var
Alias for field number 2
- modelpattern.find_frml(equations)[source]
Takes at modeltext and returns a list with where each element is a string starting with FRML and ending with $ It do not check if it is a valid FRML statement
- modelpattern.split_frml(frml)[source]
Splits a string with a frml into a tuple with 4 parts:
The unsplit frml statement
FRML
<Frml name>
<the frml expression>
- modelpattern.find_statements(a_model)[source]
splits a modeltest into comments and statements
a comment starts with ! and ends at lineend
a statement starts with a name and ends with a $ all characters between are considerd part of the statement
The statement is not chekked for meaningfulness returns a list of tuppels (comment,command,<rest of statement>)
- modelpattern.model_parse_old(equations, funks=[])[source]
- Takes a model returns a list of tupels. Each tupel contains:
- the compleete formular:
- FRML:
- formular name:
- the expression:
- list of terms from the expression:
The purpose of this function is to make model analysis faster. this is 20 times faster than looping over espressions in a model
- modelpattern.model_parse(equations, funks=[])[source]
- Takes a model returns a list of tupels. Each tupel contains:
- the compleete formular:
- FRML:
- formular name:
- the expression:
- list of terms from the expression:
The purpose of this function is to make model analysis faster. this is 20 times faster than looping over espressions in a model
This new model_parse handels lags of -0 or +0 which ocours in some models from world bank.
- modelpattern.list_extract(equations, silent=True)[source]
creates lists used in a model
returns a dictonary with the lists if a list is defined several times, the first definition is used
- modelpattern.check_syntax_model(equations, test=True)[source]
cheks if equations have syntax errors by calling the python compile.parse
- modelpattern.udtryk_parse(udtryk, funks=[])[source]
returns a list of terms from an expression ie: lhs=rhs $ or just an expression like x+b