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

zincware / MDSuite / 3999396905

pending completion
3999396905

push

github-actions

GitHub
[merge before other PRs] ruff updates (#580)

960 of 1311 branches covered (73.23%)

Branch coverage included in aggregate %.

15 of 15 new or added lines in 11 files covered. (100.0%)

4034 of 4930 relevant lines covered (81.83%)

3.19 hits per line

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

75.0
/mdsuite/utils/testing.py
1
"""
2
MDSuite: A Zincwarecode package.
3

4
License
5
-------
6
This program and the accompanying materials are made available under the terms
7
of the Eclipse Public License v2.0 which accompanies this distribution, and is
8
available at https://www.eclipse.org/legal/epl-v20.html
9

10
SPDX-License-Identifier: EPL-2.0
11

12
Copyright Contributors to the Zincwarecode Project.
13

14
Contact Information
15
-------------------
16
email: zincwarecode@gmail.com
17
github: https://github.com/zincware
18
web: https://zincwarecode.com/
19

20
Citation
21
--------
22
If you use this module please cite us with:
23

24
Summary
25
-------
26
"""
27
import multiprocessing
4✔
28
import traceback
4✔
29

30
import numpy as np
4✔
31
import tensorflow as tf
4✔
32

33

34
def assertDeepAlmostEqual(expected, actual, *args, **kwargs):
4✔
35
    """
36
    Assert that two complex structures have almost equal contents.
37
    Compares lists, dicts and tuples recursively. Checks numeric values
38
    using test_case's :py:meth:`unittest.TestCase.assertAlmostEqual` and
39
    checks all other values with :py:meth:`unittest.TestCase.assertEqual`.
40
    Accepts additional positional and keyword arguments and pass those
41
    intact to assertAlmostEqual() (that's how you specify comparison
42
    precision).
43

44
    Parameters
45
    ----------
46
    decimal: int
47
        The desired positional precision.
48
        See numpy.testing.assert_array_almost_equal for keyword arguments
49

50
    References
51
    ----------
52
    https://github.com/larsbutler/oq-engine/blob/master/tests/utils/helpers.py
53

54
    """
55
    if isinstance(expected, (int, float, complex, np.ndarray, list, tf.Tensor)):
4✔
56
        np.testing.assert_array_almost_equal(expected, actual, *args, **kwargs)
4✔
57
    elif isinstance(expected, dict):
4!
58
        assert set(expected) == set(actual)
4✔
59
        for key in expected:
4✔
60
            assertDeepAlmostEqual(expected[key], actual[key], *args, **kwargs)
4✔
61
    else:
62
        assert expected == actual
×
63

64

65
class MDSuiteProcess(multiprocessing.Process):
4✔
66
    """Process class for use in ZnVis testing."""
67

68
    def __init__(self, *args, **kwargs):
4✔
69
        """Multiprocessing class constructor."""
70
        super(MDSuiteProcess, self).__init__(*args, **kwargs)
4✔
71
        self._pconn, self._cconn = multiprocessing.Pipe()
4✔
72
        self._exception = None
4✔
73

74
    def run(self):
4✔
75
        """Run the process and catch exceptions."""
76
        try:
×
77
            multiprocessing.Process.run(self)
×
78
            self._cconn.send(None)
×
79
        except Exception as e:
×
80
            tb = traceback.format_exc()
×
81
            self._cconn.send((e, tb))
×
82

83
    @property
4✔
84
    def exception(self):
3✔
85
        """Exception property to be stored by the process."""
86
        if self._pconn.poll():
4!
87
            self._exception = self._pconn.recv()
4✔
88
        return self._exception
4✔
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