• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

SPF-OST / trnsys-dck-parser / 8924908461

02 May 2024 01:43PM UTC coverage: 0.0%. First build
8924908461

Pull #1

github

web-flow
Merge bfe2a5bec into add13752b
Pull Request #1: Expressions

0 of 401 new or added lines in 9 files covered. (0.0%)

0 of 401 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/trnsys_dck_parser/build.py
NEW
1
import abc as _abc
×
NEW
2
import dataclasses as _dc
×
NEW
3
import typing as _tp
×
4

NEW
5
import trnsys_dck_parser.model.equations as _meqs
×
NEW
6
import trnsys_dck_parser.model.expression as _mexpr
×
NEW
7
import trnsys_dck_parser.parse.common as _pcom
×
NEW
8
import trnsys_dck_parser.parse.expression.parse as _pexpp
×
9

10

NEW
11
def create_equation(variable_name: str, rhs: str) -> _meqs.Equation:
×
NEW
12
    parse_result = parse_expression(rhs)
×
NEW
13
    equation = _pcom.success(parse_result).value
×
NEW
14
    return _meqs.Equation(variable_name, equation)
×
15

16

NEW
17
def create_literal(number: _mexpr.Number) -> _mexpr.Literal:
×
NEW
18
    return _mexpr.Literal(number)
×
19

20

NEW
21
def create_variable(variable: str) -> _mexpr.Variable:
×
NEW
22
    return _mexpr.Variable(variable)
×
23

24

NEW
25
def create_variables(variables: str) -> _tp.Sequence[_mexpr.Variable]:
×
NEW
26
    return [_mexpr.Variable(v) for v in variables.split()]
×
27

28

NEW
29
@_dc.dataclass(eq=True)
×
NEW
30
class FunctionBase(_abc.ABC):
×
NEW
31
    name: str
×
32

NEW
33
    def _call(self, *arguments: _mexpr.Expression) -> _mexpr.Expression:
×
NEW
34
        return _mexpr.FunctionCall(self.name, list(arguments))
×
35

36

NEW
37
class UnaryFunction(FunctionBase, _abc.ABC):
×
NEW
38
    def __call__(self, x: _mexpr.Expression):
×
NEW
39
        return self._call(x)
×
40

41

NEW
42
sin = UnaryFunction("SIN")
×
NEW
43
cos = UnaryFunction("COS")
×
44

45

NEW
46
def parse_expression(expression: str) -> _pexpp.ParseResult:
×
NEW
47
    parser = _pexpp.Parser(expression)
×
NEW
48
    return parser.parse()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc