8000 Add a `description` to `Parameter`s by SengerM · Pull Request #1153 · pymeasure/pymeasure · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Add a description to Parameters #1153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SengerM
Copy link
Contributor
@SengerM SengerM commented Aug 19, 2024

I am new to pymeasure, but reading the documentation and source code I could not find a way to provide a description for each Parameter I add to my Procedure. I think it would be really nice to have an official description field in the constructor of Parameters, so that the user can provide a human-friendly description with information that is not captured by the other fields or not obvious.

In this pull request I am simply suggesting that this would be a good idea and providing a trivial implementation. What exactly is done with the description afterwards I still don't know, as I am not experienced with pymeasure. However, I would guess it could probably be integrated with the graphical interface machinery and other things, instead as being mere documentation strings in the code.

Example:

class ProcedureWithManyParameters(Procedure):
	repetition_rate = FloatParameter('repetition rate', units='s^-1', minimum=1e3, maximum=200e6, description='The inverse of the period between two write pulses.')
	read_fraction_start = FloatParameter('read fraction start', default=0.8, minimum=0, maximum=1, description='Fraction within each pulse at which to start the reading.')
	read_fraction_end = FloatParameter('read fraction end', default=1, minimum=0, maximum=1, description='Fraction within each pulse at which to stop the reading.')

as opposed to

class ProcedureWithManyParameters(Procedure):
	"""A procedure with many parameters.
	
	Parameters
	----------
	repetition_rate: float
		The inverse of the period between two write pulses. units='s^-1', minimum=1e3, maximum=200e6.
	read_fraction_start: float
		Fraction within each pulse at which to start the reading. default=0.8, minimum=0, maximum=1.
	read_fraction_end: float
		Fraction within each pulse at which to stop the reading. default=1, minimum=0, maximum=1.
	"""
	
	repetition_rate = FloatParameter('repetition rate', units='s^-1', minimum=1e3, maximum=200e6)
	read_fraction_start = FloatParameter('read fraction start', default=0.8, minimum=0, maximum=1)
	read_fraction_end = FloatParameter('read fraction end', default=1, minimum=0, maximum=1)

which involves duplication between the code and the docstring.

Please let me know if this is already implemented somehow in Pymeasure, in that case I apologize for this.

Copy link
codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 75.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 58.50%. Comparing base (bda7fd5) to head (cdb2c1b).

Files Patch % Lines
pymeasure/experiment/parameters.py 75.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1153      +/-   ##
==========================================
- Coverage   58.51%   58.50%   -0.02%     
==========================================
  Files         264      264              
  Lines       18416    18416              
==========================================
- Hits        10776    10774       -2     
- Misses       7640     7642       +2     
Flag Coverage Δ
unittests 58.50% <75.00%> (-0.02%) ⬇️

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.

@BenediktBurger
Copy link
Member

@CasperSchippers / @msmttchr .

Maybe this description could be shown as a tooltip over the parameter?

@CasperSchippers
Copy link
Collaborator
CasperSchippers commented Aug 19, 2024

@SengerM Thanks for contributing. I agree that it could be useful to have a standardised place for a description and combining that with the idea of a tooltip (thank @BenediktBurger) it could be realy nice!! You could show the description and the limits or so.

I think this could be added in the input widgets (pymeasure/display/inputs.py)

CasperSchippers added a commit that referenced this pull request Feb 4, 2025
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.

3 participants
0