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

Update Inputs for User-Facing Classes #85

Merged
merged 14 commits into from
Apr 17, 2024
Merged

Update Inputs for User-Facing Classes #85

merged 14 commits into from
Apr 17, 2024

Conversation

connoramoreno
Copy link
Collaborator

@connoramoreno connoramoreno commented Apr 11, 2024

Reduces arguments of all user-facing classes to a minimal list and introduces setters and getters for those classes. Additionally, implements the use of **kwargs to handle optional setting of default class attributes for both the Python API and command-line interface with YAML input.

Furthermore, introduces a RadialBuild class in invessel_build.py to minimize the argument list for InVesselBuild.

@connoramoreno connoramoreno requested a review from gonuke April 11, 2024 20:27
@connoramoreno connoramoreno linked an issue Apr 11, 2024 that may be closed by this pull request
@connoramoreno
Copy link
Collaborator Author

connoramoreno commented Apr 11, 2024

I have another commit coming soon that will improve the use of kwargs, allowing only certain kwargs to be supplied to each class/method. I suggest holding off on review of that aspect of the PR until that next commit.

@connoramoreno
Copy link
Collaborator Author

PR is ready for review now!

Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

This is a bigger upgrade than expected - thanks for all the effort @connoramoreno

Examples/config.yaml Outdated Show resolved Hide resolved
Examples/example_python.py Outdated Show resolved Hide resolved
Comment on lines 87 to 89
num_s = 4
num_theta = 8
num_phi = 4
Copy link
Member

Choose a reason for hiding this comment

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

While we're refining this, I've wondered about making this a tuple mesh_size = (4, 8, 4).

Pros:

  • It makes things a little more compact
  • It is a common pattern for sizing a grid

Cons:

  • the order of (s, theta, phi) is implied

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 think with sufficient documentation, a tuple input would be fine

parastell/invessel_build.py Outdated Show resolved Hide resolved
parastell/invessel_build.py Outdated Show resolved Hide resolved
for name, value in dict.items():
if name in allowed_kwargs:
kwarg_dict.update({name: value})
elif all_kwargs and name not in allowed_kwargs:
Copy link
Member

Choose a reason for hiding this comment

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

Isn't the second half of this condition implied by the fact that you didn't match on the if?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well I want the first condition to happen whether all_kwargs is True or False, while I want the error to be raised only under the condition that all_kwargs = True.

This functionality is particularly useful when extracting keyword arguments from YAML-derived dictionaries, since not all keys in those dictionaries are keyword arguments. In such cases, we set all_kwargs = False since we don't want an error to be raised when the algorithm comes across a key that is a positional argument.

Copy link
Member

Choose a reason for hiding this comment

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

But I think you only get to this check against all_kwargs if name not in allowed_kwargs... right?

Suggested change
elif all_kwargs and name not in allowed_kwargs:
elif all_kwargs:

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Oh, I see what you're saying. Good point! I thought the "second half of the condition" you were referring to was the elif as a whole.

@connoramoreno connoramoreno self-assigned this Apr 15, 2024
Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

Some final comments as we close in on the final version.

parastell/invessel_build.py Show resolved Hide resolved
parastell/invessel_build.py Outdated Show resolved Hide resolved
parastell/invessel_build.py Show resolved Hide resolved
parastell/utils.py Show resolved Hide resolved
parastell/utils.py Outdated Show resolved Hide resolved
parastell/parastell.py Outdated Show resolved Hide resolved
parastell/invessel_build.py Outdated Show resolved Hide resolved
Copy link
Member

@gonuke gonuke left a comment

Choose a reason for hiding this comment

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

This is ready to go! Great effort @connoramoreno!

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.

introduce setters/getters for default parameters of each object
2 participants