-
Notifications
You must be signed in to change notification settings - Fork 13
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
ENH: Adding docstrings to functions in config reader #81
base: master
Are you sure you want to change the base?
Conversation
Codecov Report
@@ Coverage Diff @@
## master #81 +/- ##
=======================================
Coverage 70.81% 70.81%
=======================================
Files 7 7
Lines 209 209
=======================================
Hits 148 148
Misses 61 61
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
excellent!
pytentiostat/config_reader.py
Outdated
config_data : dict | ||
the configuration data | ||
|
||
override_ts : Unique string to add after output filename in stringe. Optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
slightly wrong structure to this one. type is string and its optional on this line, the description of what id does on the next line down.
Also, as per the other comments, remove empty lines between parameters and return values. Also, good time to fix small typo in here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I tried override_ts: (str, optional), if that seems fine? I saw it on an example doc string. Or maybe should just be str, optional?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I prefer the latter:
override_ts: str, optional
Let's set the style to this maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sounds good!
pytentiostat/config_reader.py
Outdated
Parameters | ||
---------- | ||
config_data : dict | ||
the configuration data |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
capitalize the here, remove mt lines, but this is super!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it!
Removing mt lines, capitalizing in descriptions, fixing typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
very nice, nearly there!
@@ -8,22 +8,21 @@ | |||
def parse_config_file(configlocation=None): | |||
""" | |||
Reads config data from the config file | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This line should be put back in. First line is a one-line (<80 chars) description of the overall purpose of the function, then a blank line, then as many lines as you want to expand on the explanation, then a blank line, then Parameters underlined and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay, makes sense!
pytentiostat/config_reader.py
Outdated
@@ -64,13 +100,53 @@ def get_lsv_params(config_data): | |||
|
|||
|
|||
def get_ca_params(config_data): | |||
""" | |||
Obtains the parameters for a chronoamperometry experiment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not so sure about these guys, but I think Returns the parameters for a chronoamperometry experiment from the config data
i.e., returns is maybe better than obtains? But I am not so clear on that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that phrasing is more clear. I changed it on the other functions that do similar things as well so they would be consistent.
Changing obtain to returns in all config data retriever functions, readding blank in first function docstring, and removing parens on str, optional
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
few more comments....got a little deeper into the functions this time....
pytentiostat/config_reader.py
Outdated
---------- | ||
config_data : dict | ||
The configuration data | ||
override_ts : (str, optional) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah got it now.
pytentiostat/config_reader.py
Outdated
configlocation : str | ||
the path on the filesystem to the config file. Optional. If not | ||
configlocation : str, optional | ||
The path on the filesystem to the config file. If not | ||
specified pytentiostat looks in the current directory for the | ||
config files. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since i posted another change request, I may as well make this small req too......config file
(singular) now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops holdover from previous version. fixed now
pytentiostat/config_reader.py
Outdated
out_name_ts : str | ||
The output filename with unique identifier. | ||
data_out_path : str | ||
The path to which the output file will be written to. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The path where the file will be written
?
or
The path to the directory where the file will be written
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah the latter. Now changed
pytentiostat/config_reader.py
Outdated
Returns | ||
------- | ||
out_name_ts : str | ||
The output filename with unique identifier. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
a little unclear, this. maybe a second sentence that discusses how the name is composed rather than just "with unique identifier"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added what unique identifier is added to the file
pytentiostat/config_reader.py
Outdated
------- | ||
voltage : float | ||
The voltage which will be held at in volts. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
pls delete line
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deleted
pytentiostat/config_reader.py
Outdated
Returns | ||
------- | ||
voltage : float | ||
The voltage which will be held at in volts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we find a better way to say it maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I changed to make more descriptive.
pytentiostat/config_reader.py
Outdated
exp_type : str | ||
The type of experiment to be run. | ||
""" | ||
|
||
exp_type = config_data["general_parameters"]["experiment_type"] | ||
|
||
return exp_type | ||
|
||
|
||
def get_exp_time(config_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if this function should be called get_experiment_duration
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is more descriptive. Now changed
exp_type = config_data["general_parameters"]["experiment_type"] | ||
|
||
return exp_type | ||
|
||
|
||
def get_exp_time(config_data): | ||
""" | ||
Returns how long the experiment is to be run for the chronoamperometry case. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why isn't this info returned with the chronoamperometry info? Wouldn't that be better maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just wrote this for plotting module since the only data it needs for the CA experiment is the time (not the voltage). But maybe this one is separate enough that I should just read from the dictionary in plotter and get rid of this function. Check for it could already be made by get CA params.
How long the starting voltage will be held in seconds. | ||
|
||
""" | ||
|
||
rest_time = config_data["general_parameters"]["rest_time"] | ||
|
||
return rest_time | ||
|
||
def get_steps(config_data): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't quite get why we are having functions that just retrieve dictionary values..... I guess it can make sense if it is part of our user-interface, and we don't expect our users to know python very well. Is that the case?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Though I expect users won't know python well, this part won't really be front-end. I envision in the end, user will enter into visual boxes which, when starting experiment, will write a config (which can be loaded if desired to conduct the same experiment later). I just thought compartmentalizing the experimental config reading here might be good so these functions can read in and then go through a series of checks to make sure they are appropriate values (I still don't have these checks in for most of these functions) instead of bundling that with the functions of the other modules. I can just remake it and place the reading and the checks in the other modules where they are used though if that makes more sense.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see. Actually, this is part of the MVC pattern and it would be the controller layer that does the validation, but it would probably be structured differently with a few validation functions that are more abstract (think about validating file paths, emails or passwords), but here we would be validating that floats are within some range or sthg and then return true or false and it would have statements like
if validate_voltage(config_data["ca"]["initial_voltage"], -5., 5.):
ca_initial voltage = config_data["ca"]["initial_voltage"]
We can certainly do it your way, but we are writing a lot of code and a way that does it robustly with less code is probably preferred.
Maybe we can discuss this a bit more on the call and make a decision. it will also depend on the UC a bit, so spending time hardening this code (docstrings and tests) may not be the best just yet (though I am glad this is now your impulse and wanting the code to validate!). I think it has also been helpful for learning. I am very excited about how you are now thinking about the coding!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay yeah this makes sense, let's discuss this in the next meeting. Especially because we were going to discuss MVC anyways!
No description provided.