Welcome to PyCrop2ML Documentation

Contents .. _pycropml:

PyCrop2ML documentation

Module description

What is PyCrop2ML?

PyCrop2ML is a free, open-source library for defining and exchanging CropML models.It is used to generate components of modeling and simulation platforms from the CropML specification and allow component exchange between different platform.
It allows to parse the models described in CropML format and automatically generate the equivalent executable Python, java, C#, C++ components and packages usable from existing crop simulation platform.

What is Crop2ML ?

CropML is a XML-(JSON-)based language used to represent different biological processes involved in the crop models.
CropML project aims to provide common framework for defining and exchanging descriptions of crop growth models between crop simulation frameworks.
Objectives

Our main objectives are:

  • define a declarative language to describe either an atomic model or a composition of models
  • add semantic dimension to CropML language by annotation of the models to allow the composition of components of different platforms by using the standards of the semantic web
  • develop a library to allow the transformation and the exchange of CropML model between different Crop modelling and simulation platform
  • provide a web repository enabling registration, search and discovery of CropML Models
  • facilitate Agricultural Model Exchange Initiative
Context
Nowadays, we observe the emergence of plant growth models which are built in different platforms. Although standard platform development initiatives are emerged, there is a lack of transparency, reusability, and exchange code between platforms due to the high diversity of modeling languages leading to a lack of benchmarking between the different platforms.
This project aims to gather developers and plant growth modelers to define a standard framework based on the development of declarative language and libraries to improve exchange model components between platforms.
Motivation
Our motivation is to:
  • Strengthen the synergy between crop modelers, users and scientific researchers
  • Facilitate model intercomparison (at the process level) and model improvement through the exchange of model components (algorithms) and code reuse between platforms/models.
  • Bridge the gap between ecophysiologists who develop models at the process level with crop modelers and model users and facilitate the integration in crop models of new knowledge in plant science (i.e. we are seeking the exchange of knowledge rather than black box models).
  • Increase capabilities and responsiveness to stakeholder’ needs.
  • Propose a solution to the AgMIP community for NexGen crop modeling tools.
Vision
  • Facilitate the development of complex models
  • Use modular modelling to share knowledge and rapidly develop operational tools.
  • Reuse model parts to leverage the expertise of third parties;
  • Renovate legacy code.
  • Realize the benefit of sharing and complementing different expertise.
  • Promote model sharing and reuse

Crop2ML Description

In Crop2ML, a model is either a model unit or a composition of models. ModelUnit represents an atomic unit of a crop model. A model composition is a model resulting from the composition of two or more atomic model or composite models.
These models have a specific formal definition in Crop2ML.
Formal definition of a Model Unit in Crop2ML
The structure of a Model Unit in Crop2ML MUST be conform to a specific Document Type Definition named ModelUnit.dtd .
So a Model Unit Crop2ML document is a XML document well-formed and also obeys the rules given in the ModelUnit structure.
This structure MAY be described by the below tree:
_images/modelunit.png
For more details, consult Crop2ML model unit specification .
Formal definition of a Composite Model in Crop2ML
A Composite Model Crop2ML is an assembly of processes which are described by a set of model units or a composition of models. Given a composite model is a model, this one has also inputs, outputs and internal state which describe the orchestration of different independent models composed.
The structure of a Composite Model in Crop2ML MUST conform to a specific Document Type Definition named ModelComposition.dtd .
The composition is represented as a directed port graph of models:
Vertices are the different models that form the composition.
Ports are the inputs and outputs of each model.
Edges are directed and connect one output port to an input port of another model.
It contains in addition to all Elements of a model unit a Composition Element for the composition of models.
This structure MAY be described by the below tree:
_images/modelcomposition.PNG
| For more details, consult Crop2ML model composite specification .

CyML Language Specification

This document specifies the CyML language, an extended Cython subset supported.

Cython file types

  • The implementation files, carrying a .pyx suffix.
Basic Types

The following basic types are supported

  • bool
  • int
  • float
  • double
  • string
Complex Types

The following complex types are supported

  • array
  • list
  • datetime
Conditional Statements
  • IF
  • IF/Else
  • IF/ElseIf/Else

The ELIF and ELSE clauses are optional. An IF statement can appear anywhere that a normal statement or declaration can appear

Integer For Loops

CyML recognises the usual Python for-in-range integer loop pattern:

for i in range(n):
    ...

Like other Python looping statements, break and continue may be used in the body, without the loop that have an else clause.

While Loop
  • Like Python While loop
Function
  • Parameters with declaration
  • Default value is possible
Return Statement
  • A function needs to return the same data type.

The following code is valid:

def fibonacci(int n):
    if n <= 2:
        return 1
    else:
        return fibonacci(n-1)+fibonacci(n-2)
Call functions
  • Call to CyML functions are supported if the function
  • is accessible on the module
  • is accessible from import statement
Operators

Assignment

Assign b = a

Unary operators

UAdd +a
USub -a

Binary operators

Add a + b
Sub a - b
Mult a * b
Div a / b
FloorDiv a // b
Pow a ** b
Mod a % b
LShift a << b
RShift a >> b
BitOr a | b
BitXor a ^ b
BitAnd a & b

Augmented assign statements

AugAdd a += b
AugSub a -= b
AugMult a *= b
AugDiv a /= b

Comparison Operators

Eq a == b
NotEq a != b
Lt a < b
LtE a <= b
Gt a > b
GtE a >= b

Bool Operators

&& a and b
|| a or b
Array creation routines
`` `` Return a new array of given shape and type, without initializing entries.
`` `` Return a new array of given shape and type, filled with ones.
`` `` Return a new array of given shape and type, filled with zeros.
Mathematical functions

Trigonometric functions

sin(x) Trigonometric sine, element-wise.
cos(x) Cosine elementwise.
tan(x) Compute tangent element-wise.
arcsin(x) Inverse sine, element-wise.
arccos(x) Trigonometric inverse cosine, element-wise.
arctan(x) Trigonometric inverse tangent, element-wise.

Hyperbolic functions

sinh(x) Hyperbolic sine, element-wise.
cosh(x) Hyperbolic cosine, element-wise.
tanh(x) Compute hyperbolic tangent element-wise.

PyCrop2ML User Guide

Version:1.1.0
Release:1.1.0
Date:Oct 07, 2020

This reference manual details functions, modules, and objects included in OpenAlea.Core, describing what they are and what they do. For a complete reference guide, see core_reference.

Warning

This “Reference Guide” is still very much in progress. Many aspects of OpenAlea.Core are not covered.

Manual

Note

The following examples assume you have installed the packages and setup your python path correctly.

Installation
conda install -c openalea pycropml

or

python setup.py install
Overview of the different classes

src

pycropml package
Subpackages
pycropml.interface package
Submodules
pycropml.interface.design module
pycropml.interface.version module

Maintain version for this package. Do not edit this file, use ‘version’ section of config.

pycropml.interface.version.MAJOR = 0

(int) Version major component.

pycropml.interface.version.MINOR = 0

(int) Version minor component.

pycropml.interface.version.POST = 2

(int) Version post or bugfix component.

Module contents
pycropml.transpiler package
Subpackages
pycropml.transpiler.generators package
Submodules
pycropml.transpiler.generators.checkGenerator module
class pycropml.transpiler.generators.checkGenerator.CheckCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.checkGenerator.CheckGenerator

This class used to generates states, rates and auxiliary classes for C# languages.

class pycropml.transpiler.generators.checkGenerator.CheckGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.pythonRules.PythonRules

This class contains the specific properties of python language and use the NodeVisitor to generate a python code source from a well formed syntax tree.

visit_ExprStatNode(node)[source]
visit_array(node)[source]
visit_assignment(node)[source]
visit_binary_op(node)[source]
visit_bool(node)[source]
visit_breakstatnode(node)[source]
visit_call(node)[source]
visit_comparison(node)[source]
visit_cond_expr_node(node)[source]
visit_continuestatnode(node)[source]
visit_custom_call(node)[source]
visit_datetime(node)[source]
visit_declaration(node)[source]
visit_dict(node)[source]
visit_else_statement(node)[source]
visit_elseif_statement(node)[source]
visit_float(node)[source]
visit_for_iterator(node)[source]
visit_for_iterator_with_index(node)[source]
visit_for_range_statement(node)[source]
visit_for_sequence(node)[source]
visit_for_sequence_with_index(node)[source]
visit_for_statement(node)[source]
visit_function_definition(node)[source]
visit_if_statement(node)[source]
visit_implicit_return(node)[source]
visit_import(node)[source]
visit_importfrom(node)[source]
visit_index(node)[source]
visit_list(node)[source]
visit_local(node)[source]
visit_method_call(node)[source]
visit_module(node)[source]
visit_notAnumber(node)[source]
visit_pair(node)[source]
visit_sliceindex(node)[source]
visit_standard_call(node)[source]
visit_standard_method_call(node)[source]
visit_str(node)[source]
visit_tuple(node)[source]
visit_unary_op(node)[source]
visit_while_statement(node)[source]
pycropml.transpiler.generators.cppGenerator module
pycropml.transpiler.generators.csharpGenerator module
pycropml.transpiler.generators.docGenerator module
class pycropml.transpiler.generators.docGenerator.DocGenerator(model=None, tag='#')[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator

Generate doc in different target language - desccription of the code - Inputs details - Outputs details

comment(doc)[source]
doc(x, name)[source]
generate_desc(model)[source]
generate_header(model)[source]
pycropml.transpiler.generators.fortranGenerator module
class pycropml.transpiler.generators.fortranGenerator.FortranCompo(tree=None, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.fortranGenerator.FortranGenerator

This class used to generates states, rates and auxiliary classes for Fortran90 language.

visit_importfrom(node)[source]

self.newline(node) self.write(‘Use ‘) for idx, item in enumerate(node.name):

if idx:
self.write(‘, ‘)

self.write(“%smod”%item.split(“model_”)[1].capitalize())

class pycropml.transpiler.generators.fortranGenerator.FortranGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.fortranRules.FortranRules

This class contains the specific properties of fortran language and use the NodeVisitor to generate a fortran code source from a well formed syntax tree.

add_features(node)[source]
binop_precedence = {'!=': 4, '%': 11, '&': 7, '*': 11, '**': 12, '+': 9, '-': 9, '/': 11, '//': 11, '<': 4, '<<': 8, '<=': 4, '==': 4, '>': 4, '>=': 4, '>>': 8, '@': 11, '^': 6, 'and': 2, 'in': 4, 'is': 4, 'is_not': 4, 'not_in': 4, 'or': 1, '|': 5}
body(statements)[source]
checkIndex(node)[source]
doc = None

# get constant parameters in models if inp.inputtype==”parameter”:

#print(inp.name, model.name) if inp.parametercategory==”constant”:

self.mod_parameters.append(inp.name)
Type:for inp in self.model.inputs
internal_declaration(node)[source]
part_declaration(node)[source]
retrieve_params(node)[source]
subOrFun(node)[source]
transform_return(node)[source]
unop_precedence = {'!': 3, '+': 10, '-': 10, 'not': 3, '~': 10}
visit_ExprStatNode(node)[source]
visit_array_decl(node)[source]
visit_assignment(node)[source]
visit_binary_op(node)[source]
visit_bool(node)[source]
visit_bool_decl(node)[source]
visit_breakstatnode(node)[source]
visit_call(node)[source]
visit_combine(node)[source]
visit_comparison(node)[source]
visit_cond_expr_node(node)[source]
visit_continuestatnode(node)[source]
visit_custom_call(node)[source]
visit_datetime(node)[source]
visit_datetime_decl(node)[source]
visit_decl(nodeT)[source]
visit_declaration(node)[source]
visit_else_statement(node)[source]
visit_elseif_statement(node)[source]
visit_float(node)[source]
visit_float_decl(node)[source]
visit_for_iterator(node)[source]
visit_for_iterator_with_index(node)[source]
visit_for_range_statement(node)[source]
visit_for_sequence(node)[source]
visit_for_statement(node)[source]
visit_function(node)[source]
visit_function_definition(node)[source]
visit_if_statement(node)[source]
visit_implicit_return(node)[source]
visit_import(node)[source]
visit_importfrom(node)[source]

self.newline(node) self.write(‘from %s import ‘ % (node.namespace)) for idx, item in enumerate(node.name):

if idx:
self.write(‘, ‘)

self.write(item)

visit_index(node)[source]
visit_int(node)[source]
visit_int_decl(node)[source]
visit_list(node)[source]
visit_list_decl(node)[source]
visit_local(node)[source]
visit_method_call(node)[source]
visit_module(node)[source]
visit_notAnumber(node)[source]
visit_pair(node)[source]
visit_sliceindex(node)[source]
visit_standard_call(node)[source]
visit_standard_method_call(node)[source]
visit_str(node)[source]
visit_str_decl(node)[source]
visit_subroutine(node)[source]
visit_subroutine_def(node)[source]
visit_tab(node)[source]
visit_unary_op(node)[source]
visit_while_statement(node)[source]
pycropml.transpiler.generators.fortranGenerator.checkList(list1, list2)[source]
pycropml.transpiler.generators.fortranGenerator.valParam(model, name)[source]
pycropml.transpiler.generators.javaGenerator module
class pycropml.transpiler.generators.javaGenerator.JavaCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.javaGenerator.JavaTrans, pycropml.transpiler.generators.javaGenerator.JavaGenerator

This class used to generates states, rates and auxiliary classes for java language.

copyconstructor(node)[source]
get_mo(varname)[source]
initCompo()[source]
instanceModels()[source]
setCompo(p)[source]
visit_assignment(node)[source]
visit_declaration(node)[source]
visit_function_definition(node)[source]
visit_implicit_return(node)[source]
visit_module(node)[source]
visit_return(node)[source]
class pycropml.transpiler.generators.javaGenerator.JavaGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.javaRules.JavaRules

This class contains the specific properties of Java language and use the NodeVisitor to generate a java code source from a well formed syntax tree.

add_features(node)[source]
gettype(arg)[source]
internal_declaration(node)[source]
retrieve_params(node)[source]
transform_return(node)[source]
visit_array(node)[source]
visit_array_decl(node)[source]
visit_assignment(node)[source]
visit_binary_op(node)[source]
visit_bool(node)[source]
visit_bool_decl(node)[source]
visit_breakstatnode(node)[source]
visit_call(node)[source]
visit_comparison(node)[source]
visit_cond_expr_node(node)[source]
visit_constant(node)[source]
visit_continuestatnode(node)[source]
visit_custom_call(node)[source]

TODO

visit_datetime_decl(node)[source]
visit_decl(node)[source]
visit_declaration(node)[source]
visit_dict(node)[source]
visit_dict_decl(node)[source]
visit_else_statement(node)[source]
visit_elseif_statement(node)[source]
visit_float(node)[source]
visit_float_decl(node)[source]
visit_for_iterator(node)[source]
visit_for_iterator_with_index(node)[source]
visit_for_range_statement(node)[source]
visit_for_sequence_with_index(node)[source]
visit_for_statement(node)[source]
visit_function_definition(node)[source]
visit_if_statement(node)[source]
visit_implicit_return(node)[source]
visit_import(node)[source]
visit_importfrom(node)[source]
visit_index(node)[source]
visit_int_decl(node)[source]
visit_list(node)[source]
visit_list_decl(node)[source]
visit_method_call(node)[source]
visit_module(node)[source]
visit_notAnumber(node)[source]
visit_pair(node)[source]
visit_print()[source]
visit_return(node)[source]
visit_sliceindex(node)[source]
visit_standard_call(node)[source]
visit_standard_method_call(node)[source]
visit_str(node)[source]
visit_str_decl(node)[source]
visit_tuple(node)[source]
visit_tuple_decl(node)[source]
visit_unary_op(node)[source]
visit_while_statement(node)[source]
class pycropml.transpiler.generators.javaGenerator.JavaTrans(models)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.javaRules.JavaRules

This class used to generates states, rates and auxiliary classes for java language.

DATATYPE = {'BOOLEAN': 'bool', 'DATE': 'datetime', 'DATEARRAY': ['array', 'datetime'], 'DATELIST': ['list', 'datetime'], 'DOUBLE': 'float', 'DOUBLEARRAY': ['array', 'float'], 'DOUBLELIST': ['list', 'float'], 'INT': 'int', 'INTARRAY': ['array', 'int'], 'INTLIST': ['list', 'int'], 'STRING': 'str', 'STRINGARRAY': ['array', 'str'], 'STRINGLIST': ['list', 'str']}
access(node)[source]
copyconstructor(node)[source]
generate(nodes, typ)[source]
getset(node)[source]
gettype(arg)[source]
model2Node()[source]
private(node)[source]
visit_array_decl(node)[source]
visit_bool_decl(node)[source]
visit_datetime_decl(node)[source]
visit_decl(node)[source]
visit_dict_decl(node)[source]
visit_float_decl(node)[source]
visit_int_decl(node)[source]
visit_list_decl(node)[source]
visit_str_decl(node)[source]
visit_tuple_decl(node)[source]
pycropml.transpiler.generators.javaGenerator.argsToStr(args)[source]
pycropml.transpiler.generators.javaGenerator.to_struct_java(models, rep, name)[source]
pycropml.transpiler.generators.openaleaGenerator module
class pycropml.transpiler.generators.openaleaGenerator.OpenaleaCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.pythonGenerator.PythonCompo

This class used to generates states, rates and auxiliary classes for C# languages.

generate_factory(model)[source]

Create a Node Factory from CropML model unit.

generate_wralea(mc)[source]

Generate wralea factories from the meta-information of the the model units.

class pycropml.transpiler.generators.openaleaGenerator.OpenaleaGenerator(tree=None, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.pythonGenerator.PythonGenerator

This class contains the specific properties of OpenAlea and use the NodeVisitor to generate a csharp code source from a well formed syntax tree.

pycropml.transpiler.generators.openaleaGenerator.openalea_interface(inout)[source]
pycropml.transpiler.generators.openaleaGenerator.signature(model)[source]
pycropml.transpiler.generators.pythonGenerator module
class pycropml.transpiler.generators.pythonGenerator.PythonCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.pythonGenerator.PythonGenerator

This class used to generates states, rates and auxiliary classes for C# languages.

class pycropml.transpiler.generators.pythonGenerator.PythonGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.pythonRules.PythonRules

This class contains the specific properties of python language and use the NodeVisitor to generate a python code source from a well formed syntax tree.

comment(doc)[source]
visit_ExprStatNode(node)[source]
visit_array(node)[source]
visit_assignment(node)[source]
visit_binary_op(node)[source]
visit_bool(node)[source]
visit_breakstatnode(node)[source]
visit_call(node)[source]
visit_comparison(node)[source]
visit_cond_expr_node(node)[source]
visit_continuestatnode(node)[source]
visit_custom_call(node)[source]
visit_datetime(node)[source]
visit_declaration(node)[source]
visit_dict(node)[source]
visit_else_statement(node)[source]
visit_elseif_statement(node)[source]
visit_float(node)[source]
visit_for_iterator(node)[source]
visit_for_iterator_with_index(node)[source]
visit_for_range_statement(node)[source]
visit_for_sequence(node)[source]
visit_for_sequence_with_index(node)[source]
visit_for_statement(node)[source]
visit_function_definition(node)[source]
visit_if_statement(node)[source]
visit_implicit_return(node)[source]
visit_import(node)[source]
visit_importfrom(node)[source]
visit_index(node)[source]
visit_list(node)[source]
visit_method_call(node)[source]
visit_module(node)[source]
visit_notAnumber(node)[source]
visit_pair(node)[source]
visit_sliceindex(node)[source]
visit_standard_call(node)[source]
visit_standard_method_call(node)[source]
visit_str(node)[source]
visit_tuple(node)[source]
visit_unary_op(node)[source]
visit_while_statement(node)[source]
pycropml.transpiler.generators.rGenerator module
class pycropml.transpiler.generators.rGenerator.RCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.rGenerator.RGenerator

This class used to generates states, rates and auxiliary classes for C# languages.

visit_tuple(node)[source]
class pycropml.transpiler.generators.rGenerator.RGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.rRules.RRules

This class contains the specific properties of R language and use the NodeVisitor to generate a R code source from a well formed syntax tree.

comment(doc)[source]
multValreturn(node)[source]
visit_ExprStatNode(node)[source]
visit_array(node)[source]
visit_assignment(node)[source]
visit_binary_op(node)[source]
visit_bool(node)[source]
visit_breakstatnode(node)[source]
visit_comparison(node)[source]
visit_cond_expr_node(node)[source]
visit_continuestatnode(node)[source]
visit_datetime(node)[source]
visit_declaration(node)[source]
visit_else_statement(node)[source]
visit_elseif_statement(node)[source]
visit_float(node)[source]
visit_for_iterator(node)[source]
visit_for_iterator_with_index(node)[source]
visit_for_range_statement(node)[source]
visit_for_sequence(node)[source]
visit_for_sequence_with_index(node)[source]
visit_for_statement(node)[source]
visit_function_definition(node)[source]
visit_if_statement(node)[source]
visit_implicit_return(node)[source]
visit_import(node)[source]
visit_importfrom(node)[source]
visit_index(node)[source]
visit_list(node)[source]
visit_method_call(node)[source]
visit_module(node)[source]
visit_notAnumber(node)[source]
visit_pair(node)[source]
visit_sliceindex(node)[source]
visit_standard_call(node)[source]
visit_standard_method_call(node)[source]
visit_str(node)[source]
visit_tuple(node)[source]
visit_unary_op(node)[source]
visit_while_statement(node)[source]
pycropml.transpiler.generators.recordGenerator module
<vle_project version=”1.1.x” date=”2012-Oct-03 13:01:13” author=”Eric Casellas”>
<structures>
<model width=”2184” height=”1280” name=”2CV_parcelle” type=”coupled”>
<submodels>
<model observables=”vueDecision” conditions=”condDecFSA” dynamics=”dynDecFSA” debug=”false” width=”100” height=”75” x=”132” y=”26” name=”Decision” type=”atomic”></model> <model width=”100” height=”165” x=”316” y=”127” name=”2CV” type=”coupled”></model>

</submodels> <connections> </connections>

</model>

</structures> <dynamics> </dynamics> <experiment name=”2CV_parcelle”> </experiment>

</vle_project>

pycropml.transpiler.generators.simplaceGenerator module
class pycropml.transpiler.generators.simplaceGenerator.SimplaceCompo(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.javaGenerator.JavaGenerator

class pycropml.transpiler.generators.simplaceGenerator.SimplaceGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.javaGenerator.JavaGenerator

visit_declaration(node)[source]
visit_function_definition(node)[source]
visit_import(node)[source]
visit_local(node)[source]
visit_module(node)[source]
visit_return(node)[source]
pycropml.transpiler.generators.siriusGenerator module
Module contents
pycropml.transpiler.lib package
Module contents
pycropml.transpiler.rules package
Submodules
pycropml.transpiler.rules.cppRules module
class pycropml.transpiler.rules.cppRules.CppRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': '&&', 'not': '!', 'or': '||'}
constant = {'math': {'pi': 'M_PI'}}
constructor = '\n %s::%s()\n {\n \n }\n '
copy_constr = '\n public %s(%s toCopy, bool copyAll) // copy constructor \n {\n if (copyAll)\n {\n '
copy_constrArray = '\n for (int i = 0; i < %s; i++)\n {\n _%s[i] = toCopy._%s[i];\n }\n '
copy_constrList = '\n for (int i = 0; i < toCopy.%s.Count; i++)\n {\n %s.Add(toCopy.%s[i]);\n }\n '
copy_constr_compo = '\nvoid %s(%s& toCopy): this() // copy constructor \n{\n'
functions = {'datetime': {'datetime': ' new DateTime'}, 'io': {'print': 'cout<<', 'read': 'Console.ReadLine', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'acos', 'asin': 'asin', 'atan': 'atan', 'ceil': '(int) ceil', 'cos': 'cos', 'exp': 'exp', 'ln': 'log', 'log': 'log10', 'pow': 'pow', 'round': 'round', 'sin': 'asin', 'sqrt': 'sqrt', 'tan': 'tan'}, 'system': {'abs': 'abs', 'max': 'max', 'min': <function translateMIN>, 'pow': 'pow'}}
methods = {'array': {'append': '.Add', 'len': <function translateLenArray>}, 'dict': {'get': <function translateget>, 'keys': <function translatekeyDict>, 'len': <function translateLenDict>}, 'float': {'int': 'int'}, 'int': {'float': 'float'}, 'list': {'append': '.push_back', 'contains?': <function translateContains>, 'index': <function translateIndex>, 'insert_at': <function translateInsert>, 'len': <function translateLenList>, 'not contains?': <function translateNotContains>, 'pop': <function translatePop>, 'sum': <function translateSum>}, 'str': {'find': '.find', 'int': 'int', 'len': <function translateLenStr>}}
public_properties = '\n {\n get\n {\n return this._%s;\n }\n set\n {\n this._%s= value;\n } \n }'
public_properties_compo = '\n {\n get\n {\n return _%s.%s;\n }\n set\n {\n %s\n } \n }\n '
public_properties_wrap = '{ get { return %s.%s;}} \n '
types = {'array': 'array<%s, %s> ', 'bool': 'bool', 'datetime': 'string', 'dict': 'map', 'float': 'float', 'int': 'int', 'list': 'vector', 'str': 'string', 'tuple': 'tuple'}
unary_op = {'+': '+', '-': '-', 'not': '!', '~': '~'}
pycropml.transpiler.rules.cppRules.translateContains(node)[source]
pycropml.transpiler.rules.cppRules.translateIndex(node)[source]
pycropml.transpiler.rules.cppRules.translateInsert(node)[source]
pycropml.transpiler.rules.cppRules.translateLenArray(node)[source]
pycropml.transpiler.rules.cppRules.translateLenDict(node)[source]
pycropml.transpiler.rules.cppRules.translateLenList(node)[source]
pycropml.transpiler.rules.cppRules.translateLenStr(node)[source]
pycropml.transpiler.rules.cppRules.translateMIN(node)[source]
pycropml.transpiler.rules.cppRules.translateNotContains(node)[source]
pycropml.transpiler.rules.cppRules.translatePop(node)[source]
pycropml.transpiler.rules.cppRules.translateSum(node)[source]
pycropml.transpiler.rules.cppRules.translateget(node)[source]
pycropml.transpiler.rules.cppRules.translatekeyDict(node)[source]
pycropml.transpiler.rules.csharpRules module
class pycropml.transpiler.rules.csharpRules.CsharpRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': '&&', 'not': '!', 'or': '||'}
constant = {'math': {'pi': 'Math.PI'}}
constructor = '\n public %s() { }\n '
copy_constr = '\n public %s(%s toCopy, bool copyAll) // copy constructor \n {\n if (copyAll)\n {\n '
copy_constrArray = '\n for (int i = 0; i < %s; i++)\n { _%s[i] = toCopy._%s[i]; }\n '
copy_constrList = '\n for (int i = 0; i < toCopy.%s.Count; i++)\n { %s.Add(toCopy.%s[i]); }\n '
copy_constr_compo = '\n public %s(%s toCopy): this() // copy constructor \n {\n'
functions = {'datetime': {'datetime': ' new DateTime'}, 'io': {'print': <function translatePrint>, 'read': 'Console.ReadLine', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'Math.Acos', 'asin': 'Math.Asin', 'atan': 'Math.Atan', 'ceil': '(int) Math.Ceiling', 'cos': 'Math.Cos', 'exp': 'Math.Exp', 'ln': 'Math.Log', 'log': 'Math.Log', 'pow': 'Math.Pow', 'round': 'Math.Round', 'sin': 'Math.Sin', 'sqrt': 'Math.Sqrt', 'tan': 'Math.Tan'}, 'system': {'abs': 'Math.Abs', 'max': 'Math.Max', 'min': 'Math.Min', 'pow': <function translatePow>}}
methods = {'array': {'append': '.Add', 'len': <function translateLenArray>}, 'dict': {'get': <function translateget>, 'keys': <function translatekeyDict>, 'len': <function translateLenDict>, 'values': <function translatevalueDict>}, 'float': {'int': '(int)'}, 'int': {'float': '(double)'}, 'list': {'append': '.Add', 'contains?': '.Contains', 'index': '.IndexOf', 'insert_at': '.Insert', 'len': <function translateLenList>, 'map': <function CsharpRules.<lambda>>, 'not contains?': <function translateNotContains>, 'pop': '.RemoveAt', 'sum': <function translateSum>}, 'str': {'find': '.IndexOf', 'int': '(int)'}}
public_properties = '\n {\n get { return this._%s; }\n set { this._%s= value; } \n }'
public_properties_compo = '\n {\n get\n { return _%s.%s; }\n set\n { %s } \n }\n '
public_properties_wrap = '{ get { return %s.%s;}} \n '
types = {'DateTime': 'DateTime', 'array': '%s[] %s= new %s', 'bool': 'bool', 'datetime': 'DateTime', 'dict': 'Dictionary', 'float': 'double', 'int': 'int', 'list': 'List', 'str': 'string', 'tuple': 'Tuple'}
unary_op = {'+': '+', '-': '-', 'not': '!', '~': '~'}
pycropml.transpiler.rules.csharpRules.linq(name, z=True, swap=False)[source]
pycropml.transpiler.rules.csharpRules.translateLenArray(node)[source]
pycropml.transpiler.rules.csharpRules.translateLenDict(node)[source]
pycropml.transpiler.rules.csharpRules.translateLenList(node)[source]
pycropml.transpiler.rules.csharpRules.translateNotContains(node)[source]
pycropml.transpiler.rules.csharpRules.translatePow(node)[source]
pycropml.transpiler.rules.csharpRules.translatePrint(node)[source]
pycropml.transpiler.rules.csharpRules.translateSum(node)[source]
pycropml.transpiler.rules.csharpRules.translateget(node)[source]
pycropml.transpiler.rules.csharpRules.translatekeyDict(node)[source]
pycropml.transpiler.rules.csharpRules.translatevalueDict(node)[source]
pycropml.transpiler.rules.fortranRules module
class pycropml.transpiler.rules.fortranRules.FortranRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '.NE.', '*': '*', '**': '**', '+': '+', '-': '-', '/': '/', '<': '.LT.', '<=': '.LE.', '==': '.EQ.', '>': '.GT.', '>=': '.GE.', 'and': '.AND.', 'not': '.NOT..', 'or': '.OR.'}
functions = {'datetime': {'datetime': <function FortranRules.<lambda>>}, 'io': {'print': <function translatePrint>, 'read': 'Console.ReadLine', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'ACOS', 'asin': 'ASIN', 'atan': 'ATAN', 'ceil': <function translateCeil>, 'cos': 'COS', 'exp': 'EXP', 'ln': 'LOG', 'log': 'LOG', 'pow': <function translatePow>, 'sin': 'SIN', 'sqrt': 'SQRT', 'tan': 'TAN'}, 'system': {'abs': 'ABS', 'max': 'MAX', 'min': <function translateMIN>, 'modulo': 'modulo', 'pow': <function translatePow>, 'round': 'Round'}}
method()[source]
methods = {'array': {'append': <function FortranRules.<lambda>>, 'len': 'SIZE'}, 'dict': {'len': 'SIZE'}, 'float': {'int': 'INT'}, 'int': {'float': 'REAL'}, 'list': {'append': <function translateAppend>, 'contains?': <function translateContains>, 'index': <function translateIndex>, 'len': 'SIZE', 'not contains?': <function translateNotContains>, 'pop': <function translatePop>, 'sum': 'sum'}, 'str': {'find': <function translateFind>, 'int': 'INT'}}

dependencies = {

‘list’: {
‘index’: ‘list_sub’, ‘append’: ‘list_sub’

}

}

types = {'array': '%s, DIMENSION(%s)', 'bool': 'LOGICAL', 'datetime': 'CHARACTER(65)', 'float': 'REAL', 'int': 'INTEGER', 'list': '%s,DIMENSION (:), ALLOCATABLE::', 'str': 'CHARACTER(65)'}
unary_op = {'+': '+', '-': '-', 'not': '.NOT. ', '~': '~'}
pycropml.transpiler.rules.fortranRules.argsToStr(args)[source]
pycropml.transpiler.rules.fortranRules.translateAppend(node)[source]
pycropml.transpiler.rules.fortranRules.translateCeil(node)[source]
pycropml.transpiler.rules.fortranRules.translateContains(node)[source]
pycropml.transpiler.rules.fortranRules.translateFind(node)[source]
pycropml.transpiler.rules.fortranRules.translateIndex(node)[source]
pycropml.transpiler.rules.fortranRules.translateMIN(node)[source]
pycropml.transpiler.rules.fortranRules.translateNotContains(node)[source]
pycropml.transpiler.rules.fortranRules.translatePop(node)[source]
pycropml.transpiler.rules.fortranRules.translatePow(node)[source]
pycropml.transpiler.rules.fortranRules.translatePrint(node)[source]
pycropml.transpiler.rules.generalRule module
class pycropml.transpiler.rules.generalRule.GeneralRule[source]

Bases: object

” Abstract class of Rules

pycropml.transpiler.rules.javaRules module
class pycropml.transpiler.rules.javaRules.JavaRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': '&&', 'not': '!', 'or': '||'}
constant = {'math': {'pi': 'Math.PI'}}
constructor = '\n public %s() { }'
copy_constr = '\n public %s(%s toCopy, boolean copyAll) // copy constructor \n {\n if (copyAll)\n {'
copy_constrArray = '\n for (int i = 0; i < %s; i++)\n {\n _%s[i] = toCopy._%s[i];\n }'
copy_constrList = '\n for (%s c : toCopy.%s)\n {\n _%s.add(c);\n }\n this.%s = _%s;'
copy_constr_compo = '\n public %s(%s toCopy) // copy constructor \n {'
functions = {'datetime': {'datetime': <function translateDateTime>}, 'io': {'print': <function translatePrint>, 'read': 'readLine', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'Math.acos', 'asin': 'Math.asin', 'atan': 'Math.atan', 'ceil': '(int) Math.ceil', 'cos': 'Math.cos', 'exp': 'Math.exp', 'ln': 'Math.log', 'log': 'Math.log', 'pow': 'Math.pow', 'round': 'Math.round', 'sin': 'Math.sin', 'sqrt': 'Math.sqrt', 'tan': 'Math.tan'}, 'system': {'abs': 'Math.abs', 'max': 'Math.max', 'min': 'Math.min', 'pow': <function translatePow>}}
get_properties = '\n { return %s; }'
get_properties_compo = '\n { return _%s.get%s(); }'
methods = {'array': {'append': '.add', 'len': <function translateLenArray>}, 'dict': {'get': '.get', 'keys': <function translateDictkeys>, 'len': <function translateLenDict>, 'values': <function translateDictValues>}, 'float': {'float': '(double)', 'int': '(int)'}, 'int': {'float': '(double)'}, 'list': {'append': '.add', 'contains?': '.contains', 'index': '.indexOf', 'insert_at': '.insert', 'len': <function translateLenList>, 'not contains?': <function translateNotContains>, 'pop': '.remove', 'sum': <function translateSum>}, 'str': {'find': '.IndexOf', 'float': 'Double.', 'int': 'Integer.parseInt'}}
set_properties = '\n { this.%s= _%s; } \n '
set_properties_compo = '\n { %s } '
types = {'array': '%s[] %s= new %s', 'bool': 'boolean', 'datetime': 'Date', 'dict': 'HashMap', 'float': 'double', 'int': 'int', 'list': 'List', 'str': 'String', 'tuple': 'Pair'}
types2 = {'Date': 'Date', 'bool': 'Boolean', 'datetime': 'Date', 'float': 'Double', 'int': 'Integer', 'str': 'String'}
unary_op = {'+': '+', '-': '-', 'not': '!', '~': '~'}
pycropml.transpiler.rules.javaRules.argsToStr(args)[source]
pycropml.transpiler.rules.javaRules.translateDateTime(node)[source]
pycropml.transpiler.rules.javaRules.translateDictValues(node)[source]
pycropml.transpiler.rules.javaRules.translateDictkeys(node)[source]
pycropml.transpiler.rules.javaRules.translateLenArray(node)[source]
pycropml.transpiler.rules.javaRules.translateLenDict(node)[source]
pycropml.transpiler.rules.javaRules.translateLenList(node)[source]
pycropml.transpiler.rules.javaRules.translateNotContains(node)[source]
pycropml.transpiler.rules.javaRules.translatePow(node)[source]
pycropml.transpiler.rules.javaRules.translatePrint(node)[source]
pycropml.transpiler.rules.javaRules.translateSum(node)[source]
pycropml.transpiler.rules.pythonRules module
class pycropml.transpiler.rules.pythonRules.PythonRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '%': '%', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': 'and', 'not': 'not', 'or': 'or'}
functions = {'datetime': {'datetime': 'datetime'}, 'io': {'print': <function translatePrint>, 'read': 'read', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'acos', 'asin': 'asin', 'atan': 'atan', 'ceil': 'ceil', 'cos': 'cos', 'exp': 'exp', 'ln': 'log', 'log': 'log', 'round': 'round', 'sin': 'sin', 'sqrt': 'sqrt', 'tan': 'tan'}, 'system': {'abs': 'abs', 'max': 'max', 'min': 'min', 'modulo': <function translateModulo>, 'pow': 'pow'}}
methods = {'array': {'append': '.append', 'len': 'len'}, 'datetime': {'datetime': 'datetime', 'day': 'day'}, 'dict': {'get': '.get', 'keys': <function translateDictkeys>, 'len': 'len'}, 'float': {'int': 'int'}, 'int': {'float': 'float'}, 'list': {'append': '.append', 'contains?': <function PythonRules.<lambda>>, 'index': '.index', 'len': 'len', 'not contains?': <function translateNotContains>, 'pop': '.pop', 'sum': 'sum'}, 'str': {'find': '.index', 'int': 'int'}}
types = {'bool': 'bool', 'datetime': 'datetime', 'dict': 'dict', 'float': 'float', 'int': 'int', 'list': 'list', 'str': 'str', 'tuple': 'tuple'}
unary_op = {'+': '+', '-': '-', 'not': 'not ', '~': '~'}
pycropml.transpiler.rules.pythonRules.translateDictkeys(node)[source]
pycropml.transpiler.rules.pythonRules.translateModulo(node)[source]
pycropml.transpiler.rules.pythonRules.translateNotContains(node)[source]
pycropml.transpiler.rules.pythonRules.translatePrint(node)[source]
pycropml.transpiler.rules.rRules module
class pycropml.transpiler.rules.rRules.RRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '%': '%%', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': '&&', 'not': '!', 'or': '||'}
functions = {'datetime': {'datetime': <function RRules.<lambda>>}, 'io': {'print': <function translatePrint>, 'read': 'read', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'acos', 'asin': 'asin', 'atan': 'atan', 'ceil': 'ceiling', 'cos': 'cos', 'exp': 'exp', 'ln': 'log', 'log': 'log', 'round': 'round', 'sin': 'sin', 'sqrt': 'sqrt', 'tan': 'tan'}, 'system': {'abs': 'abs', 'max': 'max', 'min': 'min', 'modulo': <function translateModulo>, 'pow': 'pow'}}
methods = {'array': {'append': '.append', 'len': 'len'}, 'datetime': {'datetime': <function RRules.<lambda>>, 'day': 'day'}, 'dict': {'get': '.get', 'keys': <function translateDictkeys>, 'len': 'len'}, 'float': {'int': 'as.integer'}, 'int': {'float': 'as.double'}, 'list': {'append': <function RRules.<lambda>>, 'contains?': <function RRules.<lambda>>, 'index': <function RRules.<lambda>>, 'len': 'length', 'not contains?': <function translateNotContains>, 'pop': '.pop', 'sum': 'sum'}, 'str': {'find': '.index', 'int': 'as.character'}}
types = {'bool': 'bool', 'datetime': 'str', 'float': 'float', 'int': 'int', 'list': 'vector', 'str': 'str'}
unary_op = {'+': '+', '-': '-', 'not': 'not ', '~': '~'}
pycropml.transpiler.rules.rRules.argsToStr(args)[source]
pycropml.transpiler.rules.rRules.translateDictkeys(node)[source]
pycropml.transpiler.rules.rRules.translateModulo(node)[source]
pycropml.transpiler.rules.rRules.translateNotContains(node)[source]
pycropml.transpiler.rules.rRules.translatePrint(node)[source]
pycropml.transpiler.rules.sqRules module
class pycropml.transpiler.rules.sqRules.SqRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

field_decl(node)[source]
header = '------------------------------------------------------------------------------\n<auto-generated>\n// Ce code a été généré par un outil Cyml Translator.\n// Version du runtime :4.0.30319.42000\n//\n// Les modifications apportées à ce fichier peuvent provoquer un comportement incorrect et seront perdues si\n// le code est régénéré.\n// </auto-generated>\n//------------------------------------------------------------------------------\n\n/// \n/// This class was created from file %s\n/// The tool used was: DCC - Domain Class Coder, http://components.biomamodelling.org/, DCC\n/// \n/// Author: %s\n/// mail\n/// Institution: %s\n/// \n/// \n/// Hour: %s\n/// \n/// \n'
method()[source]
methods = {'dict': {'len': 'SIZE'}, 'float': {'int': 'INT'}, 'int': {'float': 'REAL'}, 'list': {'append': <function SqRules.<lambda>>, 'len': 'SIZE', 'sum': 'sum'}, 'str': {'find': <function SqRules.<lambda>>, 'int': 'INT'}}
namespace = {'headNamespace': '\nnamespace SiriusQualityEnergyBalance\n{\n using System;\n using System.Collections.Generic;\n using System.Reflection;\n using CRA.ModelLayer.Core;\n using CRA.ModelLayer.ParametersManagement;\n \n \n /// <summary>%sState Domain class contains the accessors to values</summary>\n [Serializable()]\n public class %sState : ICloneable, IDomainClass\n {\n\n '}
Module contents
Submodules
pycropml.transpiler.Parser module
class pycropml.transpiler.Parser.opt(**kwds)[source]

Bases: object

pycropml.transpiler.Parser.parser(module)[source]

Read, parse a Cython code and generate an abstract syntaxique tree.

Context: Compilation context: contains every pxd ever loaded, path information and the data related to the compilation. Class where it is implemented Cython parse method.

options: To set Compilation Options as
language_level: The source language level to use, formal_grammar: to define if it will be used to Parse the file evaluate_tree_assertions: To evaluate parse tree show_version : To display version number use_listing_file: Generate a .lis file errors_to_stderr: Echo errors to stderr when using .lis include_path: Directories to search for include files output_file: Name of generated .c file generate_pxi: Generate .pxi file for public declarations capi_reexport_cincludes: Add cincluded headers to any auto-generated header files. timestamps: Only compile changed source files verbose : Always print source names being compiled compiler_directives: Overrides for pragma options (see Options.py) embedded_metadata: Metadata to embed in the C file as json. evaluate_tree_assertions: Test support: evaluate parse tree assertions cplus : Compile as c++ code

Here default options were used except language level

Scanning.FileSourceDescriptor: Represents a code source. Only file sources for Cython code supported

pycropml.transpiler.api_transform module
class pycropml.transpiler.api_transform.Standard[source]

Bases: object

Standard classes should respond to expand and to return valid nodes on expand

class pycropml.transpiler.api_transform.StandardCall(namespace, function, expander=None)[source]

Bases: pycropml.transpiler.api_transform.Standard

converts to a standard call of the given namespace and function

expand(args)[source]
class pycropml.transpiler.api_transform.StandardCallAttrib(namespace, function, expander=None)[source]

Bases: pycropml.transpiler.api_transform.Standard

converts to a standard call of the given namespace and function

expand(args=[])[source]
class pycropml.transpiler.api_transform.StandardMethodCall(type, message, default=None, expander=None)[source]

Bases: pycropml.transpiler.api_transform.Standard

converts to a method call of the same class

expand(args)[source]
class pycropml.transpiler.api_transform.StandardSwapper(type, message)[source]

Bases: pycropml.transpiler.api_transform.Standard

expand(args)[source]
pycropml.transpiler.api_transform.abs_expander(type, message, args)[source]
pycropml.transpiler.api_transform.array_expander(type, message, args)[source]
pycropml.transpiler.api_transform.datetime_expander(type, message, args)[source]
pycropml.transpiler.api_transform.float_expander(type, message, args)[source]
pycropml.transpiler.api_transform.int_expander(type, message, args)[source]
pycropml.transpiler.api_transform.len_expander(type, message, args)[source]
pycropml.transpiler.api_transform.max_expander(type, message, args)[source]
pycropml.transpiler.api_transform.min_expander(type, message, args)[source]
pycropml.transpiler.api_transform.modulo_expander(type, message, args)[source]
pycropml.transpiler.api_transform.pow_expander(type, message, args)[source]
pycropml.transpiler.ast_transform module
class pycropml.transpiler.ast_transform.AstTransformer(tree, code, model=None)[source]

Bases: object

accessReturn(node)[source]
assert_translatable(node, **pairs)[source]
checktype(base)[source]
newtype(name)[source]
notdeclared(name, line)[source]
retrieve_library(func)[source]
transformer()[source]
translate_comprehensionnode(rhs, lhs, location)[source]
visit_addnode(node, operand1, operand2, location)[source]
visit_attributenode(node, obj, location)[source]
visit_binopnode(node, operand1, operand2, location)[source]
visit_boolbinopnode(node, operand1, operand2, location)[source]
visit_boolnode(node, location)[source]
visit_breakstatnode(node, location)[source]
visit_cargdeclnode(node, base_type, declarator, default, annotation, location)[source]
visit_comprehensionappendnode(node, expr, location)[source]
visit_comprehensionnode(node, loop, location)[source]
visit_condexprnode(node, test, true_val, false_val, location)[source]
visit_continuestatnode(node, location)[source]
visit_csimplebasetypenode(node, location)[source]
visit_cstructoruniondefnode(node, attributes, location)[source]
visit_cvardefnode(node, base_type, declarators, location)[source]
visit_definitions()[source]
visit_defnode(node, args, star_arg, starstar_arg, decorators, body, return_type_annotation, location)[source]
visit_dictnode(node, key_value_pairs, location)[source]
visit_divnode(node, operand1, operand2, location)[source]
visit_elements(elements, kind, homogeneous=True)[source]
visit_exprstatnode(node, expr, location)[source]
visit_floatnode(node, location)[source]

if float(node.value) < 0.0: return { ‘type’: ‘unary_op’,

‘operator’: ‘-‘, ‘value’: str(-float(node.value)), ‘pseudo_type’: “float” }
visit_forinstatnode(node, target, iterator, item, body, else_clause, location)[source]
visit_ifclausenode(node, body, condition, location)[source]
visit_ifstatnode(node, if_clauses, else_clause, location)[source]
visit_indexnode(node, base, index, location)[source]
visit_inplaceassignmentnode(node, lhs, rhs, location)[source]
visit_intnode(node, location)[source]
visit_listnode(node, args, mult_factor, location)[source]
visit_modnode(node, operand1, operand2, location)[source]
visit_mulnode(node, operand1, operand2, location)[source]
visit_namenode(node, location)[source]
visit_node(node)[source]
visit_notnode(node, operand, location)[source]
visit_pownode(node, operand1, operand2, location)[source]
visit_primarycmpnode(node, operand1, operand2, coerced_operand2, cascade, location)[source]
visit_printstatnode(node, arg_tuple, stream, location)[source]
visit_pyclassdefnode(node, location)[source]
visit_returnstatnode(node, value, location)[source]
visit_simplecallnode(node, function, coerced_self, args, arg_tuple, location)[source]
visit_singleassignmentnode(node, lhs, rhs, location)[source]
visit_sliceindexnode(node, start, stop, base, slice, location)[source]
visit_statlistnode(node, stats, location)[source]
visit_stringnode(node, location)[source]
visit_subnode(node, operand1, operand2, location)[source]
visit_top_level(nodes)[source]
visit_tuplenode(node, args, mult_factor, location)[source]
visit_unaryminusnode(node, operand, location)[source]
visit_unaryplusnode(node, operand, location)[source]
visit_unicodenode(node, location)[source]
visit_whilestatnode(node, condition, body, else_clause, location)[source]
pycropml.transpiler.ast_transform.transform_to_syntax_tree(tree)[source]

Generate a Node class from the tree in dict format

pycropml.transpiler.builtin_typed_api module
pycropml.transpiler.builtin_typed_api.add(l, r)[source]
pycropml.transpiler.builtin_typed_api.and_(l, r)[source]
pycropml.transpiler.builtin_typed_api.arg_check(expected_type, args, a)[source]
pycropml.transpiler.builtin_typed_api.binary_and(l, r)[source]
pycropml.transpiler.builtin_typed_api.binary_or(l, r)[source]
pycropml.transpiler.builtin_typed_api.builtin_type_check(namespace, function, receiver, args)[source]
pycropml.transpiler.builtin_typed_api.div(l, r, lo)[source]
pycropml.transpiler.builtin_typed_api.mod(l, r)[source]
pycropml.transpiler.builtin_typed_api.mul(l, r)[source]
pycropml.transpiler.builtin_typed_api.or_(l, r)[source]
pycropml.transpiler.builtin_typed_api.pow_(l, r)[source]
pycropml.transpiler.builtin_typed_api.simplify(kind, generics)[source]
pycropml.transpiler.builtin_typed_api.sub(l, r)[source]
pycropml.transpiler.checkingModel module
class pycropml.transpiler.checkingModel.Checking[source]

Bases: object

Module used to check units validity in model equation based on model xml files. This checking can also use for python code with metadata

pycropml.transpiler.codeGenerator module
class pycropml.transpiler.codeGenerator.CodeGenerator(add_line_information=False)[source]

Bases: pycropml.transpiler.nodeVisitor.NodeVisitor

binop_precedence = {'!=': 4, '%': 10, '&': 7, '*': 10, '**': 12, '+': 9, '-': 9, '/': 10, '//': 10, '<': 4, '<<': 8, '<=': 4, '==': 4, '>': 4, '>=': 4, '>>': 8, '@': 10, '^': 6, 'and': 2, 'in': 4, 'is': 4, 'is_not': 4, 'not_in': 4, 'or': 1, '|': 5}
body(statements)[source]
body_or_else(node)[source]
comma_separated_list(items)[source]
emit_sequence(node, parens=('', ''))[source]
emit_string(node, prefix='')[source]
newline(node=None, extra=0)[source]
operator_enter(new_prec)[source]
operator_exit()[source]
safe_double(node)[source]
unop_precedence = {'!': 3, '+': 11, '-': 11, 'not': 3, '~': 11}
visit_ExprStatNode(node)[source]
visit_array(node)[source]
visit_call(node)[source]
visit_custom_call(node)[source]
visit_for_sequence(node)[source]
visit_int(node)[source]
visit_local(node)[source]
visit_simpleCall(node)[source]
write(x)[source]
pycropml.transpiler.env module
class pycropml.transpiler.env.Env(values=None, parent=None)[source]

Bases: object

child_env(values=None)[source]
pycropml.transpiler.errors module
exception pycropml.transpiler.errors.PseudoCythonNotTranslatableError(message, suggestions=None, right=None, wrong=None)[source]

Bases: pycropml.transpiler.errors.PseudoError

exception pycropml.transpiler.errors.PseudoCythonTypeCheckError(message, suggestions=None, right=None, wrong=None)[source]

Bases: pycropml.transpiler.errors.PseudoError

exception pycropml.transpiler.errors.PseudoError(message, suggestions=None, right=None, wrong=None)[source]

Bases: Exception

pycropml.transpiler.errors.beautiful_error(exception)[source]
pycropml.transpiler.errors.cant_infer_error(name, line)[source]
pycropml.transpiler.errors.tab_aware(location, code)[source]

if tabs in beginning of code, add tabs for them, otherwise spaces

pycropml.transpiler.errors.translation_error(data, location=None, code=None, wrong_type=None, **options)[source]
pycropml.transpiler.errors.type_check_error(data, location=None, code=None, wrong_type=None, **options)[source]
pycropml.transpiler.helpers module
pycropml.transpiler.helpers.prepare_table(types, original_methods=None)[source]
pycropml.transpiler.helpers.safe_serialize_type(l)[source]

serialize only with letters, numbers and _

pycropml.transpiler.helpers.serialize_type(l)[source]
pycropml.transpiler.interface module
class pycropml.transpiler.interface.TreeInterface(tree)[source]

Bases: object

visits recursively nodes of the tree with defined transform_<node_type> methods and transforms in place

transform(tree, in_block=False)[source]
transform_block(tree)[source]
transform_default(tree)[source]
class pycropml.transpiler.interface.middleware(tree)[source]

Bases: pycropml.transpiler.interface.TreeInterface

api_translate()[source]
pycropml.transpiler.main module
pycropml.transpiler.nodeVisitor module
class pycropml.transpiler.nodeVisitor.NodeVisitor[source]

Bases: object

Define a method which browse the graph and call a methode constructed from the type of each node of the graph

visit(node)[source]
pycropml.transpiler.pseudo_tree module
class pycropml.transpiler.pseudo_tree.Node(type, **fields)[source]

Bases: object

The new Node generated with specific properties. These properties are automatically set”

Example: Node(type=’local’, name=’l’, pseudo_type=”int”) to represent a int variable declaration

y
pycropml.transpiler.version module

Maintain version for this package. Do not edit this file, use ‘version’ section of config.

pycropml.transpiler.version.MAJOR = 0

(int) Version major component.

pycropml.transpiler.version.MINOR = 0

(int) Version minor component.

pycropml.transpiler.version.POST = 2

(int) Version post or bugfix component.

Module contents
Submodules
pycropml.algorithm module
class pycropml.algorithm.Algorithm(language, development, platform, filename=None)[source]

Bases: object

pycropml.checking module
class pycropml.checking.Test(name)[source]

Bases: pycropml.checking.Testset

class pycropml.checking.Testset(name, parameterset, description, uri=None)[source]

Bases: object

Test

pycropml.checking.testset(model, name, kwds)[source]
pycropml.code2nbk module
pycropml.composition module

Read xml representation of a model composite

class pycropml.composition.Description[source]

Bases: object

Model Composition Description.

A description is defined by:
  • Title
  • Authors
  • Institution
  • Reference
  • Abstract
class pycropml.composition.ModelComposition(kwds)[source]

Bases: pycropml.composition.ModelDefinition

Formal description of a Model Composite.

add_description(description)[source]

TODO

class pycropml.composition.ModelDefinition(kwds)[source]

Bases: object

Model name, id, version and step

class pycropml.composition.ModelParser[source]

Bases: pycropml.composition.Parser

Read an XML file and transform it in our object model.

Composition(elts)[source]
Description(Title, Author, Institution, Reference, Abstract)[source]
Initialization(elt)[source]

Retrieve different types of links

Model(elt)[source]

Models

ModelComposition(elts)[source]

ModelComposition (Description, Models, Inputlink,Outputlink,externallink)

dispatch(elt)[source]
parse(fn)[source]
class pycropml.composition.Models(name, modelid, file, package_name=None)[source]

Bases: pycropml.composition.ModelComposition, pycropml.modelunit.ModelUnit

class pycropml.composition.Parser[source]

Bases: object

Read an XML file and transform it in our object model.

dispatch(elt)[source]
parse(fn)[source]
pycropml.composition.model_parser(fn)[source]

Parse a composite model and return the model.

Returns ModelComposite object of the CropML Model.

pycropml.composition.retrieve_path(fn)[source]
pycropml.cyml module
pycropml.description module
class pycropml.description.Description[source]

Bases: object

Model Unit Description.

A description is defined by:
  • Title
  • Author
  • Institution
  • Reference
  • Abstract
pycropml.error module

Created on Wed Apr 10 17:01:34 2019

@author: midingoy

exception pycropml.error.Error(message)[source]

Bases: Exception

pycropml.formater_f90 module
pycropml.formater_f90.formater(code)[source]
pycropml.formater_f90.formaterNext(line)[source]
pycropml.function module
class pycropml.function.Function(name, language, filename, type, description)[source]

Bases: object

pycropml.initialization module
class pycropml.initialization.Initialization(name, language, filename)[source]

Bases: object

Function

pycropml.inout module
class pycropml.inout.Input(kwds)[source]

Bases: pycropml.inout.InputOutput

class pycropml.inout.InputOutput(kwds)[source]

Bases: object

class pycropml.inout.Output(kwds)[source]

Bases: pycropml.inout.InputOutput

pycropml.main module
pycropml.model module
pycropml.modelunit module

Model Description and Model Unit.

class pycropml.modelunit.ModelDefinition(kwds)[source]

Bases: object

class pycropml.modelunit.ModelUnit(kwds)[source]

Bases: pycropml.modelunit.ModelDefinition

Formal description of a Model Unit.

add_description(description)[source]

TODO

pycropml.package module

from pycropml import composition from pycropml.pparse import model_parser from path import Path import networkx as nx from collections import defaultdict from IPython.display import Image, display from networkx.drawing.nx_pydot import to_pydot from pycropml.render_cyml import signature

class pycropml.package.AbstractPackageReader(filename)[source]

Bases: object

Abstract class to add a package in the package manager.

register_packages(pkgmanager)[source]

Create and add a package in the package manager.

class pycropml.package.Package(name, metainfo, path=None)[source]

Bases: pycropml.package.PackageDict

A Package is a dictionnary of node factory. Each node factory is able to generate node and their widgets. Meta informations are associated with a package.

add_modelunit(modelunit)[source]

Add to the package a factory ( node or subgraph )

get_crop2ml_path()[source]

Return the full path of the wralea.py (if set)

get_id()[source]

Return the package id

get_metainfo(key)[source]

Return a meta information. See the standard key in the __init__ function documentation. :param key: todo

get_modelunit(modelid)[source]

Return the factory associated with id

get_names()[source]

Return all the factory names in a list

get_pkg_files()[source]

Return the list of xml filename of the package. The filename are relative to self.path

get_tip()[source]

Return the package description

is_directory()[source]

New style package. A package is embeded in a unique directory. This directory can not contain more than one package. Thus, you can move, copy or delete a package by acting on the directory without ambiguity. Return True if the package is embeded in a directory.

is_editable()[source]

A convention (for the GUI) to ensure that the user can modify the package.

mimetype = 'pycrop2ml/package'
reload()[source]

Reload all xml file of the package

remove_files()[source]

Remove pkg files

update_modelunit(old_name, modelunit)[source]

Update factory (change its name)

class pycropml.package.PackageDict(*args)[source]

Bases: dict

Dictionnary with case insensitive key This object is able to handle protected entry begining with an ‘#’

get(key, default=None)[source]

Return the value for key if key is in the dictionary, else default.

has_key(key)[source]
iter_public_values()[source]

Iterate througth dictionnary value (remove protected value)

nb_public_values()[source]

Return the number of unprotected values

class pycropml.package.PackageManager[source]

Bases: object

add_crop2ml_path(path, container)[source]

Add a search path for wralea files

Parameters:
  • path – a path string
  • container – set containing the path
add_package(package)[source]

Add a package to the pkg manager

clear()[source]

Remove all packages

create_readers(crop2ml_files)[source]
find_and_register_packages(no_cache=False)[source]

Find all composite model on the system and register them If no_cache is True, ignore cache file

find_crop2ml_dir(directory, recursive=True)[source]

Find in a directory wralea files, Search recursivly is recursive is True

:return : a list of pkgreader instances

get(*args)[source]
get_pkgreader(filename)[source]

Return the pkg reader corresponding to the filename

has_key(*args)[source]
init(dirname=None, verbose=True)[source]

Initialize package manager

If dirname is None, find composition files on the system else load directory

items()[source]
iteritems()[source]
iterkeys()[source]
itervalues()[source]
keys()[source]
load_directory(dirname)[source]

Load a directory containing wraleas

rebuild_category()[source]

Rebuild all the category

reload(pkg=None)[source]

Reload one or all packages. If the package pkg is None reloa all the packages. Else reload only pkg.

set_sys_crop2ml_path()[source]

Define the default composition files search path

For that, we look for “composition” entry points and deprecated_wralea entry point if a package is declared as deprecated_wralea, the module is not load

update_category(package)[source]

Update the category dictionary with package contents

values()[source]
class pycropml.package.PseudoGroup(name)[source]

Bases: pycropml.package.PackageDict

Data structure used to separate dotted naming (packages, category)

add_name(name, value)[source]

Add a value in the structure with the key name_tuple

get_id()[source]

todo

get_tip()[source]

todo

mimetype = 'pycrop2ml/package'
new(name)[source]

todo

sep = '.'
class pycropml.package.PyPackageReader(filename)[source]

Bases: pycropml.package.AbstractPackageReader

Build packages from wralea file Use ‘register_package’ function

build_package(wraleamodule, pkgmanager)[source]

Build package and update pkgmanager

filename_to_module(filename)[source]

Transform the filename ending with .py to the module name

get_pkg_name()[source]

Return the OpenAlea (uniq) full package name

register_packages(pkgmanager)[source]

Execute model.py

class pycropml.package.PyPackageReaderModel(filename)[source]

Bases: pycropml.package.PyPackageReader

Build a package from a __wralea__.py Use module variable

build_package(wraleamodule, pkgmanager)[source]

Build package and update pkgmanager

check_exist()[source]
contain_pkg(pkg)[source]
get_path(pkg, name)[source]
class pycropml.package.PyPackageWriter(package)[source]

Bases: object

Write a wralea python file

get_str()[source]

Return string to write

pkg_template = '\n$PKGNAME\n$METAINFO\n'
wralea_template = '\n# This file has been generated at $TIME\n$PKG_DECLARATION\n'
write_wralea(full_filename)[source]

Write the wralea.py in the specified filename

exception pycropml.package.UnknownNodeError(name)[source]

Bases: Exception

class pycropml.package.UserPackage(name, metainfo, path=None)[source]

Bases: pycropml.package.Package

Package user editable and persistent

pycropml.package.get_default_home_dir()[source]

Return the home directory (valid on linux and windows)

pycropml.package.get_openalea_home_dir(name='.pycrop2ml')[source]

Return the crop2ml home directory If it doesn’t exist, create it

pycropml.package.get_userpkg_dir(name='user_pkg')[source]

Get user package directory (the place where are the wralea.py files). If it doesn’t exist, create it

pycropml.package.is_protected(item)[source]

Return true the item is protected

pycropml.package.lower(item)[source]
pycropml.package.protected(item)[source]

Return corresponding protected name for item

pycropml.parameterset module
class pycropml.parameterset.Parameterset(name, description, uri=None)[source]

Bases: object

Parameter set

pycropml.parameterset.parameterset(model, name, kwds)[source]
pycropml.pparse module

License, Header

class pycropml.pparse.ModelParser[source]

Bases: pycropml.pparse.Parser

Read an XML file and transform it in our object model.

Algorithm(elt)[source]
Description(Title, Author, Institution, Reference, Abstract)[source]
Function(elt)[source]
Initialization(elt)[source]
Input(elts)[source]
Inputs(Input)[source]
ModelUnit(elts)[source]

ModelUnit (Description,Inputs,Outputs,Algorithm,Parametersets, Testsets)

Output(elts)[source]
Outputs(elts)[source]

Ouputs (Output)

Parameterset(elts)[source]
Parametersets(Parameterset)[source]
Testset(Test)[source]
Testsets(Testset)[source]
dispatch(elt)[source]
param(pset, elt)[source]

Param

parse(crop2ml_dir)[source]
class pycropml.pparse.Parser[source]

Bases: object

Read an XML file and transform it in our object model.

dispatch(elt)[source]
parse(crop2ml_dir)[source]
pycropml.pparse.model_parser(crop2ml_dir)[source]
Parse a set of models as xml files contained in crop2ml directory
and algorithm in src directory This function returns models as python object.

Returns ModelUnit object of the Crop2ML Model.

pycropml.render_R module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_R.Model2Package(models, dir=None, pkg_name=None)[source]

Bases: object

TODO

generate_func_test(model_unit)[source]
generate_function_doc(model_unit)[source]
generate_test(model_unit)[source]
num = 0
run()[source]

TODO.

write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_R.comment(line)[source]
pycropml.render_R.generate_doc(model)[source]
pycropml.render_R.signature(model)[source]
pycropml.render_R.transf(type_v, elem)[source]
pycropml.render_cpp module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_cpp.Model2Package(models, dir=None)[source]

Bases: object

TODO

DATATYPE = {'BOOLEAN': 'bool', 'DATE': 'string', 'DATELIST': 'vector<string>', 'DOUBLE': 'double', 'DOUBLELIST': 'vector<double>', 'INT': 'int', 'INTLIST': 'vector<int>', 'STRING': 'string', 'STRINGLIST': 'vector<string>'}
generate_test(model_unit)[source]
num = 0
write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_cpp.signature(model)[source]
pycropml.render_cpp.transf(type_v, elem)[source]
pycropml.render_cpp.transfDate(type, elem)[source]
pycropml.render_cpp.transfDateList(type, elem)[source]
pycropml.render_cpp.transfDouble(type_v, elem)[source]
pycropml.render_cpp.transfList(type_v, elem)[source]
pycropml.render_cpp.transfString(type_v, elem)[source]
pycropml.render_csharp module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_csharp.Model2Package(models, dir=None)[source]

Bases: object

TODO

DATATYPE = {'BOOLEAN': 'bool', 'DATE': 'string', 'DATELIST': 'List<string>', 'DOUBLE': 'double', 'DOUBLELIST': 'List<double>', 'INT': 'int', 'INTLIST': 'List<int>', 'STRING': 'string', 'STRINGLIST': 'List<string>'}
generate_test(model_unit)[source]
num = 0
write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_csharp.signature(model)[source]
pycropml.render_csharp.transf(type_v, elem)[source]
pycropml.render_csharp.transfDate(type, elem)[source]
pycropml.render_csharp.transfDateList(type, elem)[source]
pycropml.render_csharp.transfDouble(type_v, elem)[source]
pycropml.render_csharp.transfList(type_v, elem)[source]
pycropml.render_csharp.transfString(type_v, elem)[source]
pycropml.render_cyml module

Add License, Header. Use pkglts Problems: - name of a model unit?

class pycropml.render_cyml.Model2Package(models, dir=None, pkg_name=None)[source]

Bases: object

TODO

generate_algorithm(model_unit)[source]
generate_component(model_unit)[source]

Todo

generate_func_test(model_unit)[source]
generate_function_doc(model_unit)[source]
generate_function_signature(func_name, inputs)[source]
generate_package()[source]

Generate a Cyml package equivalent to the xml definition. Args: - models : a list of model - dir: the directory where the code is generated. Returns: - None or status

generate_test(model_unit)[source]
initialization(model_unit)[source]
num = 0
run()[source]

TODO.

write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_cyml.generate_doc(model)[source]
pycropml.render_cyml.my_input(_input, defa=True)[source]
pycropml.render_cyml.signature(model)[source]
pycropml.render_cyml.transBool(type, elem)[source]
pycropml.render_cyml.transf(type_, elem)[source]
pycropml.render_cyml.transfDate(type, elem)[source]
pycropml.render_cyml.transfDateList(type, elem)[source]
pycropml.render_fortran module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_fortran.Model2Package(models, directory=None, pkg_name=None)[source]

Bases: object

TODO

DATATYPE = {'BOOLEAN': 'LOGICAL', 'DATE': 'CHARACTER(65)', 'DATELIST': 'CHARACTER(65), ALLOCATABLE, DIMENSION(:)', 'DOUBLE': 'REAL', 'DOUBLEARRAY': 'REAL, ALLOCATABLE, DIMENSION', 'DOUBLELIST': 'REAL, ALLOCATABLE, DIMENSION(:)', 'FLOAT': 'REAL', 'INT': 'INTEGER', 'INTARRAY': 'INTEGER, ALLOCATABLE, DIMENSION', 'INTLIST': 'INTEGER, ALLOCATABLE, DIMENSION(:)', 'STRING': 'CHARACTER(65)', 'STRINGARRAY': 'CHARACTER(65), ALLOCATABLE, DIMENSION', 'STRINGLIST': 'CHARACTER(65), ALLOCATABLE, DIMENSION(:)'}
generate_test(model_unit)[source]
my_input(_input)[source]
num = 0
write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_fortran.generate_doc(model)[source]
pycropml.render_fortran.signature(model)[source]
pycropml.render_java module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_java.Model2Package(models, dir=None)[source]

Bases: object

DATATYPE = {'BOOLEAN': 'boolean', 'DATE': 'String', 'DATELIST': 'Arrays.asList', 'DOUBLE': 'double', 'DOUBLELIST': 'Arrays.asList', 'INT': 'int', 'INTLIST': 'Arrays.asList', 'STRING': 'String', 'STRINGLIST': 'Arrays.asList'}
generate_test(model_unit)[source]
num = 0
write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_java.formatDate(elem)[source]
pycropml.render_java.formatDateList(elem)[source]
pycropml.render_java.signature(model)[source]
pycropml.render_java.transf(type_v, elem)[source]
pycropml.render_java.transfDate(categ, name, elem)[source]
pycropml.render_java.transfDateList(categ, name, elem)[source]
pycropml.render_java.transfDouble(type_v, elem)[source]
pycropml.render_java.transfList(type_v, elem)[source]
pycropml.render_java.transfString(type_v, elem)[source]
pycropml.render_notebook module

License, Header

Use pkglts

Problems: - name of a model unit?

class pycropml.render_notebook.Model2Nb(models, dir=None)[source]

Bases: pycropml.render_python.Model2Package

Generate a Jupyter Notebook from a set of models.

generate_notebook()[source]

Generate a Python package equivalent to the xml definition.

Args: - models : a list of model - dir: the directory where the code is generated.

Returns: - None or status

generate_test(model_unit)[source]
run()[source]

TODO.

pycropml.render_notebook_csharp module

License, Header

Use pkglts

Problems: - name of a model unit?

class pycropml.render_notebook_csharp.Model2Nb(models, dir=None)[source]

Bases: pycropml.render_csharp.Model2Package

Generate a Jupyter Notebook from a set of models in Csharp.

generate_notebook()[source]

Generate a csharp package equivalent to the xml definition.

Args: - models : a list of model - dir: the directory where the code is generated.

Returns: - None or status

generate_test(model_unit)[source]
run()[source]

TODO.

pycropml.render_notebook_csharp.signature(model)[source]
pycropml.render_notebook_csharp.transf(type, elem)[source]
pycropml.render_notebook_csharp.transfDate(type, elem)[source]
pycropml.render_notebook_csharp.transfDateList(type, elem)[source]
pycropml.render_notebook_csharp.transfDouble(type, elem)[source]
pycropml.render_notebook_csharp.transfSDIList(type, elem)[source]
pycropml.render_notebook_csharp.transfString(type, elem)[source]
pycropml.render_notebook_java module

License, Header

Use pkglts

Problems: - name of a model unit?

class pycropml.render_notebook_java.Model2Nb(models, dir=None)[source]

Bases: pycropml.render_java.Model2Package

Generate a Jupyter Notebook from a set of models in Java.

generate_notebook()[source]

Generate a java package equivalent to the xml definition.

Args: - models : a list of model - dir: the directory where the code is generated.

Returns: - None or status

generate_test(model_unit)[source]
run()[source]

TODO.

pycropml.render_notebook_java.signature(model)[source]
pycropml.render_python module

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.render_python.Model2Package(models, dir=None, pkg_name=None)[source]

Bases: object

TODO

DATATYPE = {'BOOLEAN': <class 'bool'>, 'CHARLIST': <class 'list'>, 'DATE': <class 'str'>, 'DATELIST': <class 'list'>, 'DOUBLE': <class 'float'>, 'DOUBLEARRAY': <built-in function array>, 'DOUBLELIST': <class 'list'>, 'FLOAT': <class 'float'>, 'INT': <class 'int'>, 'INTLIST': <class 'list'>, 'STRING': <class 'str'>, 'STRINGLIST': <class 'list'>}
generate_algorithm(model_unit)[source]
generate_component(model_unit)[source]

Todo

generate_factory(model)[source]

Create a Node Factory from CropML model unit.

generate_func_test(model_unit)[source]
generate_function_doc(model_unit)[source]
generate_function_signature(model_unit)[source]
generate_package()[source]

Generate a Python package equivalent to the xml definition.

Args: - models : a list of model - dir: the directory where the code is generated.

Returns: - None or status

generate_test(model_unit)[source]
generate_wralea()[source]

Generate wralea factories from the meta-information of the the model units.

num = 0
run()[source]

TODO.

write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.render_python.generate_doc(model)[source]
pycropml.render_python.openalea_interface(inout)[source]
pycropml.render_python.signature(model)[source]
pycropml.test_generator module
pycropml.topology module
pycropml.version module

Maintain version for this package. Do not edit this file, use ‘version’ section of config.

pycropml.version.MAJOR = 1

(int) Version major component.

pycropml.version.MINOR = 1

(int) Version minor component.

pycropml.version.POST = 0

(int) Version post or bugfix component.

pycropml.wf2xml module
pycropml.writeTest module

Created on Mon Mar 18 15:46:31 2019

@author: midingoy

class pycropml.writeTest.WriteTest(models, language, dir)[source]

Bases: object

write()[source]

Populate and write the test files.

pycropml.writeTest_f90 module

Created on Thu Mar 28 15:39:28 2019

@author: midingoy

Add License, Header.

Use pkglts

Problems: - name of a model unit?

class pycropml.writeTest_f90.Model2Package(models, dir=None)[source]

Bases: object

TODO

DATATYPE = {'BOOLEAN': 'LOGICAL::', 'DATE': 'CHARACTER(65)', 'DATELIST': 'CHARACTER(65), DIMENSION(:), ALLOCATABLE ::', 'DOUBLE': 'REAL::', 'DOUBLELIST': 'REAL, DIMENSION(:), ALLOCATABLE ::', 'INT': 'INTEGER::', 'INTLIST': 'INTEGER, DIMENSION(:), ALLOCATABLE ::', 'STRING': 'CHARACTER(65)::', 'STRINGLIST': 'CHARACTER(65), DIMENSION(:), ALLOCATABLE ::'}
generate_algorithm(model_unit)[source]
generate_component(model_unit)[source]

Todo

generate_estimation(model_unit)[source]
generate_function_doc(model_unit)[source]
generate_package()[source]

Generate a csharp package equivalent to the xml definition.

Args: - models : a list of model - dir: the directory where the code is generated.

Returns: - None or status

generate_public_class(model_unit)[source]
generate_test(model_unit)[source]
num = 0
run()[source]

TODO.

write_tests()[source]

TODO: Manage several models rather than just one.

pycropml.writeTest_f90.signature(model)[source]
pycropml.writeTest_f90.transf(type, elem)[source]
pycropml.writeTest_f90.transfDate(type, elem)[source]
pycropml.writeTest_f90.transfDateList(type, elem)[source]
pycropml.writeTest_f90.transfDouble(type, elem)[source]
pycropml.writeTest_f90.transfSDIList(type, elem)[source]
pycropml.writeTest_f90.transfString(type, elem)[source]
pycropml.xml2wf module
class pycropml.xml2wf.XmlToWf(xmlwf, dir, pkg_name)[source]

Bases: object

compareInterface(interfaces)[source]
compoPack(name)[source]
compositeNodeInputs()[source]
compositeNodeOutputs()[source]
connectInputs()[source]
connectInternal()[source]
connectOutputs()[source]
createNodes()[source]
retrievePackage(name)[source]
run()[source]
Module contents

Usecases

Licence

PyCropML is released under a MIT License.

Usecases

Glossary

Terminology

Model
Simplified representation of the crop system within specific objectives.

Overview

Documentation

  • A PDF version of |core| documentation is available.

History

creation (2018-01-18)

  • First release on PyPI.

Indices and tables

History

creation (2018-01-18)

  • First release on PyPI.

License

|pycrop2ml| is released under a MIT License.

Welcome to PyCrop2ML’s documentation!

Contents:

Contributing Guide

This is a wiki for anything related to the contributing on [[Crop2ML|https://github.com/AgriculturalModelExchangeInitiative|Crop2ML]] which is a project of the Agricultural Model Exchange Initiative. For more information about this project, please visit CropML documentation [[Crop2ML|https://cropmlformat.readthedocs.io/en/latest/?badge=latest|documentation]]:


People

[[Stefan Behnel|http://scoder.behnel.de/|Stefan Behnel]], [[Robert Bradshaw|http://www.math.washington.edu/~robertwb/|Robert Bradshaw]], [[Dag Seljebotn|http://heim.ifi.uio.no/dagss/|Dag Seljebotn]], Lisandro Dalcin.

Mailing Lists

Our development mailing list is [[cython-dev|http://mail.python.org/mailman/listinfo/cython-devel|cython-dev]] and user mailing list at http://groups.google.com/group/cython-users.

In the past we also used a [[Google group|http://groups.google.com/group/cython|Google group]] and a list at [[BerliOS Developer|https://lists.berlios.de/mailman/listinfo/cython-dev|BerliOS Developer]]. You can still read [[the archives at Gmane|http://blog.gmane.org/gmane.comp.python.cython.devel|the archives at Gmane]].

Project Goals

  • Fully supported easy-to-use test suite, including the normal CPython test suite.
  • Easy installation and usage.
  • Rich, accessible documentation. Make sure the examples are plenty and can be automatically tested.
  • Make Cython part of the standard distribution of Python (like ctypes).
  • Compile all Python code except for possibly some obvious exclusions, which will be worked out by developers.
  • Very fast when the user explicitly declares types (but we’re not going to make promises with type inference). Precise benchmarks.
  • Mitigate or eliminate the need for users to invoke the Python/C API directly without sacrificing performance.

Documentation

  • See http://docs.cython.org/.
  • Official Pyrex [[Language Overview|http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/LanguageOverview.html|Language Overview]] (note the [[changes|http://hg.cython.org/cython|changes]] though).
  • [[Extension Types|http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/extension_types.html|Extension Types]]
  • [[Sharing Declarations Between Pyrex Modules|http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/Manual/sharing.html|Sharing Declarations Between Pyrex Modules]]
  • [[FAQ|http://www.cosc.canterbury.ac.nz/greg.ewing/python/Pyrex/version/Doc/FAQ.html|FAQ]]
  • [[Quick Guide to Pyrex|http://ldots.org/pyrex-guide/|Quick Guide to Pyrex]] from Michael JasonSmith.
  • CategoryCythonDoc lists pages that are related to Cython documentation.
  • [[ Pure Python mode|pure| Pure Python mode]]
  • SAGE Days 4 talk highlighting some of the [[differences between Pyrex and SageX|http://cython.org/talks/SageX.pdf|differences between Pyrex and SageX]] (the predecessor of Cython).

CategoryHomepage

Indices and tables

Supported by:

_images/openalea.png
_images/record.jpg
_images/bioma.png
images/siriusquality.png
images/simplace.png