Skip to content
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

Add selection of random seed for reproducibility #39

Merged
merged 3 commits into from
Mar 15, 2024

Conversation

Flaminietta
Copy link
Collaborator

In the configuration file, the user can now select the random seed used for the creation of N random input matrices in case of robustness analysis. This ensures the reproducibility of the results and the possibility of generating different random sequences if needed.

In the function create_n_randomly_sampled_matrices it is provided that random_seed may also be None. This is not possible in the configuration JSON file now but is a generalization we can use when we delete the configuration file.

@Flaminietta Flaminietta added enhancement New feature or request code quality quality of the code improved joss review related issues related to the review process for publication labels Mar 7, 2024
@Flaminietta Flaminietta self-assigned this Mar 7, 2024
@Flaminietta Flaminietta linked an issue Mar 7, 2024 that may be closed by this pull request
Copy link
Collaborator

@mspada mspada left a comment

Choose a reason for hiding this comment

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

Tested, all good from my side

@Flaminietta
Copy link
Collaborator Author

@kapil-agnihotri, do you have any concerns here or can I merge it?

mcda/mcda_with_robustness.py Show resolved Hide resolved
@@ -47,36 +47,41 @@ def check_config_error(condition: bool, error_message: str):

def check_config_setting(condition_robustness_on_weights: bool,
condition_robustness_on_indicators: bool,
mc_runs: int) -> (int, int):
mc_runs: int, random_seed: int) -> (int, int):
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can you try to wrap the method definition in two lines ,i.e., extending the lines upto 120 characters?
I think that will improve the readability. As below we can see lines that are extended until 120.

def check_config_setting(condition_robustness_on_weights: bool, condition_robustness_on_indicators: bool,
                             mc_runs: int, random_seed: int) -> (int, int):


Parameters:
- condition (bool): The condition to check.
Parameters:
Copy link
Collaborator

Choose a reason for hiding this comment

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

List of parameters do not match to that of declared in the method definition.
I think the parameters added here are the expected return parameters and not the ones passed to it. Can you please write both the ones passed and the ones returned in Returns ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I have corrected "Parameters" into "Returns". However, I am not adding "Parameters" because my thinking throughout the code has been to add a description of the parameters and/or returns only when I feel it needs a short explanation. Anyways, the last section in every docstring always lists all :param: and :return:.

"True", "False", 1000)
```
"""
:rtype: Tuple[int, int]
Copy link
Collaborator

Choose a reason for hiding this comment

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

Here this list is again confusing with the parameter declaration above.

Copy link
Collaborator Author

@Flaminietta Flaminietta Mar 13, 2024

Choose a reason for hiding this comment

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

Do you understand my logic now? Don't you like it?
If needed, a short comment is added about parameters and/or returns, and a full list of parameters and returns is always at the bottom of each docstring.

This produces a function description like this (if you hoover the mouse over its name):

Screenshot 2024-03-13 at 15 22 55

So, it's the bottom list that gives precise info on parameters and returns.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Cool. Thanks for the explanation.

mcda/utils/utils_for_main.py Show resolved Hide resolved
@Flaminietta
Copy link
Collaborator Author

@kapil-agnihotri ready.

# TODO: the default_random_seed cannot be used while reading the settings from a JSON file, where None
# cannot be given as an option; it will be implemented when the congiguration settings will be passed as a
# stream or handle.
default_random_seed = 42
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you don't need an additional variable declaration for 42 I think it can directly be assigned as well. But however, you prefer.

@Flaminietta Flaminietta merged commit 3dc78e4 into main Mar 15, 2024
3 checks passed
@Flaminietta Flaminietta deleted the add-an-option-to-specify-random-seeds branch March 15, 2024 15:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
code quality quality of the code improved enhancement New feature or request joss review related issues related to the review process for publication
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add an option to specify random seeds
3 participants