Nektar++
Classes | Functions | Variables
CellMLToNektar.translators Namespace Reference

Classes

class  CellMLTranslator
 
class  ConfigurationError
 
class  ConfigurationStore
 
class  SolverInfo
 
class  TranslationError
 

Functions

def version_comment (note_time=True)
 
def debugexpr (e)
 
def get_options (args, default_options=None)
 
def load_model (model_file, options)
 
def run ()
 

Variables

list __version__ = "$Revision: 25950 $"[11:-2]
 

Function Documentation

◆ debugexpr()

def CellMLToNektar.translators.debugexpr (   e)

Definition at line 74 of file translators.py.

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

◆ get_options()

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.

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

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

◆ load_model()

def CellMLToNektar.translators.load_model (   model_file,
  options 
)
Load and validate a CellML model.

Definition at line 2754 of file translators.py.

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

Referenced by CellMLToNektar.translators.run().

◆ run()

def CellMLToNektar.translators.run ( )
Translate the file given on the command line.

Definition at line 2789 of file translators.py.

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

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 Nektar::SolverUtils::FilterFieldConvert.FilterFieldConvert(), and main().

◆ version_comment()

def CellMLToNektar.translators.version_comment (   note_time = True)
Generate a version comment, with optional time info.

Definition at line 62 of file translators.py.

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

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

Variable Documentation

◆ __version__

list CellMLToNektar.translators.__version__ = "$Revision: 25950 $"[11:-2]
private

Definition at line 58 of file translators.py.