Skip to content

BUG: Fixes module data docstrings. - #17373

Merged
charris merged 5 commits into
numpy:masterfrom
melissawm:f2py-print
Sep 27, 2020
Merged

charris merged 5 commits into
numpy:masterfrom
melissawm:f2py-print

Conversation

@melissawm

@melissawm melissawm commented Sep 24, 2020 •

Copy link
Copy Markdown
Member

Improves printing of module data items, showing proper information via the module docstring.

Fixes #15325 and #15308

Comment thread numpy/f2py/src/fortranobject.c
@melissawm

Copy link
Copy Markdown
Member Author

Testing with CI, I noticed

    @pytest.mark.skipif(sys.platform=='win32',
                        reason='Fails with MinGW64 Gfortran (Issue #9673)')
    @pytest.mark.xfail(IS_PYPY,
                       reason="PyPy cannot modify tp_doc after PyType_Ready")

were necessary to get the new test to run - but I'm not really sure if those are the right messages, as I'm not familiar with either PyPy or Windows. From #9673 and test_block_docstring.py it looks like those are appropriate.

@melissawm
melissawm marked this pull request as ready for review September 24, 2020 19:14
Comment thread numpy/f2py/src/fortranobject.c Outdated

if (def.data == NULL) {
n = format_def(p, size, def) == -1;
n = format_def(p, size, def);// == -1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Might as well remove the comparison as comment it out.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, that was supposed to go when I took the PR out of draft. Done!

Comment thread numpy/f2py/tests/test_module_doc.py Outdated
@pytest.mark.xfail(IS_PYPY,
reason="PyPy cannot modify tp_doc after PyType_Ready")
def test_module_docstring(self):
expected = "i : 'i'-scalar\nx : 'i'-array(4)\na : 'f'-array(2,3)\nb : 'f'-array(-1,-1), not allocated\x00\nfoo()\n\nWrapper for ``foo``.\n\n"

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be a good use of textwrap.dedent('"""...""")

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion, I was not familiar with that :)

@charris
charris merged commit 82226d8 into numpy:master Sep 27, 2020
@charris

charris commented Sep 27, 2020

Copy link
Copy Markdown
Member

Thanks Melissa.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

BUG: f2py does not report names of module data items

4 participants