Skip to content

SimCBC object fails doctest because of formatting issues

The test_lsctables test target is failing because the (new) SimCBC object docstring is malformatted (at least for new versions of doctest):

$ git log -1 --oneline
a3c30e5a72 (HEAD -> refs/heads/master, refs/remotes/upstream/master, refs/remotes/upstream/HEAD) ligo/lw/ligolw.py:  adjust escape chars in doc
$ python setup.py build_ext --inplace 1>/dev/null
...
$ PYTHONPATH="$(pwd)" python test/test_lsctables.py
Traceback (most recent call last):
  File "/home/duncan/git/git.ligo.org/kipp.cannon/python-ligo-lw/test/test_lsctables.py", line 8, in <module>
    failures = doctest.testmod(lsctables)[0]
               ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 2004, in testmod
    for test in finder.find(m, name, globs=globs, extraglobs=extraglobs):
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 948, in find
    self._find(tests, obj, name, module, source_lines, globs, {})
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 1022, in _find
    self._find(tests, val, valname, module, source_lines,
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 1054, in _find
    self._find(tests, val, valname, module, source_lines,
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 1010, in _find
    test = self._get_test(obj, name, module, globs, source_lines)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 1092, in _get_test
    return self._parser.get_doctest(docstring, globs, name,
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 684, in get_doctest
    return DocTest(self.get_examples(string, name), globs,
                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 698, in get_examples
    return [x for x in self.parse(string, name)
                       ^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 660, in parse
    self._parse_example(m, name, lineno)
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 718, in _parse_example
    self._check_prompt_blank(source_lines, indent, name, lineno)
  File "/home/duncan/opt/conda/envs/py312/lib/python3.12/doctest.py", line 802, in _check_prompt_blank
    raise ValueError('line %r of the docstring for %s '
ValueError: line 3 of the docstring for ligo.lw.lsctables.SimCBCTable.RowType lacks blank after >>>: '>>>x = SimCBC()'