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

quaquel / EMAworkbench / 18214982978

03 Oct 2025 06:39AM UTC coverage: 88.703% (+0.04%) from 88.664%
18214982978

Pull #422

github

web-flow
Merge fe026872f into 592d0cd98
Pull Request #422: ruff fixes

53 of 73 new or added lines in 16 files covered. (72.6%)

2 existing lines in 2 files now uncovered.

7852 of 8852 relevant lines covered (88.7%)

0.89 hits per line

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

94.12
/ema_workbench/util/ema_exceptions.py
1
"""Exceptions and warning used internally by the EMA workbench.
2

3
In line with advice given in `PEP 8 <https://www.python.org/dev/peps/pep-0008/>`_.
4
"""
5

6
# Created on 31 mei 2011
7
#
8
# .. codeauthor:: jhkwakkel <j.h.kwakkel (at) tudelft (dot) nl>
9

10
__all__ = ["EMAError", "EMAParallelError", "EMAWarning", "ExperimentError"]
1✔
11

12

13
class EMAError(BaseException):
1✔
14
    """Base EMA error."""
15

16
    def __init__(self, *args):
1✔
17
        self.args = args
1✔
18

19
    def __str__(self):
1✔
20
        """Return string representation of EMA error."""
21
        if len(self.args) == 1:
1✔
22
            return str(self.args[0])
1✔
23
        else:
24
            return str(self.args)
1✔
25

26
    def __repr__(self):
1✔
27
        """Return a repr. of EMA error."""
UNCOV
28
        return f"{self.__class__.__name__}(*{self.args!r})"
×
29

30

31
class EMAWarning(EMAError):  # noqa: N818
1✔
32
    """base EMA warning class."""
33

34

35
class ExperimentError(EMAError):
1✔
36
    """Error to be used when a particular experiment does not complete correctly.
37

38
    The character of the error can be specified as the message, and the actual experiment that
39
    gave rise to the error.
40

41
    """
42

43
    def __init__(self, message:str, experiment, policy=None):
1✔
44
        """Init."""
45
        self.message = message
1✔
46
        self.experiment = experiment
1✔
47
        self.args = (message, experiment)
1✔
48
        try:
1✔
49
            self.policy = policy.name
1✔
50
        except AttributeError:
1✔
51
            self.policy = "None"
1✔
52

53
    def __str__(self):  # noqa: D105
1✔
54
        keys = sorted(self.experiment.keys())
1✔
55

56
        c = ""
1✔
57
        for key in keys:
1✔
58
            value = self.experiment.get(key)
1✔
59
            c += key
1✔
60
            c += ":"
1✔
61
            c += str(value)
1✔
62
            c += ", "
1✔
63
        c += "policy:" + self.policy
1✔
64

65
        return self.message + " case: {" + c + "}"
1✔
66

67
    def __repr__(self):  # noqa: D105
1✔
68
        return f"{self.message} case: {self.case!r} "
×
69

70

71
class EMAParallelError(EMAError):
1✔
72
    """Parallel EMA error."""
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

© 2025 Coveralls, Inc