def prepare(quick=False, incremental=False, cli=False, full=False, **kwargs): """ Run code generation. Warnings -------- The default behavior has changed since v1.0.8: when `cli` is `True` and `full` is not `True`, quick code generation will be used. Returns ------- System object if `cli` is `False`; exit_code 0 otherwise. """ # use `quick` for cli if `full` is not enforced, # because the LaTeX code gen is usually discarded in CLI. if cli is True: if not full: quick = True if full is True: quick = False system = System() system.prepare(quick=quick, incremental=incremental) if cli is True: return 0 else: return system
def prepare(quick=False, **kwargs): t0, _ = elapsed() logger.info('Numeric code preparation started...') system = System() system.prepare(quick=quick) _, s = elapsed(t0) logger.info(f'Successfully generated numerical code in {s}.') return True
def prepare(quick=False, incremental=False, models=None, precompile=False, nomp=False, **kwargs): """ Run code generation. Parameters ---------- full : bool True to run full prep with formatted equations. Useful in interactive mode and during document generation. ncpu : int Number of cores to be used for parallel processing. cli : bool True to indicate running from CLI. It will set `quick` to True if not `full`. precompile : bool True to compile model function calls after code generation. Warnings -------- The default behavior has changed since v1.0.8: when `cli` is `True` and `full` is not `True`, quick code generation will be used. Returns ------- System object if `cli` is `False`; exit_code 0 otherwise. """ # use `quick` for cli if `full` is not enforced, # because the LaTeX code gen is usually discarded in CLI. cli = kwargs.get("cli", False) full = kwargs.get("full", False) ncpu = kwargs.get("ncpu", os.cpu_count()) if cli is True: if not full: quick = True if full is True: quick = False # run code generation system = System(options=kwargs, no_undill=True) system.prepare(quick=quick, incremental=incremental, models=models, nomp=nomp, ncpu=ncpu) # compile model function calls if precompile: system.precompile(models, nomp=nomp, ncpu=ncpu) if cli is True: return 0 else: return system
def prepare(quick=False, incremental=False, cli=False, **kwargs): """ Run code generation. Returns ------- System object """ t0, _ = elapsed() logger.info('Numeric code generation started...') system = System() system.prepare(quick=quick, incremental=incremental) _, s = elapsed(t0) logger.info(f'Successfully generated numerical code in {s}.') if cli is True: return 0 else: return system
""" This file is used to generate reStructuredText tables for Group and Model references """ import dill from andes.system import System dill.settings['recurse'] = True ss = System() ss.prepare() out = '' out += '.. _modelref:\n\n' out += '********************************************************************************\n' out += 'Model References\n' out += '********************************************************************************\n' out += '\n' for group in ss.groups.values(): out += group.doc_all(export='rest') with open('modelref.rst', 'w') as f: f.write(out)