snowdrop.src.misc package

Submodules

snowdrop.src.misc.display module

Display content of a model file.

snowdrop.src.misc.display.model_to_html(filename)[source]

Display model file.

param filename:

Path to model file

type filename:

str.

returns:

HTML representation of model file

snowdrop.src.misc.info module

Prints model object in pdf file format.

snowdrop.src.misc.info.print_model(model_name, fout)[source]

Create PDF from .tex file.

Parameters:
model_namestr

Name of model file

foutstr

Outtput file path

Returns:

None.

snowdrop.src.misc.latex module

class snowdrop.src.misc.latex.Apply(variables, fun)[source]

Bases: ExprVisitor

visit_Variable(tvar)[source]
class snowdrop.src.misc.latex.ExprTransformer(variables)[source]

Bases: NodeTransformer

visit_Call(call)[source]
visit_Name(cname)[source]
class snowdrop.src.misc.latex.ExprVisitor(variables)[source]

Bases: NodeVisitor

visit_Call(call)[source]
visit_Name(cname)[source]
visit_RCall(call)[source]
visit_RName(name)[source]
class snowdrop.src.misc.latex.LatexVisitor(variables)[source]

Bases: ExprVisitor

generic_prec(n)[source]
generic_visit(n)[source]

Called if no explicit visitor function exists for a node.

prec(n)[source]
prec_Add(n)[source]
prec_BinOp(n)[source]
prec_Call(n)[source]
prec_Div(n)[source]
prec_FloorDiv(n)[source]
prec_Invert(n)[source]
prec_Mod(n)[source]
prec_Mult(n)[source]
prec_Name(n)[source]
prec_Not(n)[source]
prec_Num(n)[source]
prec_Pow(n)[source]
prec_RCall(n)[source]
prec_RName(n)[source]
prec_Sub(n)[source]
prec_UAdd(n)[source]
prec_USub(n)[source]
prec_UnaryOp(n)[source]
visit_Add(n)[source]
visit_BinOp(n)[source]
visit_BitAnd(n)[source]
visit_BitOr(n)[source]
visit_BitXor(n)[source]
visit_Invert(n)[source]
visit_LShift(n)[source]
visit_Mod(n)[source]
visit_Mult(n)[source]
visit_Not(n)[source]
visit_Num(n)[source]
visit_RCall(n)[source]
visit_RName(n)[source]
visit_RShift(n)[source]
visit_Sub(n)[source]
visit_UAdd(n)[source]
visit_USub(n)[source]
visit_UnaryOp(n)[source]
visit_Variable(tvar)[source]
class snowdrop.src.misc.latex.TimeShift(variables, shift)[source]

Bases: ExprVisitor

visit_Variable(tvar)[source]
snowdrop.src.misc.latex.eq2tex(variables, s)[source]
snowdrop.src.misc.latex.expr2tex(variables, s)[source]
snowdrop.src.misc.latex.greekify(expr)[source]
snowdrop.src.misc.latex.name_to_latex(name, date=None)[source]
snowdrop.src.misc.latex.parse(s)[source]
snowdrop.src.misc.latex.split_name_into_parts(a)[source]

snowdrop.src.misc.linter module

Set of utilities to check correctness of model file syntax.

exception snowdrop.src.misc.linter.ModelException[source]

Bases: Exception

Model exception class.

type = 'error'
snowdrop.src.misc.linter.check_all(data)[source]

Check correctness of model file.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_calibration(data)[source]

Check correctness of model calibration.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_definitions(data)[source]

Check correctness of model definitions.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_equations(data)[source]

Check correctness of model equations.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_extra_symbols(data)[source]

Check extra variables declaration.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_infos(data)[source]

Check model info.

Parameters:
param data:

Model info.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.check_symbol_validity(s)[source]

Check symbol validity.

Parameters:
param s:

Symbol

type s:

str.

returns:

snowdrop.src.misc.linter.check_symbols(data)[source]

Check model symbols validity.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

Can raise three types of exceptions:
  • unknown symbol

  • invalid symbol

  • already declared

snowdrop.src.misc.linter.check_variables(data)[source]

Check number of endogenous variables.

Parameters:
param data:

Model content.

type data:

Dictionary.

returns:

List of exceptions if any.

snowdrop.src.misc.linter.human_format(err)[source]

Highlights exceptions represntation by red color if it is an error and by yellow color if it is warning..

Parameters:
param err:

Error.

type err:

ModelException.

returns:

snowdrop.src.misc.linter.lint(txt, source='<string>', format='human')[source]

Convert model file text to Python objects. Check syntax of model file for any errors.

Parameters:
param txt:

Model file content.

type txt:

str.

param source:

Source type.

type source:

str.

param format:

Format of exceptions display.

type format:

str.

returns:

Exceptions if any, otherwise a ruamel.yaml object.

snowdrop.src.misc.termcolor module

ANSII Color formatting for output in terminal.

snowdrop.src.misc.termcolor.colored(text, color=None, on_color=None, attrs=None)[source]

Colorize text.

Available text colors:

red, green, yellow, blue, magenta, cyan, white.

Available text highlights:

on_red, on_green, on_yellow, on_blue, on_magenta, on_cyan, on_white.

Available attributes:

bold, dark, underline, blink, reverse, concealed.

Example:

colored(‘Hello, World!’, ‘red’, ‘on_grey’, [‘blue’, ‘blink’]) colored(‘Hello, World!’, ‘green’)

snowdrop.src.misc.termcolor.cprint(text, color=None, on_color=None, attrs=None, **kwargs)[source]

Print colorize text.

It accepts arguments of print function.

snowdrop.src.misc.text2latex module

Simple Text to Latex converter.

snowdrop.src.misc.text2latex.fill_document(doc, name, fname, paragraphs, elements)[source]

Add a section, a subsection and some text to the document.

Parameters:

doc (pylatex.document.Document instance) – the document

snowdrop.src.misc.text2latex.getDocElements(model)[source]

Get document elements.

Args:

model : Model object.

snowdrop.src.misc.text2latex.getLatexDocument(model)[source]

Convert text to latex format.

Args:

model : Model object.

snowdrop.src.misc.text2latex.saveDocument(model)[source]

Save model document.

Module contents