Skip to content

Fix the parameter sections of L2TransformedFunctional docstrings - #5572

Draft
mmporong wants to merge 2 commits into
firedrakeproject:releasefrom
mmporong:docs-l2transformedfunctional-params
Draft

mmporong wants to merge 2 commits into
firedrakeproject:releasefrom
mmporong:docs-l2transformedfunctional-params

Conversation

@mmporong

Copy link
Copy Markdown

Description

The docstrings of L2TransformedFunctional.__call__ and L2TransformedFunctional.derivative in firedrake/adjoint/transformed_functional.py had two problems in their Parameters sections:

  • The underline under Parameters had nine dashes, one fewer than the heading. numpydoc does not read a section with a short underline: it warns "potentially wrong underline length" and returns no parameters for either method.
  • The entries named the arguments value and adj_value, but the methods take values and adj_input.

This fixes both underlines and both names. The adj_input entry now also says what the code checks: only the default value 1 is supported, and other values raise NotImplementedError.

I found the adj_value entry by comparing the documented parameter names with the method signatures, and the other two problems while reading the same docstrings. Checks:

  • numpydoc NumpyDocString on both docstrings: before, no parameters and the underline warning; after, ['values'] and ['adj_input', 'apply_riesz'], the same as the signatures.
  • python -m flake8 firedrake/adjoint/transformed_functional.py passes with the repository's setup.cfg.

Only docstrings change. I did not run the test suite, since no code changes.

AI assistance: this PR was written with Claude Code (Claude Opus 5.5). I can't add labels to this repository, so could a maintainer please apply the LLM used label?

@leo-collins leo-collins left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This is fine pending my comment. Thanks for catching this!

Comment on lines +377 to +378
Only the default value 1 is supported. Other values raise
``NotImplementedError``.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Can this also explain what adj_input actually does?

@leo-collins

Copy link
Copy Markdown
Contributor

ACtually I think this should be merged into the release branch, can you rebase and target that branch?

The Parameters underline in L2TransformedFunctional.__call__ and
L2TransformedFunctional.derivative was one dash short, so numpydoc did not
read the section. The entries also named the arguments value and
adj_value, while the methods take values and adj_input.
@mmporong
mmporong changed the base branch from main to release October 30, 2026 13:35
@mmporong
mmporong force-pushed the docs-l2transformedfunctional-params branch from 1df8a93 to be5ca57 Compare October 30, 2026 13:35
@mmporong

Copy link
Copy Markdown
Author

I rebased onto release and updated the target branch. I also added an explanation of adj_input.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants