question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Docstrings in `basicShapes` classes erroneously include units

See original GitHub issue

Many of the method docstrings of various classes within the basicShapes and complexShapes module include units when the methods are actually unit-agnostic. For instance, the getComponentArea method of the Circle class says “Computes the area for the circle component in cm^2”. Similar statements exist for other ShapedComponent area and perimeter methods.

The units in these docstrings should be removed because they are potentially confusing and do not describe anything about the method itself. Yes, when used in the way expected, wherein the user provides the underlying dimensions to a ShapedComponent in units of cm, the method returns area in units of cm^2. But the method itself has no idea what the units of its arguments are, and therefore the computed area is returned in whatever units are passed to the method (i.e. no checks or conversions are performed to ensure that the value returned is in units of cm^2). It also does not matter that the dimensions can be thermally expanded, because getThermalExpansionFactor returns a unitless expansion factor and so unit compatibility is not an issue.

Because ARMI has an API, methods like getComponentArea are likely to be used in unexpected ways wherein it cannot be assumed that the dimensions passed to it are in a given set of units without additional checks being implemented.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
youngmitcommented, Aug 27, 2021

because it would be well known to everyone that area implies cm^2

You’d think that. cm for length is about the only well-standardized unit in ARMI, so we don’t have a big doc page with flashing lights telling everyone what all of the official units are like you might see in, say, MOOSE. If we had a page it wouldn’t be able to say much more than “ARMI uses centimeters for all Component dimensions,” and most people probably wouldn’t see it. So I feel that repeating the assertion throughout the docstrings where length and length-derives values are returned is beneficial.

That said, if there are examples where this isn’t the case, it would more improve the code to add units to docstrings than to remove them.

1reaction
kecklercommented, Aug 26, 2021

Thanks @john-science . I only very briefly looked around for similar occurrences, but didn’t find any. I’ll post on here if I see any more in the near term.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python Docstrings (With Examples) - Programiz
Python docstrings are the string literals that appear right after the definition of a function, method, class, or module. Let's take an example....
Read more >
Documenting Python APIs with docstrings
Documenting Python APIs with docstrings¶. We use Python docstrings to create reference documentation for our Python APIs. Docstrings are read by developers, ...
Read more >
Python Docstrings Tutorial : Examples & Format for Pydoc ...
Python documentation string or commonly known as docstring, is a string literal, and it is used in the class, module, function, or method...
Read more >
Documenting Python Code: A Complete Guide
Documenting Your Python Code Base Using Docstrings: A deep dive into docstrings for classes, class methods, functions, modules, packages, and scripts, as well ......
Read more >
SymPy Docstrings Style Guide
Every public function, class, method, and module should have a docstring that describes what it does. Documentation that is specific to a ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found