Skip to content

Docstrings#111

Merged
henrikjacobsenfys merged 12 commits into
developfrom
docstrings
Mar 4, 2026
Merged

Docstrings#111
henrikjacobsenfys merged 12 commits into
developfrom
docstrings

Conversation

@henrikjacobsenfys

Copy link
Copy Markdown
Member

Improve docstrings for all ModelComponents.

Also prevented the setters of the width of Gaussian, Lorentzian and Voigt to set negative widths

@henrikjacobsenfys henrikjacobsenfys added [scope] bug Bug report or fix (major.minor.PATCH) [scope] documentation Documentation only changes (major.minor.patch.POST) [priority] medium Normal/default priority labels Feb 27, 2026
@codecov

codecov Bot commented Feb 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
⚠️ Please upload report for BASE (develop@33b093b). Learn more about missing BASE report.

Additional details and impacted files
@@            Coverage Diff             @@
##             develop     #111   +/-   ##
==========================================
  Coverage           ?   98.13%           
==========================================
  Files              ?       36           
  Lines              ?     2302           
  Branches           ?      380           
==========================================
  Hits               ?     2259           
  Misses             ?       23           
  Partials           ?       20           
Flag Coverage Δ
integration 0.00% <0.00%> (?)
unittests 98.13% <100.00%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@henrikjacobsenfys henrikjacobsenfys removed the [scope] bug Bug report or fix (major.minor.PATCH) label Mar 3, 2026
area (Int or float): Area under the curve.
unit (str or sc.Unit): Unit of the parameters.
Defaults to "meV".
area (Int | float): Area under the curve. center (Int | float):

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I think you forgot a line break before center.


Raises:
TypeError: If the value is not a number.
ValueError: If the value is not positive.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

I don't think you need the Raises information . . .

@rozyczko rozyczko left a comment

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.

Looks good with several minor issues raised

Comment on lines +175 to +179
I(x) = \frac{A}{\\sigma \\sqrt{2\\pi}}
\\exp\\left(
-\frac{1}{2}
\\left(\frac{x - x_0}{\\sigma}\right)^2
\right)

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.

Is this correct? You are mixing unescaped \frac with \\sigma, \\sqrt etc. The class level docstring uses r""" with single backslashes. Is the rendered document OK?

I think you should just use single backslashes throughout, given you have r"""

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.

You're right, it needed r""". If I forget the r""" then Ruff automatically adds \

Comment on lines +17 to +18
r"""Test Model of a Gaussian function.

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.

Is this still a "Test" model? Neither Lorentzian nor DHO have "Test"

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.

Whoops that "test" was added to check that the documentation updated when I made changes - didn't realise I pushed that change

Comment on lines 18 to 19
@@ -19,17 +19,30 @@ class Voigt(CreateParametersMixin, ModelComponent):
center is not provided, it will be centered at 0 and fixed, which is

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.

Maybe you should use r""" for consistency? Even if there's no Latex in the docstrings

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.

Yeah probably. Thanks!

Comment on lines +37 to +38
unique_name (str | None): Unique name of the component. if None,
a unique_name is automatically generated.

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.

if None -> If None

Comment on lines +41 to +42
energy (number, list, np.ndarray, | scipp Variable). The energy
transfer. If number, assumed to be in meV unless energy_unit

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.

Stray | before scipp Variable.
Please standardise on full stop vs. colon after arg description
You have Parameter). If number and |None): Unit for below.

Please standardise on whether you want to use commas for arguments or vertical bars.

Comment on lines 57 to 58
TODO: change to sc.Variable?

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.

TODOs are source code comments, NOT docs!

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.

Or github issues.. removed it

@rozyczko

rozyczko commented Mar 3, 2026

Copy link
Copy Markdown
Member

looks good now!

@henrikjacobsenfys henrikjacobsenfys merged commit cadc6f8 into develop Mar 4, 2026
26 of 32 checks passed
@AndrewSazonov AndrewSazonov deleted the docstrings branch March 5, 2026 14:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[priority] medium Normal/default priority [scope] documentation Documentation only changes (major.minor.patch.POST)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants