Repository navigation
Conversation
…ault values for parameters against the values in the function signature. Warnings are raised during the build for violations, to prevent blocking the build process.
…th default values have an ", optional" marker in the docstring.
…tercarlo to the main description. The type list must fit a single line for Numpydoc parsing, and this avoids a long line in the code.
… and flag unnoticed errors.
…ion. This avoids many false positives in the mismatch detection.
…ect to the function definition.
Collaborator
…nsistency across the library. This was complemented with minor fixes when required.
CozySocksAlways
self-requested a review
October 12, 2026 09:46
| # class name excludes its members. | ||
| defaults_ignore = [ | ||
| 'elephant.statistics.cv', # re-export of scipy.stats.variation | ||
| 'elephant.trials', # TODO: addressed in another PR |
Contributor
There was a problem hiding this comment.
Link to PR number?
| where ML parameter learning returns one or more zero private variances. | ||
| Default: 0.01 | ||
| (See Martin & McDonald, Psychometrika, Dec 1975.) | ||
| Default: 0.01 (see Martin & McDonald, Psychometrika, Dec 1975.) |
Contributor
There was a problem hiding this comment.
Add citation for this, maybe on PR 693
Contributor
Author
There was a problem hiding this comment.
Added to PR #693. It will have to be merged into master first to carry over the changes and avoid conflicts.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The optional arguments in Elephant functions should be clearly documented in the docstring text.
The style adopted in Elephant asks for identifying the argument as optional with an
, optionalafter the type list, and to include the default value defined in the function header as a last line starting withDefault:. In this line, trailing periods are not allowed to avoid errors if copying the value from the documentation page.Some inconsistencies were identified across the library, and to correct and prevent future errors, a custom Sphinx extension is being added to identify disagreements between the function declaration and the corresponding docstring.
The extension is added to
doc/_extasdefaults_validation.py.The following rules/behavior were defined:
Optional marker. The parameter type list must end with
, optional, with no space between the type list and the comma. The marker states that the caller may omit the argument, which is exactly what a signature default means. Parameter entries documented without type specifications are not checked.Default line present. The description block must contain a line that starts with
Default:followed by a space, matched case-sensitively.Default line last. The
Default:line must be the last non-empty line of the description block.No separate paragraph. A blank line must not precede the
Default:line, unless it closes an indented block or a list, wherereStructuredText requires it.
Default value correct. The text following
Default:must match the default expression from the signature, or start with it followed by parenthetical extra text. The comparison is exact and is made against a canonical rendering of the expression, not against its source text, so15*pq.msis documented asDefault: 15 * pq.msandspikes="random"asDefault: 'random'. An integer literal is rendered as it is written. A float literal keeps the notation of the signature, canonicalized by these forms:1.is documented asDefault: 1.0and.5asDefault: 0.5.1E-5is documented asDefault: 1e-5and1e3asDefault: 1e3.+sign and no leading zero, so1e+05is documented asDefault: 1e5..and no trailing.0, so1.e-3and1.0e-3are both documented asDefault: 1e-3, while1.5e-3keeps its fractional digit.The notation mirrors the signature in both directions: a signature written
0.001rejectsDefault: 1e-3, and a signature written1e-3rejectsDefault: 0.001.Extra text in parentheses. Any text after the default value must be enclosed in parentheses immediately after the value, such as
Default: -1 (the last axis). The parenthesis must fit on theDefault:line; a longer explanation belongs in theNotessection, referenced from the parenthesis as inDefault: None (see Notes [1]).No trailing period. The
Default:line must not end with a period.None default is annotated. A parameter whose signature default is
Noneand which carries a type hint annotation must have a type hint annotation that admitsNone. These annotations can be written asOptional[X],X | NoneorUnion[X, None]. The type hint formx: list[int] = Noneis a type error under PEP 484, which dropped implicit optionality.The build configuration in
doc/conf.pywas updated, and all the errors flagged were corrected.