/
testPrecisionFormatter.py
30 lines (22 loc) · 1.13 KB
/
testPrecisionFormatter.py
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
import unittest
import pygsti
# ppt format ommitted because the string it produces isn't necessarily in the correct order
# -> if latex and html pass, it will likely pass as well
# text formatting has also been ommitted, since providing it with a precision has no effect
from ..testutils import BaseTestCase, compare_files, temp_files
from .testFormatter import FormatterBaseTestCase
class PrecisionTest(FormatterBaseTestCase):
def setUp(self):
super(PrecisionTest, self).setUp()
headings = [self.arbitraryNum]
formatters = ['Normal']
self.table = pygsti.report.table.ReportTable(headings, formatters)
def test_precision_formatting(self):
# Precise first
for fmt in ['html', 'latex']: # text format ommitted - it doesn't care about precision :)
self.assertEqual(self.precise[fmt], self.table.render(fmt, precision=6, polarprecision=3)[fmt])
# Imprecise second
for fmt in ['html', 'latex']:
self.assertEqual(self.imprecise[fmt], self.table.render(fmt, precision=2, polarprecision=3)[fmt])
if __name__ == '__main__':
unittest.main(verbosity=2)