Nektar++
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Classes | Functions | Variables
CellMLToNektar.translators Namespace Reference

Classes

class  CellMLTranslator
 
class  ConfigurationError
 
class  ConfigurationStore
 
class  SolverInfo
 
class  TranslationError
 

Functions

def version_comment
 
def debugexpr
 
def get_options
 
def load_model
 
def run
 

Variables

string __version__ = "$Revision: 25950 $"
 

Function Documentation

def CellMLToNektar.translators.debugexpr (   e)

Definition at line 74 of file translators.py.

74 
75 def debugexpr(e):
76  "For debugging."
77  v = None
78  if isinstance(e, cellml_variable):
79  v = e
80  elif isinstance(e, mathml_apply):
81  v = e.assigned_variable()
82  if v:
83  r = (v==e, v.name, v.get_usage_count())
84  else:
85  r = (False, '', -1)
86  return r
87 
def CellMLToNektar.translators.get_options (   args,
  default_options = None 
)
get_options(args):
Process our command-line options.

args is a list of options & positional arguments.

default_options, if given, is an instance of optparse.Values created by a
previous call to this function.

Definition at line 2489 of file translators.py.

Referenced by CellMLToNektar.translators.ConfigurationStore.read_configuration_file(), and CellMLToNektar.translators.run().

2490 def get_options(args, default_options=None):
2491  """get_options(args):
2492  Process our command-line options.
2493 
2494  args is a list of options & positional arguments.
2495 
2496  default_options, if given, is an instance of optparse.Values created by a
2497  previous call to this function.
2498  """
2499  usage = 'usage: %prog [options] <cellml file or URI>'
2500  parser = optparse.OptionParser(version="%%prog %s" % __version__,
2501  usage=usage)
2502  parser.add_option('-q', '--quiet', action='store_true', default=False,
2503  help="don't show warning messages, only errors")
2504  # What type of translation is being performed
2505  parser.add_option('-T', '--translate',
2506  dest='translate', action='store_true',
2507  default=True,
2508  help="output computer code [default]")
2509  parser.add_option('-C', '--output-cellml',
2510  dest='translate', action='store_false',
2511  help="output an annotated CellML file instead of translating, on stdout unless -o specified")
2512  translators = sorted(CellMLTranslator.translators)
2513  parser.add_option('-t', '--translate-type',
2514  type='choice', choices=translators,
2515  default='Nektar', metavar='TYPE',
2516  help="the type of code to output [default: %default]. "
2517  "Choices: " + str(translators))
2518  parser.add_option('-o', dest='outfilename', metavar='OUTFILE',
2519  help="write program code to OUTFILE [default action is to use the input filename with a different extension]")
2520  # Global adjustment settings
2521  parser.add_option('--config-file',
2522  action='append', default=[],
2523  help="pathname of configuration file")
2524  parser.add_option('-A', '--fully-automatic',
2525  action='store_true', default=False,
2526  help="if human intervention is required, fail noisily")
2527  parser.add_option('--assume-valid',
2528  action='store_true', default=False,
2529  help="skip some of the model validation checks")
2530  parser.add_option('--warn-on-unit-conversions',
2531  action='store_true', default=False,
2532  help="generate a warning if unit conversions are required")
2533  parser.add_option('--Wu', '--warn-on-units-errors',
2534  action='store_true', default=False,
2535  dest='warn_on_units_errors',
2536  help="give a warning instead of an error for dimensional inconsistencies")
2537  parser.add_option('-V', '--transmembrane-potential', default=None, metavar='POT_VAR',
2538  help="POT_VAR is the full name of the variable representing the transmembrane potential."
2539  " If not specified here, the configuration file will be used, which is the prefered method."
2540  " Defaults to 'membrane,V'.")
2541  parser.add_option('-d', '--debug', action='store_true', default=False,
2542  help="output debug info to stderr")
2543  parser.add_option('-D', '--debug-source', action='append',
2544  help="only show debug info from the specified part of the code."
2545  " This option may appear more than once to select multiple sources. Implies -d.")
2546  parser.add_option('--profile', action='store_true', default=False,
2547  help="turn on profiling of PyCml")
2548  # To examine the profile do something like:
2549  # import os,pstats
2550  # os.chdir('/tmp')
2551  # files = filter(lambda f: f.startswith('pycml'), os.listdir('.'))
2552  # p = pstats.Stats(*files)
2553  # p.strip_dirs().sort_stats('cum').print_stats(15)
2554  # What optimisations/transformations to do
2555  group = optparse.OptionGroup(parser, 'Transformations',
2556  "These options control which transformations (typically optimisations) are applied in the generated code")
2557  group.add_option('-l', '--lookup-tables',
2558  dest='lut', action='store_true', default=False,
2559  help="perform a lookup table analysis")
2560  group.add_option('-p', '--pe', '--partial-evaluation',
2561  dest='pe', action='store_true', default=False,
2562  help="partially evaluate the model")
2563  group.add_option('-u', '--units-conversions',
2564  action='store_true', default=False,
2565  help="add explicit units conversion mathematics")
2566  group.add_option('-j', '--maple-output',
2567  metavar='FILENAME', default=None,
2568  help="file containing output from a Maple script generated using -J. The generated"
2569  " code/CellML will then contain a symbolic Jacobian as computed by Maple.")
2570  group.add_option('-J', '--do-jacobian-analysis',
2571  action='store_true', default=False,
2572  help="generate code to perform Jacobian analysis for backward Euler & CVODE; implies -t Maple")
2573  group.add_option('--backward-euler',
2574  action='store_true', default=False,
2575  help="generate a specialised cell model that solves itself using a decoupled"
2576  " backward Euler method. Not compatible with --rush-larsen. Implies -t Chaste."
2577  " Requires -j.")
2578  group.add_option('--rush-larsen',
2579  action='store_true', default=False,
2580  help="use the Rush-Larsen method to solve Hodgkin-Huxley style gating variable"
2581  " equations. Not compatible with --backward-euler. Implies -t Chaste.")
2582  group.add_option('--grl1',
2583  action='store_true', default=False,
2584  help="use the GRL1 method to solve Hodgkin-Huxley style gating variable"
2585  " equations. Not compatible with the backward Euler transformation."
2586  " Implies -t Chaste.")
2587  group.add_option('--grl2',
2588  action='store_true', default=False,
2589  help="use the GRL2 method to solve Hodgkin-Huxley style gating variable"
2590  " equations. Not compatible with the backward Euler transformation."
2591  " Implies -t Chaste.")
2592  parser.add_option_group(group)
2593  # Settings tweaking the generated code
2594  group = optparse.OptionGroup(parser, 'Generated code options')
2595  group.add_option('-c', '--class-name', default=None,
2596  help="explicitly set the name of the generated class")
2597  group.add_option('-a', '--augment-class-name',
2598  dest='augment_class_name', action='store_true',
2599  default=False,
2600  help="alter the class name to show what transformations are used")
2601  group.add_option('--no-timestamp',
2602  action='store_true', default=False,
2603  help="don't add a timestamp comment to generated files")
2604  parser.add_option_group(group)
2605  # Options specific to Maple output
2606  group = optparse.OptionGroup(parser, 'Maple options', "Options specific to Maple code output")
2607  group.add_option('--dont-omit-constants',
2608  dest='omit_constants', action='store_false', default=True,
2609  help="when generating Maple code, include assignments of constants")
2610  group.add_option('--compute-partial-jacobian', dest='compute_full_jacobian',
2611  action='store_false', default=True,
2612  help="make generated Maple code compute a Jacobian specific to a Newton solve"
2613  " of the nonlinear portion of the ODE system, rather than the full system Jacobian")
2614  parser.add_option_group(group)
2615  # Options specific to Python output
2616  group = optparse.OptionGroup(parser, 'Python options', "Options specific to Python code output")
2617  group.add_option('--no-numba', dest='numba', default=True, action='store_false',
2618  help="turn off using Numba to optimise code on-the-fly")
2619  parser.add_option_group(group)
2620  # Options specific to Chaste output
2621  group = optparse.OptionGroup(parser, 'Chaste options', "Options specific to Chaste code output")
2622  group.add_option('-y', '--dll', '--dynamically-loadable',
2623  dest='dynamically_loadable',
2624  action='store_true', default=False,
2625  help="add code to allow the model to be compiled to a shared library and dynamically loaded"
2626  " (only works if -t Chaste is used)")
2627  group.add_option('--use-chaste-stimulus',
2628  action='store_true', default=False,
2629  help="when generating Chaste code, use Chaste's stimulus rather than that defined in the model")
2630  group.add_option('--no-use-chaste-stimulus', dest='use_chaste_stimulus',
2631  action='store_false',
2632  help="when generating Chaste code, use the model's stimulus, not Chaste's")
2633  group.add_option('-i', '--convert-interfaces',
2634  action='store_true', default=False,
2635  help="perform units conversions at interfaces to Chaste (only works if -t Chaste is used)")
2636  group.add_option('--use-i-ionic-regexp', dest='use_i_ionic_regexp',
2637  action='store_true', default=False,
2638  help="determine ionic currents from the regexp specified in the config file"
2639  " rather than analysing the voltage derivative equation")
2640  group.add_option('--include-dt-in-tables',
2641  action='store_true', default=False,
2642  help="[experimental] allow timestep to be included in lookup tables. By default"
2643  " uses the timestep of the first cell created. Requires support from external"
2644  " code if timestep changes. Only really useful for backward Euler cells.")
2645  group.add_option('-m', '--use-modifiers',
2646  action='store_true', default=False,
2647  help="[experimental] add modifier functions for certain"
2648  " metadata-annotated variables for use in sensitivity analysis (only works if -t Chaste is used)")
2649  group.add_option('--use-data-clamp',
2650  action='store_true', default=False,
2651  help="[experimental] generate a data clamp subclass of CVODE cells"
2652  " which contains data clamp currents for fitting experimental data (only works if -t CVODE is used)")
2653  group.add_option('--expose-annotated-variables',
2654  action='store_true', default=False,
2655  help="expose all oxmeta-annotated variables for access via the GetAnyVariable functionality")
2656  group.add_option('--expose-all-variables',
2657  action='store_true', default=False,
2658  help="expose all variables for access via the GetAnyVariable functionality")
2659  parser.add_option_group(group)
2660  # Options specific to Functional Curation
2661  group = optparse.OptionGroup(parser, 'Functional Curation options', "Options specific to use by Functional Curation")
2662  def protocol_callback(option, opt_str, value, parser):
2663  """
2664  Protocols don't always produce normal cardiac cell models.
2665  However, we want to allow a later option to override these changes.
2666  """
2667  parser.values.protocol = value
2668  parser.values.convert_interfaces = False
2669  parser.values.use_chaste_stimulus = False
2670  group.add_option('--protocol',
2671  action='callback', callback=protocol_callback, type='string', nargs=1,
2672  help="specify a simulation protocol to apply to the model prior to translation")
2673  group.add_option('--protocol-options', action='store', type='string',
2674  help="extra options for the protocol")
2675  group.add_option('--expose-named-parameters',
2676  action='store_true', default=False,
2677  help="expose all constant variables with 'name' annotations for access as model parameters")
2678  parser.add_option_group(group)
2679  # Settings for lookup tables
2680  group = optparse.OptionGroup(parser, 'Lookup tables options', "Options specific to the lookup tables optimisation")
2681  lookup_type_choices = ['entry-below', 'nearest-neighbour', 'linear-interpolation']
2682  group.add_option('--lookup-type', choices=lookup_type_choices,
2683  default='linear-interpolation',
2684  help="the type of table lookup to perform [default: %default]."
2685  " Choices: " + str(lookup_type_choices))
2686  group.add_option('--no-separate-lut-class', dest='separate_lut_class',
2687  action='store_false', default=True,
2688  help="don't put lookup tables in a separate class")
2689  group.add_option('--row-lookup-method',
2690  action='store_true', default=True,
2691  help="add and use a method to look up a whole row of a table")
2692  group.add_option('--no-row-lookup-method', dest='row_lookup_method',
2693  action='store_false',
2694  help="don't add and use a method to look up a whole row of a table")
2695  group.add_option('--combine-commutative-tables',
2696  action='store_true', default=False,
2697  help="optimise a special corner case to reduce the number of tables."
2698  " See documentation for details.")
2699  group.add_option('--lt-index-uses-floor',
2700  action='store_true', default=False,
2701  help="use floor() to calculate LT indices, instead of just casting")
2702  group.add_option('--constrain-table-indices',
2703  action='store_true', default=False,
2704  help="constrain lookup table index variables to remain within the bounds specified,"
2705  " rather than throwing an exception if they go outside the bounds")
2706  group.add_option('--no-check-lt-bounds', dest='check_lt_bounds',
2707  action='store_false', default=True,
2708  help="[unsafe] don't check for LT indexes going outside the table bounds")
2709  parser.add_option_group(group)
2710  # Settings for partial evaluation
2711  group = optparse.OptionGroup(parser, 'Partial evaluation options', "Options specific to the partial evaluation optimisation")
2712  group.add_option('--pe-convert-power',
2713  action='store_true', default=False,
2714  help="convert pow(x,3) to x*x*x; similarly for powers 2 & 4.")
2715  group.add_option('--no-partial-pe-commutative', dest='partial_pe_commutative',
2716  action='store_false', default=True,
2717  help="don't combine static operands of dynamic commutative associative applys")
2718  group.add_option('--no-pe-instantiate-tables', dest='pe_instantiate_tables',
2719  action='store_false', default=True,
2720  help="don't instantiate definitions that will be tables regardless of usage")
2721  parser.add_option_group(group)
2722 
2723  options, args = parser.parse_args(args, values=default_options)
2724  if len(args) != 1:
2725  parser.error("exactly one input CellML file must be specified")
2726 
2727  # Some options imply others
2728  if options.debug_source:
2729  options.debug = True
2730  if options.do_jacobian_analysis:
2731  options.translate_type = 'Maple'
2732  options.maple_output = False
2733  options.rush_larsen = False
2734  options.backward_euler = False
2735  if options.backward_euler:
2736  if not options.maple_output:
2737  parser.error("Backward Euler code generation requires maple output (-j)")
2738  options.rush_larsen = False
2739  options.grl1 = False
2740  options.grl2 = False
2741  if options.rush_larsen or options.backward_euler or options.grl1 or options.grl2:
2742  options.translate_type = 'Chaste'
2743  if options.use_data_clamp and not options.translate_type=='CVODE':
2744  parser.error("Data clamp option '--use-data-clamp' also requires CVODE ('-t CVODE'). If you are calling this via ConvertCellModel use '--cvode-data-clamp'.")
2745  # Numba may not be available
2746  if options.numba:
2747  try:
2748  import numba
2749  except:
2750  options.numba = False
2751 
2752  return options, args[0]
2753 
def CellMLToNektar.translators.load_model (   model_file,
  options 
)
Load and validate a CellML model.

Definition at line 2754 of file translators.py.

Referenced by CellMLToNektar.translators.run().

2755 def load_model(model_file, options):
2756  """Load and validate a CellML model."""
2757  # Setup logging
2758  logging.thread = None # Hack: we're not multi-threaded, so be slightly quicker...
2759  if options.debug:
2760  formatter = logging.Formatter(fmt="%(name)s: %(message)s")
2761  handler = logging.StreamHandler(sys.stderr)
2762  handler.setFormatter(formatter)
2763  handler.addFilter(OnlyDebugFilter())
2764  if options.debug_source:
2765  handler.addFilter(OnlyTheseSourcesFilter(options.debug_source))
2766  logging.getLogger().addHandler(handler)
2767  logging.getLogger().setLevel(logging.DEBUG)
2768 
2769  # We can't translate if some warnings occur, as well as if the model is invalid
2770  notifier = NotifyHandler(level=logging.WARNING_TRANSLATE_ERROR)
2771  logging.getLogger('validator').addHandler(notifier)
2772  v = validator.CellMLValidator(create_relaxng_validator=not options.assume_valid)
2773  valid, doc = v.validate(model_file, return_doc=True, show_warnings=not options.quiet,
2774  check_for_units_conversions=options.warn_on_unit_conversions,
2775  warn_on_units_errors=options.warn_on_units_errors,
2776  assume_valid=options.assume_valid)
2777  v.quit()
2778  del v
2779 
2780  if not valid or notifier.messages:
2781  print >>sys.stderr, model_file,
2782  if not valid:
2783  print >>sys.stderr, "is not a valid CellML file"
2784  else:
2785  print >>sys.stderr, "contains untranslatable constructs (see warnings above for details)"
2786  sys.exit(1)
2787 
2788  return doc
def CellMLToNektar.translators.run ( )
Translate the file given on the command line.

Definition at line 2789 of file translators.py.

References CellMLToNektar.utilities.close_output_stream(), CellMLToNektar.utilities.DEBUG(), CellMLToNektar.translators.get_options(), CellMLToNektar.translators.load_model(), CellMLToNektar.utilities.open_output_stream(), and CellMLToNektar.translators.version_comment().

Referenced by main(), and Nektar::LibUtilities::SessionReader.ParseCommandLineArguments().

2790 def run():
2791  """Translate the file given on the command line."""
2792  options, model_file = get_options(sys.argv[1:])
2793  doc = load_model(model_file, options)
2794  DEBUG('translate', "+++ Loaded model")
2795 
2796  config = ConfigurationStore(doc, options=options)
2797  for config_file in options.config_file:
2798  config.read_configuration_file(config_file)
2799  DEBUG('translate', "+++ Read config")
2800 
2801  # Apply protocol, if given
2802  if options.protocol:
2803  import protocol
2804  protocol.apply_protocol_file(doc, options.protocol)
2805  if options.debug:
2806  post_proto_cellml = options.outfilename or model_file
2807  post_proto_cellml = os.path.splitext(post_proto_cellml)[0] + '-proto.cellml.ppp'
2808  stream = open_output_stream(post_proto_cellml)
2809  doc.xml(indent=u'yes', stream=stream)
2810  close_output_stream(stream)
2811  DEBUG('translate', "+++ Applied protocol")
2812 
2813  config.finalize_config()
2814  DEBUG('translate', "+++ Processed config")
2815 
2816  solver_info = SolverInfo(doc.model)
2817 
2818  # Generate an interface component, if desired
2819  translator_klass = CellMLTranslator.translators[options.translate_type]
2820  if not options.protocol:
2821  translator_klass.generate_interface(doc, solver_info)
2822  config.validate_metadata(options.assume_valid)
2823  DEBUG('translate', "+++ Generated interface")
2824 
2825  if options.lut:
2826  config.find_lookup_variables()
2827  DEBUG('translate', "+++ Found LT keys")
2828 
2829  # These bits could do with improving, as they annotate more than is really needed!
2830  if options.pe:
2831  # We need to ensure PE doesn't remove ionic currents needed for GetIIonic
2832  config.annotate_currents_for_pe()
2833  # "Need" to ensure pe doesn't remove metadata-annotated variables (when using modifiers or default stimulus?)
2834  config.annotate_metadata_for_pe()
2835  DEBUG('translate', "+++ Annotated variables")
2836  # Deal with the 'expose' options
2837  config.expose_variables()
2838 
2839  class_name = options.class_name
2840  if not class_name:
2841  class_name = doc.model.name.replace('-', '_')
2842  if options.augment_class_name:
2843  class_name = u'CML_' + class_name
2844  if options.pe:
2845  class_name += '_pe'
2846  if options.lut:
2847  class_name += '_lut'
2848  if options.backward_euler:
2849  class_name += '_be'
2850  if options.use_modifiers:
2851  class_name += '_sens'
2852  if options.protocol:
2853  # Try to avoid OdeSystemInformation conflicts
2854  class_name += "_Proto_" + os.path.splitext(os.path.basename(options.protocol))[0]
2855 
2856  output_filename = getattr(options, 'outfilename', None)
2857  if not options.translate and not output_filename:
2858  output_filename = 'stdout'
2859 
2860  if options.units_conversions:
2861  doc.model.add_units_conversions()
2862  DEBUG('translate', "+++ Added units conversions")
2863 
2864  if options.do_jacobian_analysis:
2866  lin.analyse_for_jacobian(doc, V=config.V_variable)
2867  DEBUG('translate', "+++ Analysed model for Jacobian")
2868 
2869  if options.maple_output:
2870  # Parse Jacobian matrix
2871  from maple_parser import MapleParser
2872  mp = MapleParser()
2873  jacobian_file = file(options.maple_output) # TODO: Error checking
2874  doc.model._cml_jacobian = mp.parse(jacobian_file)
2875  doc.model._cml_jacobian_full = mp.JacobianWasFullSize
2876  jacobian_file.close()
2877  if not options.backward_euler and doc.model._cml_jacobian_full:
2878  # Add full jacobian to XML
2879  solver_info.add_jacobian_matrix()
2880  solver_info.add_variable_links()
2881 
2882  if options.backward_euler:
2883  # Rearrange linear ODEs
2885  lin.analyse_for_jacobian(doc, V=config.V_variable)
2886  lin.rearrange_linear_odes(doc)
2887  # Remove jacobian entries that don't correspond to nonlinear state variables
2888  jacobian = doc.model._cml_jacobian
2889  if isinstance(jacobian, tuple):
2890  assert doc.model._cml_jacobian_full
2891  jacobian = jacobian[1]
2892  nonlinear_vars = set([v.get_source_variable(recurse=True) for v in doc.model._cml_nonlinear_system_variables])
2893  def gv(vname):
2894  return cellml_variable.get_variable_object(doc.model, vname).get_source_variable(recurse=True)
2895  for var_i, var_j in jacobian.keys():
2896  if gv(var_i) not in nonlinear_vars or gv(var_j) not in nonlinear_vars:
2897  del jacobian[(var_i, var_j)]
2898  if doc.model._cml_jacobian_full:
2899  # Transform the Jacobian into the form needed by the Backward Euler code
2900  import maple_parser
2901  for key, expr in jacobian.iteritems():
2902  new_expr = None
2903  if key[0] == key[1]:
2904  # 1 on the diagonal
2905  new_expr = maple_parser.MNumber(['1'])
2906  if not (isinstance(expr, maple_parser.MNumber) and str(expr) == '0'):
2907  # subtract delta_t * expr
2908  args = []
2909  if new_expr:
2910  args.append(new_expr)
2911  args.append(maple_parser.MOperator([maple_parser.MVariable(['delta_t']), expr], 'prod', 'times'))
2912  new_expr = maple_parser.MOperator(args, '', 'minus')
2913  if new_expr:
2914  jacobian[key] = new_expr
2915  # Add info as XML
2916  solver_info.add_all_info()
2917  # Analyse the XML, adding cellml_variable references, etc.
2918  solver_info.add_variable_links()
2919  solver_info.add_linear_ode_update_equations()
2920  DEBUG('translate', "+++ Parsed and incorporated Maple output")
2921  else:
2922  options.include_dt_in_tables = False
2923 
2924  if options.lut:
2925  # Create the analyser so PE knows which variables are table keys
2927  else:
2928  lut = None
2929 
2930  if options.pe:
2931  # Do partial evaluation
2933  pe.parteval(doc, solver_info, lut)
2934  DEBUG('translate', "+++ Done PE")
2935 
2936  if options.lut:
2937  # Do the lookup table analysis
2938  lut.analyse_model(doc, solver_info)
2939  DEBUG('translate', "+++ Done LT analysis")
2940 
2941  if options.rush_larsen:
2943  rl.analyse_model(doc)
2944  DEBUG('translate', "+++ Done Rush-Larsen analysis")
2945 
2946  if options.translate:
2947  # Translate to code
2948  initargs = {'add_timestamp': not options.no_timestamp,
2949  'options': options}
2950  transargs = {'v_variable': config.V_variable}
2951  transargs['row_lookup_method'] = options.row_lookup_method
2952  transargs['lt_index_uses_floor'] = options.lt_index_uses_floor
2953  transargs['constrain_table_indices'] = options.constrain_table_indices
2954  """if issubclass(translator_klass, CellMLToMapleTranslator):
2955  initargs['omit_constants'] = options.omit_constants
2956  initargs['compute_full_jacobian'] = options.compute_full_jacobian
2957  el"""
2958  from CellMLToNektarTranslator import CellMLToNektarTranslator
2959  if issubclass(translator_klass, CellMLToNektarTranslator):
2960  solver_info.add_membrane_ionic_current()
2961  transargs['use_chaste_stimulus'] = options.use_chaste_stimulus
2962  transargs['separate_lut_class'] = options.separate_lut_class
2963  transargs['convert_interfaces'] = options.convert_interfaces
2964  transargs['use_modifiers'] = options.use_modifiers
2965  transargs['use_data_clamp'] = options.use_data_clamp
2966  transargs['dynamically_loadable'] = options.dynamically_loadable
2967  transargs['use_protocol'] = bool(options.protocol)
2968  t = translator_klass(**initargs)
2969  t.translate(doc, model_file, output_filename, class_name=class_name, **transargs)
2970  cellml_metadata.remove_model(doc.model)
2971  else:
2972  # Add a comment element
2973  comment = pycml.comment_base(
2974  body=u'\n' + version_comment(not options.no_timestamp) + u'\n')
2975  doc.xml_insert_before(doc.model, comment)
2976  # Output annotated model
2977  stream = open_output_stream(output_filename)
2978  doc.xml(indent=u'yes', stream=stream)
2979  close_output_stream(stream)
2980 
2981 
2982  DEBUG('translate', "+++ Done translation")
def CellMLToNektar.translators.version_comment (   note_time = True)
Generate a version comment, with optional time info.

Definition at line 62 of file translators.py.

Referenced by CellMLToNektar.CellMLToNektarTranslator.CellMLToNektarTranslator.output_includes(), CellMLToNektar.translators.CellMLTranslator.output_top_boilerplate(), and CellMLToNektar.translators.run().

62 
63 def version_comment(note_time=True):
64  """Generate a version comment, with optional time info."""
65  if note_time:
66  t = '\non ' + time.asctime()
67  else:
68  t = ''
69  text = """Processed by pycml - CellML Tools in Python
70  (translators: %s, pycml: %s, optimize: %s)%s""" % (
71  __version__, pycml.__version__, optimize.__version__, t)
72  return text
73 
#some debugging function?

Variable Documentation

string CellMLToNektar.translators.__version__ = "$Revision: 25950 $"

Definition at line 58 of file translators.py.