Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use raw strings for latex backslash espace sequences #182

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 18 additions & 18 deletions uncertainties/test_uncertainties.py
Original file line number Diff line number Diff line change
Expand Up @@ -1704,10 +1704,10 @@ def test_format():
(1234.56789, 0.1): {
'eL': r'\left(1.23457 \pm 0.00010\right) \times 10^{3}',
'EL': r'\left(1.23457 \pm 0.00010\right) \times 10^{3}',
'fL': '1234.57 \pm 0.10',
'FL': '1234.57 \pm 0.10',
'fL': '1234.57 \pm 0.10',
'FL': '1234.57 \pm 0.10',
'fL': r'1234.57 \pm 0.10',
'FL': r'1234.57 \pm 0.10',
'fL': r'1234.57 \pm 0.10',
'FL': r'1234.57 \pm 0.10',
'%L': r'\left(123457 \pm 10\right) \%'
},
#
Expand Down Expand Up @@ -1747,7 +1747,7 @@ def test_format():
'15GS': ' -1.2(%s)E-12' % NaN_EFG,
'SL': r'-1.2(\mathrm{nan}) \times 10^{-12}', # LaTeX NaN
# Pretty-print priority, but not for NaN:
'PSL': u'-1.2(\mathrm{nan})×10⁻¹²',
'PSL': r'-1.2(\mathrm{nan})×10⁻¹²',
'L': r'\left(-1.2 \pm \mathrm{nan}\right) \times 10^{-12}',
# Uppercase NaN and LaTeX:
'.1EL': (r'\left(-1.2 \pm \mathrm{%s}\right) \times 10^{-12}'
Expand Down Expand Up @@ -1826,8 +1826,8 @@ def test_format():
# Default precision = 6
'eL': r'\left(1.234568 \pm 0\right) \times 10^{3}',
'EL': r'\left(1.234568 \pm 0\right) \times 10^{3}',
'fL': '1234.567890 \pm 0',
'FL': '1234.567890 \pm 0',
'fL': r'1234.567890 \pm 0',
'FL': r'1234.567890 \pm 0',
'%L': r'\left(123456.789000 \pm 0\right) \%'
},

Expand Down Expand Up @@ -1992,9 +1992,9 @@ def test_format():
# options:
(float('-inf'), float('inf')): {
'S': '-inf(inf)',
'LS': '-\infty(\infty)',
'L': '-\infty \pm \infty',
'LP': u'-\infty±\infty',
'LS': r'-\infty(\infty)',
'L': r'-\infty \pm \infty',
'LP': r'-\infty±\infty',
# The following is consistent with Python's own
# formatting, which depends on the version of Python:
# formatting float("-inf") with format(..., "020") gives
Expand All @@ -2018,9 +2018,9 @@ def test_format():
},
(-float('nan'), float('inf')): {
'S': 'nan(inf)',
'LS': '\mathrm{nan}(\infty)',
'L': '\mathrm{nan} \pm \infty',
'LP': u'\mathrm{nan}±\infty'
'LS': r'\mathrm{nan}(\infty)',
'L': r'\mathrm{nan} \pm \infty',
'LP': r'\mathrm{nan}±\infty'
},

# Leading zeroes in the shorthand notation:
Expand Down Expand Up @@ -2140,7 +2140,7 @@ def test_custom_pretty_print_and_latex():
PREV_CUSTOMIZATIONS = {
var: getattr(uncert_core, var).copy()
for var in ['PM_SYMBOLS', 'MULT_SYMBOLS', 'GROUP_SYMBOLS']}

# Customizations:
for format in ["pretty-print", "latex"]:
uncert_core.PM_SYMBOLS[format] = u" ± "
Expand Down Expand Up @@ -2196,7 +2196,7 @@ def arrays_close(m1, m2, precision=1e-4):
if not numbers_close(elmt1.std_dev,
elmt2.std_dev, precision):
return False

return True


Expand Down Expand Up @@ -2350,10 +2350,10 @@ def test_correlated_values():

for (variable, nom_value, variance) in zip(
variables, nom_values, cov.diagonal()):

assert numbers_close(variable.n, nom_value)
assert numbers_close(variable.s**2, variance)
assert numbers_close(variable.s**2, variance)

assert arrays_close(
cov,
numpy.array(uncert_core.covariance_matrix(variables)))
Expand Down