Hi,
Here's a doctest file I tried to run with py.test -f (I mentioned
three files on #pylib, but at closer look two of those were just empty
placeholders so far).
Jussi
----------------------------------------
Jussi Rasinmäki
Simosol Oy
Eteläinen Asemakatu 2B, 11130 Riihimäki, Finland
+358-400-382364
[EMAIL PROTECTED]
.. _modelchain-py:
#############
modelchain.py
#############
*******************************
class ModelChainDef(XmlObject):
*******************************
Model chain definitions.
def __init__(self, typedef, schema, xmldata, dirpath):
======================================================
Initializes the model chains by processing their schema and xml documents::
>>> from simo.simobuilder.modelchain.modelchain import ModelChainDef
>>> tdf = open('../../xml/schemas/Typedefs_SIMO.xsd')
>>> typedef = tdf.read()
>>> tdf.close()
>>> sf = open('../../xml/schemas/geo_table.xsd')
>>> schema = sf.read()
>>> sf.close()
>>> xml = u'''
... '''
>>> class Lexicon(object):
... def variable_ind(self, level, variable, where):
... if variable == 'GEO_X':
... return (1,1)
... elif variable == 'GEO_Y':
... return (1,2)
... elif variable == 'ALT':
... return (1,3)
... elif variable == 'TS':
... return (1,4)
>>> mcd = ModelChainDef(typedef)
>>> #mcd.schema = schema
>>> #mcd.xml = ('testxml', xml, Lexicon(), 'simulation')
>>> #mcd.xml['testxml'][:11]
def xml_to_obj(self, root, lexicon):
====================================
>>> #mc = mcd.obj['dem']
*************************
class ModelChain(object):
*************************
Values tied to a regular grid over the earth. Coordinates in decimal degrees.
Attributes:
- name
- filename: where the data for the table is
- ulx: upper left x-coordinate (longitude)
- uly: upper left y-coordinate (latitude)
- nrow: number of data rows (along y-coord)
- ncol: number of data colums (along x-coord)
- xdim: the grid step in x-direction
- ydim: the grid step in y-direction
- nvar: number of variables tied to each node in the grid
- longitude_var: data variable containing the longitude coordinate; dictionary
with keys 'variable' and 'level' containing the variable and level indices for
the data matrix
- latitude_var: data variable containing the latitude coordinate; dictionary
with keys 'variable' and 'level' containing the variable and level indices for
the data matrix
- targets: result variable definitions: a list of (levelindex, variale index)
tuples
- arr: the actual data in a multidimensional array
- sim: the simulator instance using the table
def __init__(self, ns, root, validator):
========================================
Construct model chain from the parsed model chain xml.
def execute(self, objs, param, sim):
=======================================
Execute a geo_table model for the data objects (objs) using the settings from
the modelchain (param) for the simulator instance (sim).
Calling with valid data::
_______________________________________________
py-dev mailing list
[email protected]
http://codespeak.net/mailman/listinfo/py-dev