Welcome to PyCrop2ML Documentation¶
Contents .. _pycropml:
PyCrop2ML documentation¶
Module description¶
What is PyCrop2ML?¶
What is Crop2ML ?¶
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¶
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¶
Formal definition of a Model Unit in Crop2ML¶

Formal definition of a Composite Model in Crop2ML¶
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.
CyML Language Specification¶
This document specifies the CyML language, an extended Cython subset supported.
Cython file types¶
- The implementation files, carrying a
.pyx
suffix.
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.
src¶
pycropml package¶
Subpackages¶
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.
-
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.
-
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
-
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.
-
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.
-
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}¶
-
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
-
unop_precedence
= {'!': 3, '+': 10, '-': 10, 'not': 3, '~': 10}¶
-
-
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.
-
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.
-
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']}¶
-
-
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.
-
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.
-
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.
-
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.
-
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.
- <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>
-
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
-
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': '!', '~': '~'}¶
-
-
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': '!', '~': '~'}¶
-
-
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'}}¶
-
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. ', '~': '~'}¶
-
-
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': '!', '~': '~'}¶
-
-
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 ', '~': '~'}¶
-
-
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 ', '~': '~'}¶
-
-
class
pycropml.transpiler.rules.sqRules.
SqRules
[source]¶ Bases:
pycropml.transpiler.rules.generalRule.GeneralRule
-
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'¶
-
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 '}¶
-
-
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
-
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
-
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
-
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
-
class
pycropml.transpiler.ast_transform.
AstTransformer
(tree, code, model=None)[source]¶ Bases:
object
-
visit_defnode
(node, args, star_arg, starstar_arg, decorators, body, return_type_annotation, location)[source]¶
-
-
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}¶
-
unop_precedence
= {'!': 3, '+': 11, '-': 11, 'not': 3, '~': 11}¶
-
-
exception
pycropml.transpiler.errors.
PseudoCythonNotTranslatableError
(message, suggestions=None, right=None, wrong=None)[source]¶
-
exception
pycropml.transpiler.errors.
PseudoCythonTypeCheckError
(message, suggestions=None, right=None, wrong=None)[source]¶
-
exception
pycropml.transpiler.errors.
PseudoError
(message, suggestions=None, right=None, wrong=None)[source]¶ Bases:
Exception
-
pycropml.transpiler.errors.
tab_aware
(location, code)[source]¶ if tabs in beginning of code, add tabs for them, otherwise spaces
-
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
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.
Submodules¶
-
class
pycropml.checking.
Test
(name)[source]¶ Bases:
pycropml.checking.Testset
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.
-
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.
-
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.
-
class
pycropml.inout.
Input
(kwds)[source]¶ Bases:
pycropml.inout.InputOutput
-
class
pycropml.inout.
Output
(kwds)[source]¶ Bases:
pycropml.inout.InputOutput
Model Description and Model Unit.
-
class
pycropml.modelunit.
ModelUnit
(kwds)[source]¶ Bases:
pycropml.modelunit.ModelDefinition
Formal description of a Model Unit.
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.
-
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.
-
get_metainfo
(key)[source]¶ Return a meta information. See the standard key in the __init__ function documentation. :param key: todo
-
get_pkg_files
()[source]¶ Return the list of xml filename of the package. The filename are relative to self.path
-
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.
-
mimetype
= 'pycrop2ml/package'¶
-
-
class
pycropml.package.
PackageDict
(*args)[source]¶ Bases:
dict
Dictionnary with case insensitive key This object is able to handle protected entry begining with an ‘#’
-
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
-
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
-
init
(dirname=None, verbose=True)[source]¶ Initialize package manager
If dirname is None, find composition files on the system else load directory
-
reload
(pkg=None)[source]¶ Reload one or all packages. If the package pkg is None reloa all the packages. Else reload only pkg.
-
-
class
pycropml.package.
PseudoGroup
(name)[source]¶ Bases:
pycropml.package.PackageDict
Data structure used to separate dotted naming (packages, category)
-
mimetype
= 'pycrop2ml/package'¶
-
sep
= '.'¶
-
-
class
pycropml.package.
PyPackageReader
(filename)[source]¶ Bases:
pycropml.package.AbstractPackageReader
Build packages from wralea file Use ‘register_package’ function
-
class
pycropml.package.
PyPackageReaderModel
(filename)[source]¶ Bases:
pycropml.package.PyPackageReader
Build a package from a __wralea__.py Use module variable
-
class
pycropml.package.
PyPackageWriter
(package)[source]¶ Bases:
object
Write a wralea python file
-
pkg_template
= '\n$PKGNAME\n$METAINFO\n'¶
-
wralea_template
= '\n# This file has been generated at $TIME\n$PKG_DECLARATION\n'¶
-
-
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
License, Header
-
class
pycropml.pparse.
ModelParser
[source]¶ Bases:
pycropml.pparse.Parser
Read an XML file and transform it in our object model.
Add License, Header.
Use pkglts
Problems: - name of a model unit?
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>'}¶
-
num
= 0¶
-
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>'}¶
-
num
= 0¶
-
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_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
-
num
= 0¶
-
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(:)'}¶
-
num
= 0¶
-
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'}¶
-
num
= 0¶
-
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.
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.
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.
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_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_wralea
()[source]¶ Generate wralea factories from the meta-information of the the model units.
-
num
= 0¶
-
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.
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_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
-
num
= 0¶
-
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
Indices and tables¶
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]]:
Quick Links¶
- [[Project Git Repository|https://github.com/cython/cython|Git Repository]] (and [[Change Log|https://github.com/cython/cython/blob/master/CHANGES.rst|Change Log]])
- [[ Differences between Cython and Pyrex|https://cython.readthedocs.io/en/latest/src/userguide/pyrex_differences.html| Differences between Cython and Pyrex]]
- [[Unsupported Python features|https://cython.readthedocs.io/en/latest/src/userguide/limitations.html|Unsupported Python features]] (aka TODO list)
- [[ Hacker-Guide: How to work on the Cython compiler itself|HackerGuide| Hacker-Guide: How to work on the Cython compiler itself]]
- [[ Enhancement proposals|enhancements| Enhancement proposals]] (CEPs)
- [[ Projects using Cython|projects| Projects using Cython]]
- [[ Comparison with SWIG|SWIG| Comparison with SWIG]]
- [[Automatic .pxd/.pyx generation|AutoPxd|Automatic .pxd/.pyx generation]] from C or C++ header files.
Cython Installers¶
- [[PyPi|http://pypi.python.org/pypi/Cython/|PyPi]] via
easy_install
or pip- [[Gentoo Ebuild|http://packages.gentoo.org/package/dev-python/cython|Gentoo Ebuild]]
- [[Debian package|http://packages.debian.org/sid/cython|Debian package]] (not always up to date)
- [[ Installing Cython on Windows|InstallingOnWindows| Installing Cython on Windows]]
Tips and Tricks¶
[[Getting started|http://docs.cython.org/src/quickstart/index.html|Getting started]]
[[ Using early binding techniques to improve speed|http://docs.cython.org/en/latest/src/userguide/early_binding_for_speed.html| Using early binding techniques to improve speed]]
[[ Writing Cython programs in pure Python|http://docs.cython.org/src/tutorial/pure.html| Writing Cython programs in pure Python]]
[[ Helpful notes for wrapping C++ APIs|http://docs.cython.org/en/latest/src/userguide/wrapping_CPlusPlus.html| Helpful notes for wrapping C++ APIs]]
[[ Discussion of all the options how to wrap C/C++ code to Python|WrappingCorCpp| Discussion of all the options how to wrap C/C++ code to Python]]
[[WritingFastPyrexCode|http://www.sagemath.org:9001/WritingFastPyrexCode|WritingFastPyrexCode]]
[[ Successful creation of a hierarchy of modules in a package|PackageHierarchy| Successful creation of a hierarchy of modules in a package]]
[[ One method for source-level debugging|http://docs.cython.org/en/latest/src/userguide/debugging.html| One method for source-level debugging]]
[[ Dynamic Memory Allocation (malloc, realloc, free)|http://docs.cython.org/en/latest/src/tutorial/memory_allocation.html| Dynamic Memory Allocation (malloc, realloc, free)]]
[[Profiling]]
[[ Building a Windows Installer|BuildingWindowsInstaller| Building a Windows Installer]]
[[Embedding Python|EmbeddingCython|Embedding Python]] to create standalone Cython programs.
[[List Subclass Example|ListExample|List Subclass Example]] Adding mathematical operations to subclassed built-in list.
Working with Numpy
- [[Tutorial for NumPy users|http://docs.cython.org/en/latest/src/userguide/numpy_tutorial.html|Tutorial for NumPy users]]
- [[Accessing a Numpy pointer for passing to C|http://docs.cython.org/en/latest/src/userguide/memoryviews.html#pass-data-from-a-c-function-via-pointer]]
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