Show only the necessary decimals

This commit is contained in:
Alexander Hess 2020-10-28 16:57:48 +01:00
commit ca9df9e440
Signed by: alexander
GPG key ID: 344EA5AB10D868E0
6 changed files with 152 additions and 150 deletions

View file

@ -77,7 +77,7 @@
" raise ValueError(\"a vector must have at least one entry\")\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(f\"{x:.3f}\" for x in self._entries)\n",
" args = \", \".join(repr(x) for x in self._entries)\n",
" return f\"Vector(({args}))\"\n",
"\n",
" def __len__(self):\n",
@ -762,7 +762,7 @@
" # ...\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(\"(\" + \", \".join(f\"{c:.3f}\" for c in r) + \",)\" for r in self._entries)\n",
" args = \", \".join(\"(\" + \", \".join(repr(c) for c in r) + \",)\" for r in self._entries)\n",
" return f\"Matrix(({args}))\"\n",
"\n",
" @property\n",
@ -825,7 +825,7 @@
" # ...\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(f\"{x:.3f}\" for x in self)\n",
" args = \", \".join(repr(x) for x in self)\n",
" return f\"Vector(({args}))\"\n",
"\n",
" def __iter__(self):\n",
@ -860,7 +860,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 2.000, 3.000,), (4.000, 5.000, 6.000,), (7.000, 8.000, 9.000,)))"
"Matrix(((1.0, 2.0, 3.0,), (4.0, 5.0, 6.0,), (7.0, 8.0, 9.0,)))"
]
},
"execution_count": 25,
@ -951,7 +951,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Vector((1.000, 2.000, 3.000)) Vector((4.000, 5.000, 6.000)) Vector((7.000, 8.000, 9.000)) "
"Vector((1.0, 2.0, 3.0)) Vector((4.0, 5.0, 6.0)) Vector((7.0, 8.0, 9.0)) "
]
}
],
@ -973,7 +973,7 @@
"name": "stdout",
"output_type": "stream",
"text": [
"Vector((1.000, 4.000, 7.000)) Vector((2.000, 5.000, 8.000)) Vector((3.000, 6.000, 9.000)) "
"Vector((1.0, 4.0, 7.0)) Vector((2.0, 5.0, 8.0)) Vector((3.0, 6.0, 9.0)) "
]
}
],
@ -1069,7 +1069,7 @@
" # ...\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(\"(\" + \", \".join(f\"{c:.3f}\" for c in r) + \",)\" for r in self._entries)\n",
" args = \", \".join(\"(\" + \", \".join(repr(c) for c in r) + \",)\" for r in self._entries)\n",
" return f\"Matrix(({args}))\"\n",
"\n",
" def transpose(self):\n",
@ -1102,7 +1102,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 2.000, 3.000,), (4.000, 5.000, 6.000,), (7.000, 8.000, 9.000,)))"
"Matrix(((1.0, 2.0, 3.0,), (4.0, 5.0, 6.0,), (7.0, 8.0, 9.0,)))"
]
},
"execution_count": 34,
@ -1161,7 +1161,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 4.000, 7.000,), (2.000, 5.000, 8.000,), (3.000, 6.000, 9.000,)))"
"Matrix(((1.0, 4.0, 7.0,), (2.0, 5.0, 8.0,), (3.0, 6.0, 9.0,)))"
]
},
"execution_count": 36,
@ -1248,7 +1248,7 @@
" # ...\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(\"(\" + \", \".join(f\"{c:.3f}\" for c in r) + \",)\" for r in self._entries)\n",
" args = \", \".join(\"(\" + \", \".join(repr(c) for c in r) + \",)\" for r in self._entries)\n",
" return f\"Matrix(({args}))\"\n",
"\n",
" def __iter__(self): # adapted for brevity; uses parts of entries()\n",
@ -1285,7 +1285,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 2.000, 3.000,), (4.000, 5.000, 6.000,), (7.000, 8.000, 9.000,)))"
"Matrix(((1.0, 2.0, 3.0,), (4.0, 5.0, 6.0,), (7.0, 8.0, 9.0,)))"
]
},
"execution_count": 40,
@ -1333,7 +1333,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 4.000, 7.000,), (2.000, 5.000, 8.000,), (3.000, 6.000, 9.000,)))"
"Matrix(((1.0, 4.0, 7.0,), (2.0, 5.0, 8.0,), (3.0, 6.0, 9.0,)))"
]
},
"execution_count": 42,
@ -1357,7 +1357,7 @@
{
"data": {
"text/plain": [
"Matrix(((1.000, 4.000, 7.000,), (2.000, 5.000, 8.000,), (3.000, 6.000, 9.000,)))"
"Matrix(((1.0, 4.0, 7.0,), (2.0, 5.0, 8.0,), (3.0, 6.0, 9.0,)))"
]
},
"execution_count": 43,
@ -1434,7 +1434,7 @@
" # ...\n",
"\n",
" def __repr__(self):\n",
" args = \", \".join(f\"{x:.3f}\" for x in self)\n",
" args = \", \".join(repr(x) for x in self)\n",
" return f\"Vector(({args}))\"\n",
"\n",
" def __getitem__(self, index):\n",
@ -1472,7 +1472,7 @@
{
"data": {
"text/plain": [
"Vector((1.000, 2.000, 3.000))"
"Vector((1.0, 2.0, 3.0))"
]
},
"execution_count": 47,
@ -1520,7 +1520,7 @@
{
"data": {
"text/plain": [
"Vector((nan, 2.000, 3.000))"
"Vector((nan, 2.0, 3.0))"
]
},
"execution_count": 49,
@ -1557,7 +1557,7 @@
{
"data": {
"text/plain": [
"Vector((99.000, 2.000, 3.000))"
"Vector((99.0, 2.0, 3.0))"
]
},
"execution_count": 51,