MCPcopy Index your code
hub / github.com/ipython/ipython / test_precision

Function test_precision

tests/test_formatters.py:108–133  ·  view source on GitHub ↗

test various values for float_precision.

()

Source from the content-addressed store, hash-verified

106
107
108def test_precision():
109 """test various values for float_precision."""
110 f = PlainTextFormatter()
111 assert f(pi) == repr(pi)
112 f.float_precision = 0
113 if numpy:
114 po = numpy.get_printoptions()
115 assert po["precision"] == 0
116 assert f(pi) == "3"
117 f.float_precision = 2
118 if numpy:
119 po = numpy.get_printoptions()
120 assert po["precision"] == 2
121 assert f(pi) == "3.14"
122 f.float_precision = "%g"
123 if numpy:
124 po = numpy.get_printoptions()
125 assert po["precision"] == 2
126 assert f(pi) == "3.14159"
127 f.float_precision = "%e"
128 assert f(pi) == "3.141593e+00"
129 f.float_precision = ""
130 if numpy:
131 po = numpy.get_printoptions()
132 assert po["precision"] == 8
133 assert f(pi) == repr(pi)
134
135
136def test_bad_precision():

Callers

nothing calls this directly

Calls 2

PlainTextFormatterClass · 0.90
fFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…