work around a change in python 3.13
* python/spot/__init__.py: Unindent the docstring for formula.__format__. Because Python 3.13 strips the indentation but previous version didn't, the following test case failed with Python 3.13. * tests/python/formulas.ipynb: Adjust to unindented docstring.
This commit is contained in:
parent
c971ce57a6
commit
461dc842e9
2 changed files with 69 additions and 64 deletions
|
|
@ -360,45 +360,50 @@ class formula:
|
||||||
raise ValueError("unknown string format: " + format)
|
raise ValueError("unknown string format: " + format)
|
||||||
|
|
||||||
def __format__(self, spec):
|
def __format__(self, spec):
|
||||||
|
# Some test case print this docstring, and different
|
||||||
|
# Python version will handled indentation differently.
|
||||||
|
# (Python versions before 3.13 don't strip indentation.)
|
||||||
|
# So we cannot indent this until Python 3.13 is thee
|
||||||
|
# smallest version we support.
|
||||||
"""Format the formula according to `spec`.
|
"""Format the formula according to `spec`.
|
||||||
|
|
||||||
Parameters
|
Parameters
|
||||||
----------
|
----------
|
||||||
spec : str, optional
|
spec : str, optional
|
||||||
a list of letters that specify how the formula
|
a list of letters that specify how the formula
|
||||||
should be formatted.
|
should be formatted.
|
||||||
|
|
||||||
Supported specifiers
|
Supported specifiers
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
- 'f': use Spot's syntax (default)
|
- 'f': use Spot's syntax (default)
|
||||||
- '8': use Spot's syntax in UTF-8 mode
|
- '8': use Spot's syntax in UTF-8 mode
|
||||||
- 's': use Spin's syntax
|
- 's': use Spin's syntax
|
||||||
- 'l': use LBT's syntax
|
- 'l': use LBT's syntax
|
||||||
- 'w': use Wring's syntax
|
- 'w': use Wring's syntax
|
||||||
- 'x': use LaTeX output
|
- 'x': use LaTeX output
|
||||||
- 'X': use self-contained LaTeX output
|
- 'X': use self-contained LaTeX output
|
||||||
- 'j': use self-contained LaTeX output, adjusted for MathJax
|
- 'j': use self-contained LaTeX output, adjusted for MathJax
|
||||||
|
|
||||||
Add some of those letters for additional options:
|
Add some of those letters for additional options:
|
||||||
|
|
||||||
- 'p': use full parentheses
|
- 'p': use full parentheses
|
||||||
- 'c': escape the formula for CSV output (this will
|
- 'c': escape the formula for CSV output (this will
|
||||||
enclose the formula in double quotes, and escape
|
enclose the formula in double quotes, and escape
|
||||||
any included double quotes)
|
any included double quotes)
|
||||||
- 'h': escape the formula for HTML output
|
- 'h': escape the formula for HTML output
|
||||||
- 'd': escape double quotes and backslash,
|
- 'd': escape double quotes and backslash,
|
||||||
for use in C-strings (the outermost double
|
for use in C-strings (the outermost double
|
||||||
quotes are *not* added)
|
quotes are *not* added)
|
||||||
- 'q': quote and escape for shell output, using single
|
- 'q': quote and escape for shell output, using single
|
||||||
quotes or double quotes depending on the contents.
|
quotes or double quotes depending on the contents.
|
||||||
- '[...]': rewrite away all the operators specified in brackets,
|
- '[...]': rewrite away all the operators specified in brackets,
|
||||||
using spot.unabbreviate().
|
using spot.unabbreviate().
|
||||||
|
|
||||||
- ':spec': pass the remaining specification to the
|
- ':spec': pass the remaining specification to the
|
||||||
formating function for strings.
|
formating function for strings.
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
syntax = 'f'
|
syntax = 'f'
|
||||||
parent = False
|
parent = False
|
||||||
|
|
|
||||||
|
|
@ -246,43 +246,43 @@
|
||||||
"text": [
|
"text": [
|
||||||
"Format the formula according to `spec`.\n",
|
"Format the formula according to `spec`.\n",
|
||||||
"\n",
|
"\n",
|
||||||
" Parameters\n",
|
"Parameters\n",
|
||||||
" ----------\n",
|
"----------\n",
|
||||||
" spec : str, optional\n",
|
"spec : str, optional\n",
|
||||||
" a list of letters that specify how the formula\n",
|
" a list of letters that specify how the formula\n",
|
||||||
" should be formatted.\n",
|
" should be formatted.\n",
|
||||||
"\n",
|
"\n",
|
||||||
" Supported specifiers\n",
|
"Supported specifiers\n",
|
||||||
" --------------------\n",
|
"--------------------\n",
|
||||||
"\n",
|
"\n",
|
||||||
" - 'f': use Spot's syntax (default)\n",
|
"- 'f': use Spot's syntax (default)\n",
|
||||||
" - '8': use Spot's syntax in UTF-8 mode\n",
|
"- '8': use Spot's syntax in UTF-8 mode\n",
|
||||||
" - 's': use Spin's syntax\n",
|
"- 's': use Spin's syntax\n",
|
||||||
" - 'l': use LBT's syntax\n",
|
"- 'l': use LBT's syntax\n",
|
||||||
" - 'w': use Wring's syntax\n",
|
"- 'w': use Wring's syntax\n",
|
||||||
" - 'x': use LaTeX output\n",
|
"- 'x': use LaTeX output\n",
|
||||||
" - 'X': use self-contained LaTeX output\n",
|
"- 'X': use self-contained LaTeX output\n",
|
||||||
" - 'j': use self-contained LaTeX output, adjusted for MathJax\n",
|
"- 'j': use self-contained LaTeX output, adjusted for MathJax\n",
|
||||||
"\n",
|
"\n",
|
||||||
" Add some of those letters for additional options:\n",
|
"Add some of those letters for additional options:\n",
|
||||||
"\n",
|
"\n",
|
||||||
" - 'p': use full parentheses\n",
|
"- 'p': use full parentheses\n",
|
||||||
" - 'c': escape the formula for CSV output (this will\n",
|
"- 'c': escape the formula for CSV output (this will\n",
|
||||||
" enclose the formula in double quotes, and escape\n",
|
" enclose the formula in double quotes, and escape\n",
|
||||||
" any included double quotes)\n",
|
" any included double quotes)\n",
|
||||||
" - 'h': escape the formula for HTML output\n",
|
"- 'h': escape the formula for HTML output\n",
|
||||||
" - 'd': escape double quotes and backslash,\n",
|
"- 'd': escape double quotes and backslash,\n",
|
||||||
" for use in C-strings (the outermost double\n",
|
" for use in C-strings (the outermost double\n",
|
||||||
" quotes are *not* added)\n",
|
" quotes are *not* added)\n",
|
||||||
" - 'q': quote and escape for shell output, using single\n",
|
"- 'q': quote and escape for shell output, using single\n",
|
||||||
" quotes or double quotes depending on the contents.\n",
|
" quotes or double quotes depending on the contents.\n",
|
||||||
" - '[...]': rewrite away all the operators specified in brackets,\n",
|
"- '[...]': rewrite away all the operators specified in brackets,\n",
|
||||||
" using spot.unabbreviate().\n",
|
" using spot.unabbreviate().\n",
|
||||||
"\n",
|
"\n",
|
||||||
" - ':spec': pass the remaining specification to the\n",
|
"- ':spec': pass the remaining specification to the\n",
|
||||||
" formating function for strings.\n",
|
" formating function for strings.\n",
|
||||||
"\n",
|
"\n",
|
||||||
" \n"
|
"\n"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|
@ -505,7 +505,7 @@
|
||||||
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
"<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"no\"?>\n",
|
||||||
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
"<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\"\n",
|
||||||
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\n",
|
||||||
"<!-- Generated by graphviz version 2.43.0 (0)\n",
|
"<!-- Generated by graphviz version 2.42.4 (0)\n",
|
||||||
" -->\n",
|
" -->\n",
|
||||||
"<!-- Title: G Pages: 1 -->\n",
|
"<!-- Title: G Pages: 1 -->\n",
|
||||||
"<svg width=\"343pt\" height=\"583pt\"\n",
|
"<svg width=\"343pt\" height=\"583pt\"\n",
|
||||||
|
|
@ -1056,7 +1056,7 @@
|
||||||
"name": "python",
|
"name": "python",
|
||||||
"nbconvert_exporter": "python",
|
"nbconvert_exporter": "python",
|
||||||
"pygments_lexer": "ipython3",
|
"pygments_lexer": "ipython3",
|
||||||
"version": "3.11.8"
|
"version": "3.12.7"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"nbformat": 4,
|
"nbformat": 4,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue