-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathtest_utils.py
More file actions
78 lines (61 loc) · 2.77 KB
/
Copy pathtest_utils.py
File metadata and controls
78 lines (61 loc) · 2.77 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
from autoconf import conf
from autoarray.plot.utils import _arcsec_labels
def test_arcsec_labels_default_suffix_format():
ticks = conf.instance["visualize"]["general"]["ticks"]
original = ticks.get("symbol_over_decimal", False)
try:
ticks["symbol_over_decimal"] = False
assert _arcsec_labels([-1.0, 0.0, 1.0]) == ['-1"', '0"', '1"']
assert _arcsec_labels([3.8]) == ['3.8"']
finally:
ticks["symbol_over_decimal"] = original
def test_arcsec_labels_symbol_over_decimal():
ticks = conf.instance["visualize"]["general"]["ticks"]
original = ticks.get("symbol_over_decimal", False)
try:
ticks["symbol_over_decimal"] = True
assert _arcsec_labels([-1.69, 0.13, 1.95]) == [
"-1.″69",
"0.″13",
"1.″95",
]
assert _arcsec_labels([3.0]) == ["3″"]
# Mixed whole-number and decimal ticks: the whole-number tick gains a
# single decimal so it reads as 2.″0 rather than a bare 2″.
assert _arcsec_labels([-2.1, -0.044, 2.0]) == [
"-2.″1",
"-0.″044",
"2.″0",
]
finally:
ticks["symbol_over_decimal"] = original
def test_arcsec_labels_mixed_integer_and_decimal_default():
ticks = conf.instance["visualize"]["general"]["ticks"]
original = ticks.get("symbol_over_decimal", False)
try:
ticks["symbol_over_decimal"] = False
# All-integer sets stay integer; a mixed set pads the whole number.
assert _arcsec_labels([-1.0, 0.0, 1.0]) == ['-1"', '0"', '1"']
assert _arcsec_labels([-2.1, -0.044, 2.0]) == ['-2.1"', '-0.044"', '2.0"']
finally:
ticks["symbol_over_decimal"] = original
def test_arcsec_labels_minus_in_math():
ticks = conf.instance["visualize"]["general"]["ticks"]
original_symbol = ticks.get("symbol_over_decimal", False)
original_minus = ticks.get("minus_in_math", False)
try:
ticks["minus_in_math"] = True
# Suffix format: the ASCII hyphen (U+002D) becomes the math minus (U+2212).
ticks["symbol_over_decimal"] = False
assert _arcsec_labels([-2.1, -0.044, 2.0]) == ["−2.1\"", "−0.044\"", "2.0\""]
# Symbol-over-decimal format also uses the math minus.
ticks["symbol_over_decimal"] = True
assert _arcsec_labels([-2.1, -0.044, 2.0]) == ["−2.″1", "−0.″044", "2.″0"]
# Positive-only tick sets are unchanged.
assert _arcsec_labels([0.13, 1.95]) == ["0.″13", "1.″95"]
# The emitted minus really is U+2212, not the ASCII hyphen U+002D.
label = _arcsec_labels([-0.5])[0]
assert "−" in label and "-" not in label
finally:
ticks["symbol_over_decimal"] = original_symbol
ticks["minus_in_math"] = original_minus