forked from facebook/Ax
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_analysis.py
More file actions
64 lines (58 loc) · 2.26 KB
/
test_analysis.py
File metadata and controls
64 lines (58 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env python3
# Copyright (c) Meta Platforms, Inc. and affiliates.
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
# pyre-strict
from ax.analysis.analysis import (
AnalysisE,
error_card_from_analysis_e,
NOT_APPLICABLE_STATE_SUBTITLE,
)
from ax.analysis.plotly.parallel_coordinates import ParallelCoordinatesPlot
from ax.core.analysis_card import ErrorAnalysisCard, NotApplicableStateAnalysisCard
from ax.exceptions.analysis import AnalysisNotApplicableStateError
from ax.utils.common.testutils import TestCase
class AnalysisTest(TestCase):
def test_error_card_from_analysis_e(self) -> None:
for (
exception,
expected_card_type,
expected_title,
expected_subtitle,
expected_blob,
) in (
(
ValueError("something went wrong"),
ErrorAnalysisCard,
"ParallelCoordinatesPlot Error",
"ValueError: something went wrong",
"ValueError",
),
(
ValueError(),
ErrorAnalysisCard,
"ParallelCoordinatesPlot Error",
"ValueError encountered while computing ParallelCoordinatesPlot.",
"ValueError",
),
(
AnalysisNotApplicableStateError("Experiment has no data."),
NotApplicableStateAnalysisCard,
"ParallelCoordinatesPlot -- Not Available Yet",
NOT_APPLICABLE_STATE_SUBTITLE,
"Experiment has no data.",
),
):
with self.subTest(exception=exception):
analysis_e = AnalysisE(
message="test",
exception=exception,
analysis=ParallelCoordinatesPlot(),
)
card = error_card_from_analysis_e(analysis_e)
self.assertIsInstance(card, expected_card_type)
self.assertEqual(card.name, "ParallelCoordinatesPlot")
self.assertEqual(card.title, expected_title)
self.assertEqual(card.subtitle, expected_subtitle)
self.assertIn(expected_blob, card.blob)