Welcome to PyCrop2ML Documentation

Contents .. _pycropml:

CropML 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

CropML Description

In CropML, a model is either a model unit or a composition of models. A ModelUnit represents the atomic unit of a crop model define by the modelers. 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 CropML.
Formal definition of a Model Unit in CropML
The structure of a Model Unit in CropML MUST be conform to a specific Document Type Definition named ModelUnit.dtd .
So a Model Unit CropML 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
Element Description
ModelUnit
The root of an atomic model in CropML which make the difference from a composite model.
Description
some basic information related to the name of the model, its authors and others elements used to reference it.
Inputs
A list of inputs characterized by their names, initial states, the range of values and others. Its input variables are related to climate, soil and cropping system
Outputs
A list of outputs defining the processes involved, the variables whose dynamics we want to observe.
Algorithm
The description of the behaviour of the model made by the mathematical relationship between the inputs and the outputs with some control structure.
Parametersets
Some sets of parameters which are invariant and used for the simulation of the models.
Testsets
Set of model configuration used to compare estimated and desired outputs .
In the next, we define the major elements of a CropML model unit.
ModelUnit element
An atomic model in CropML is declared with <<ModelUnit>> element, the usual root of CropML ModelUnit document.
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE ModelUnit PUBLIC "-//SIMPLACE/DTD SOL 1.0//EN" "https://raw.githubusercontent.com/AgriculturalModelExchangeInitiative/xml_representation/master/ModelUnit.dtd">
<ModelUnit modelid=" " timestep=" " name=" " version="">
        ....
</ModelUnit>
This element MUST contain a Description, an Algorithm, Parametersets and Testsets elements and MAY optionally have Inputs and Outputs elements. The restriction of the length of different lists is not imposed.
ModelUnit element MUST have an modelid and name attributes which are used to reference an atomic model. It MUST also contain a timestep attribute to define the temporality of the model and a version attribute for each version of the model.
Description element

This element gives the general information on the model and is composed by a set of character elements. It MUST contain Title, Authors, Institution and abstract elements and MAY optionally contain URI and Reference elements.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
        <Description>
                <Title>title</Title>
                <Authors>authors</Authors>
                <Institution>institution</Institution>
                <URI>uri</URI>
                <Abstract><![CDATA[abstract]]></Abstract>
        </Description>
        ...
</ModelUnit>
Inputs elements

The inputs of Model are listed inside an XML element called Inputs within a dictionary structure composed by their attributes which declarations are optional(default, max, min, parametercategory, variablecategory and uri) or required(name, datatype, description, inputtype, unit ) and their corresponding value. Inputs element MUST contain one or more Input elements.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Inputs>
      <Input name=" " description=" " parametercategory=" " datatype=" " min=" " max=" " default=" " unit=" " uri="" inputtype=" "/>
      <Input name=" " description=" " parametercategory=" " datatype=" " min=" " max=" " default=" " unit=" " uri=" " inputtype=" "/>
      ...
   </Inputs>
   ...
</ModelUnit>
  • The required datatype attribute is the type of input value specified in default (the default value in the input), min (the minimum value in the input) and max (the maximum value in the input). It MAY be one type of the set of types used in the existing crop modeling platform.
  • The inputtype attribute makes it possible to distinguish the variables and the parameters of the model. So it MUST take one of two possible values: parameter and variable.
  • The parametercategory attribute defines the category of parameter which is specified by one of the following values: constant, species, soil and genotypic.
  • The variablecategory defines the category of variable depending on whether it is a state, a rate or an “auxiliary” variable. State variable characterize the behavior of the model and rate variable characterizes the changes in state variables.
Outputs element

The outputs of Model are listed inside an XML element called Outputs within a dictionary structure composed by their attributes which declarations are:

  • optional(variabletype and URI)
  • required(name, datatype, description, unit, max and min )
  • and their corresponding value

Outputs MUST contain zero or more output elements.

<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Outputs>
      <Output name=" " description=" " datatype=" " min=" " max=" "  unit=" " uri=" "/>
      <Output name=" " description=" " datatype=" " min=" " max=" "  unit=" " uri=" "/>
      ...
   </Outputs>
   ...
</ModelUnit>
The definition of different attributes is same as Input’s attributes.
Algorithm element
The Algorithm element defines the building block of CropML model unit and shows the computational method to determine the outputs from the inputs.
It consists of a set of mathematical equations (relation between inputs), loops and conditional instructions which are well structured in a specific language, the algorithm’s attribute.
<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Algorithm language =""><![CDATA[
      ...
      ]]>
   </Algorithm>
   ...
</ModelUnit>
Parametersets element
Parametersets element contains one or more Parameterset elements that define the different ways of setting the model. Each Parameterset element MUST have name and description attributes that respectively represents the name and the description of each setting.
The different parameterset MUST contain a list of Param elements that show in attribute the name of the parameter (an input which inputtype equals parameter) and the fixed value of this one.
<ModelUnit modelid=" " timestep=" " name=" " version =" ">
    ...
    <Parametersets>
       <Parameterset name="" description="" uri = ""/>
       <Parameterset name="" description="" >
          <Param name="">value</Param>
          <Param name="">value</Param>
          ...
       </Parameterset>
       ...
    ...
 </ModelUnit>
Testsets element
Testsets element contains one or more Testset elements that define the different run for evaluating the outputs of the model.
Each Testset element MUST have name, description and parameterset attributes that respectively represents the name, the description of each run and the name of the parameterset related to the Testset. This one allow to retrieve the name and the value of different parameters includes in this parameterset.
The different Testset MUST contain a list of InputValue and OutputValue elements corresponding respectively to the values of inputs used in the run and the values of Outputs that will be asserted.
<ModelUnit modelid=" " timestep=" " name=" " version =" ">
   ...
   <Testsets>
      <Testset name="" parameterset = "" description="" uri = ""/>
      <Testset name="" parameterset = "" description="" >
         <Test name="">
            <InputValue name="">value</InputValue>
            ...
            <OutputValue name="" precision ="">value</OutputValue>
            ...
         </Test>
         ...
      </Testset>
      ...
  </Testsets>
  ...
</ModelUnit>
Formal definition of a Composite Model in CropML
A Composite Model CropML 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 CropML 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:
user/images/modelcomposition.png
In the next, we define the major elements of a CropML model unit.
Inputs element

It MUST contain one or more input element which provide a set of independent models entries. If two or more input variables of independent models are the same (same unit, interval, description) a link should be made to one input variable of the composite model.

Outputs element

It MUST contain one or more output element which provide a set of independent models outputs or a result of a combination of models .

Composition element

It’s a list of models elements which contains a list of links elements. Link provides the mechanism for mapping inputs declared within one modelUnit to output in another modelUnit, allowing information to be exchanged between the various atomic models in the composite model.

Algorithm element

The implementation differs from the platform:

  • Discrete Events Models and Formalisms (RECORD)
  • Actor model framework (OpenAlea)
  • A sequence of algorithmic instructions witch implement the control flow (BIOMA)

PyCropML User Guide

Version:0.1.1
Release:0.1.1
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
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.csharpGenerator module
class pycropml.transpiler.generators.csharpGenerator.CsharpCompo(tree=None, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.csharpGenerator.CsharpTrans, pycropml.transpiler.generators.csharpGenerator.CsharpGenerator

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

assignParam()[source]
constrWrap()[source]
copyconstrWrap()[source]
copyconstructor(node)[source]
estimateWrap()[source]
format()[source]
get_mo(varname)[source]
initCompo()[source]
initWrap()[source]
instanceModels()[source]
loadParamWrap()[source]
outputWrap()[source]
privateWrap()[source]
setCompo(p)[source]
tranAssignParam()[source]
visit_assignment(node)[source]
visit_declaration(node)[source]
visit_function_definition(node)[source]
visit_local(node)[source]
visit_module(node)[source]
visit_return(node)[source]
wrapper()[source]
class pycropml.transpiler.generators.csharpGenerator.CsharpGenerator(tree, model=None, name=None)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.csharpRules.CsharpRules

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

add_features(node)[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_continuestatnode(node)[source]
visit_custom_call(node)[source]

TODO

visit_datetime(node)[source]
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]

TODO

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.csharpGenerator.CsharpTrans(models)[source]

Bases: pycropml.transpiler.codeGenerator.CodeGenerator, pycropml.transpiler.rules.csharpRules.CsharpRules

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

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']}
copyconstructor(node)[source]
generate(nodes, typ)[source]
getset(node, wrap=False)[source]
model2Node()[source]
private(node)[source]
visit_DateTime(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.csharpGenerator.to_struct_cs(models, rep, name)[source]
pycropml.transpiler.generators.csharpGenerator.to_wrapper_cs(models, rep, name)[source]
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]
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_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_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_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_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_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.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.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
class pycropml.transpiler.generators.siriusGenerator.SiriusCompo(tree=None, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.csharpGenerator.CsharpCompo

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

constrWrap()[source]
copyconstrWrap()[source]
visit_module(node)[source]
wrapper()[source]
class pycropml.transpiler.generators.siriusGenerator.SiriusGenerator(tree=None, model=None, name=None)[source]

Bases: pycropml.transpiler.generators.csharpGenerator.CsharpGenerator

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

class pycropml.transpiler.generators.siriusGenerator.SiriusTrans(models)[source]

Bases: pycropml.transpiler.generators.csharpGenerator.CsharpTrans

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

pycropml.transpiler.generators.siriusGenerator.to_struct_sirius(models, rep, name)[source]
pycropml.transpiler.generators.siriusGenerator.to_wrapper_sirius(models, rep, name)[source]
Module contents
pycropml.transpiler.lib package
Module contents
pycropml.transpiler.rules package
Submodules
pycropml.transpiler.rules.csharpRules module
class pycropml.transpiler.rules.csharpRules.CsharpRules[source]

Bases: pycropml.transpiler.rules.generalRule.GeneralRule

binary_op = {'!=': '!=', '*': '*', '+': '+', '-': '-', '/': '/', '<': '<', '<=': '<=', '==': '==', '>': '>', '>=': '>=', 'and': '&&', 'not': '!', 'or': '||'}
constructor = '\n public %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 = '\n public %s(%s toCopy): this() // copy constructor \n {\n'
functions = {'datetime': {'datetime': ' new DateTime'}, 'io': {'print': 'Display', 'read': 'Console.ReadLine', 'read_file': 'File.ReadAllText', 'write_file': 'File.WriteAllText'}, 'math': {'acos': 'Math.Acos', 'asin': 'Math.Asin', 'atan': 'Math.Atan', 'ceil': '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': 'Math.Pow'}}
methods = {'array': {'append': '.Add', 'len': <function translateLenArray>}, 'dict': {'get': <function translateget>, 'keys': <function translatekeyDict>, 'len': <function translateLenDict>}, 'float': {'int': '(int)'}, 'int': {'float': '(double)'}, 'list': {'append': '.Add', 'contains?': '.Contains', 'index': '.IndexOf', 'insert_at': '.Insert', 'len': <function translateLenList>, 'not contains?': <function translateNotContains>, 'pop': '.RemoveAt', 'sum': <function translateSum>}, 'str': {'find': '.IndexOf', 'int': '(int)'}}
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 = {'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.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.translateSum(node)[source]
pycropml.transpiler.rules.csharpRules.translateget(node)[source]
pycropml.transpiler.rules.csharpRules.translatekeyDict(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 <lambda>>}, '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': 'MIN', 'modulo': 'modulo', 'pow': <function translatePow>, 'round': 'Round'}}
method()[source]
methods = {'array': {'append': <function <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.translateNotContains(node)[source]
pycropml.transpiler.rules.fortranRules.translatePop(node)[source]
pycropml.transpiler.rules.fortranRules.translatePow(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': '||'}
constructor = '\n public %s()\n {\n \n }'
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': 'format.parse'}, 'math': {'acos': 'Math.acos', 'asin': 'Math.asin', 'atan': 'Math.atan', 'ceil': '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': 'Math.pow'}}
get_properties = '\n {\n return %s;\n }'
get_properties_compo = '\n {\n return _%s.get%s();\n }'
methods = {'array': {'append': '.add', 'len': <function translateLenArray>}, 'dict': {'get': '.get', 'keys': <function translateDictkeys>, 'len': <function translateLenDict>}, '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': '(int)'}}
set_properties = '\n {\n this.%s= _%s;\n } \n '
set_properties_compo = '\n {\n %s\n } '
types = {'array': '%s[] %s= new %s', 'bool': 'boolean', 'datetime': 'Date', 'dict': 'TreeMap', 'float': 'double', 'int': 'int', 'list': 'List', 'str': 'String', 'tuple': 'Tuple'}
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.trans_format_parse(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.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'}, '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', 'pow': 'pow'}}
methods = {'array': {'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 <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.translateNotContains(node)[source]
pycropml.transpiler.rules.sqRules module
Module contents
Submodules
pycropml.transpiler.Parser module
class pycropml.transpiler.Parser.opt(**kwds)[source]
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]

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.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]
assert_translatable(node, **pairs)[source]
newtype()[source]
notdeclared(name, line)[source]
retrieve_library(func)[source]
transformer()[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_condexprnode(node, test, true_val, false_val, location)[source]
visit_continuestatnode(node, location)[source]
visit_csimplebasetypenode(node, 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)[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]

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=(u'', u''))[source]
emit_string(node, prefix=u'')[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_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]
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: exceptions.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]

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
class pycropml.transpiler.main.Main(file, language, models=None, name=None)[source]
parse()[source]
to_ast(source)[source]
to_source()[source]
translate()[source]
pycropml.transpiler.main.formater(code)[source]
pycropml.transpiler.main.formaterNext(line)[source]
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]

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

License, Header

Use pkglts

Generate notebook from code source

class pycropml.code2nbk.Model2Nb(model, code, name, dir=None)[source]

Bases: object

Generate a Jupyter Notebook from a set of models.

generate_nb(language, tg_rep, namep)[source]
nb = {'cells': [], 'metadata': {}, 'nbformat': 4, 'nbformat_minor': 2}
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

Created on Tue Mar 19 22:59:23 2019

@author: midingoy

pycropml.cyml.ext(language)[source]
pycropml.cyml.prefix(model)[source]
pycropml.cyml.transpile_file(source, language)[source]
pycropml.cyml.transpile_package(package, language)[source]
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: exceptions.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

Created on Tue Mar 19 22:59:23 2019

@author: pradal

pycropml.main.main()[source]
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(k[, d]) → D[k] if k in D, else d. d defaults to None.[source]
has_key(k) → True if D has a key k, else False[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]
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: exceptions.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

DATATYPE = {'BOOLEAN': <type 'bool'>, 'CHARLIST': <type 'list'>, 'DATE': <type 'str'>, 'DATELIST': <type 'list'>, 'DOUBLE': <type 'float'>, 'DOUBLEARRAY': <built-in function array>, 'DOUBLELIST': <type 'list'>, 'FLOAT': <type 'float'>, 'INT': <type 'int'>, 'INTLIST': <type 'list'>, 'STRING': <type 'str'>, 'STRINGLIST': <type 'list'>}
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(model_unit)[source]
generate_package()[source]

Generate a R 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]
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_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, model_unit)[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': <type 'bool'>, 'CHARLIST': <type 'list'>, 'DATE': <type 'str'>, 'DATELIST': <type 'list'>, 'DOUBLE': <type 'float'>, 'DOUBLEARRAY': <built-in function array>, 'DOUBLELIST': <type 'list'>, 'FLOAT': <type 'float'>, 'INT': <type 'int'>, 'INTLIST': <type 'list'>, 'STRING': <type 'str'>, 'STRINGLIST': <type '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.test_generator.generate_test_check(model, dir=None)[source]
pycropml.test_generator.generate_test_cs(model, dir)[source]
pycropml.test_generator.generate_test_f90(model, dir)[source]
pycropml.test_generator.generate_test_java(model, directory=None)[source]
pycropml.test_generator.generate_test_openalea(model, dir=None)[source]
pycropml.test_generator.generate_test_py(model, dir=None)[source]
pycropml.test_generator.generate_test_simplace(model, dir=None)[source]
pycropml.test_generator.generate_test_sirius(model, dir=None)[source]
pycropml.topology module
class pycropml.topology.Package(name, metainfo, path=None)[source]
class pycropml.topology.PackageManager(proj)[source]
check_exist()[source]
contain_pkg()[source]
get_path(pkg)[source]
class pycropml.topology.Topology(name, pkg=None)[source]
algo2cyml()[source]
algorithm()[source]
check_compo(mc, m)[source]
compotranslate(language)[source]
createGraph()[source]
create_edgeInOut()[source]
decl(defa=True)[source]
display_wf()[source]
generate_function_signature(model)[source]
get_mu_inp(pkgname, varname)[source]
get_mu_out(pkgname, varname)[source]
info_inputs_mu(ppkg, mu, varname)[source]
info_minout()[source]
info_outputs_mu(ppkg, mu, varname)[source]
isPackage(name)[source]
load_pkge(name)[source]
meta_ext(pkgname)[source]
meta_inp(pkgname)[source]
meta_out(pkgname)[source]
minout()[source]
pkg_m(mc, m)[source]
pkgs = {}
retrive(pkgname)[source]
topologicalSort()[source]
translate()[source]
translate_all(model)[source]
val_init(model)[source]
write_png()[source]
write_xml()[source]
pycropml.version module

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

pycropml.version.MAJOR = 0

(int) Version major component.

pycropml.version.MINOR = 1

(int) Version minor component.

pycropml.version.POST = 1

(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

PyCropML is released under a MIT License.

Welcome to CropML’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