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

WassimTenachi / PhySO / #15

10 Jun 2024 12:47AM UTC coverage: 80.984% (+28.9%) from 52.052%
#15

push

coveralls-python

WassimTenachi
monitoring test

26 of 27 new or added lines in 1 file covered. (96.3%)

131 existing lines in 18 files now uncovered.

6814 of 8414 relevant lines covered (80.98%)

0.81 hits per line

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

96.3
/physo/learn/tests/monitoring_UnitTest.py
1
import os
1✔
2

3
import numpy as np
1✔
4
import matplotlib.pyplot as plt
1✔
5
import torch
1✔
6
import warnings
1✔
7
# Internal code import
8
import physo
1✔
9
import physo.learn.monitoring as monitoring
1✔
10

11
import unittest
1✔
12

13
class MonitoringTest(unittest.TestCase):
1✔
14
    def test_monitoring(self):
1✔
15

16
        run_logger = lambda : monitoring.RunLogger(
1✔
17
                                      save_path = 'delete_test_monitoring.log',
18
                                      do_save   = True)
19
        run_visualiser = lambda : monitoring.RunVisualiser (
1✔
20
                                      epoch_refresh_rate = 1,
21
                                      save_path = 'delete_test_monitoring.png',
22
                                      do_show   = False,
23
                                      do_prints = True,
24
                                      do_save   = True, )
25

26
        # Seed
27
        seed = 0
1✔
28
        np.random.seed(seed)
1✔
29
        torch.manual_seed(seed)
1✔
30

31
        # Dataset
32
        z = np.random.uniform(-10, 10, 50)
1✔
33
        v = np.random.uniform(-10, 10, 50)
1✔
34
        X = np.stack((z, v), axis=0)
1✔
35
        y = 1.234*9.807*z + 1.234*v**2
1✔
36

37
        # Running SR task
38
        expression, logs = physo.SR(X, y,
1✔
39
                                    # Giving names of variables (for display purposes)
40
                                    X_names = [ "z"       , "v"        ],
41
                                    # Giving units of input variables
42
                                    X_units = [ [1, 0, 0] , [1, -1, 0] ],
43
                                    # Giving name of root variable (for display purposes)
44
                                    y_name  = "E",
45
                                    # Giving units of the root variable
46
                                    y_units = [2, -2, 1],
47
                                    # Fixed constants
48
                                    fixed_consts       = [ 1.      ],
49
                                    # Units of fixed constants
50
                                    fixed_consts_units = [ [0,0,0] ],
51
                                    # Free constants names (for display purposes)
52
                                    free_consts_names = [ "m"       , "g"        ],
53
                                    # Units of free constants
54
                                    free_consts_units = [ [0, 0, 1] , [1, -2, 0] ],
55
                                    # Run config
56
                                    run_config = physo.config.config0.config0,
57

58
                                    # FOR TESTING
59
                                    get_run_logger     = run_logger,
60
                                    get_run_visualiser = run_visualiser,
61
                                    parallel_mode=False,
62
                                    epochs = 5,
63
        )
64

65
        # Inspecting pareto front expressions
66
        pareto_front_complexities, pareto_front_expressions, pareto_front_r, pareto_front_rmse = logs.get_pareto_front()
1✔
67

68
        # Deleting files made by the test
69
        for fname in os.listdir():
1✔
70
            if fname.startswith("delete_test_monitoring"):
1✔
71
                os.remove(fname)
1✔
72

73
        return None
1✔
74

75

76
if __name__ == '__main__':
1✔
NEW
77
    unittest.main()
×
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