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

Document convention of preferring named arguments even for mandatory (positional) args #298

Open
AFg6K7h4fhy2 opened this issue Jul 23, 2024 · 2 comments
Assignees
Labels
discussion documentation Improvements or additions to documentation

Comments

@AFg6K7h4fhy2
Copy link
Collaborator

Given the variety of backgrounds and experiences present across CFA and the fact that CFA members seem, at present time, to constitute most of MSRs early users, I suggest we explicitly write out the argument names for positional arguments.

Pro: The argument names provide useful information to new users of MSR, Python, and certain Python package (e.g., numpyro).

Con: Blurs the lines between required and optional arguments, as now all previously positional arguments are presented as keyword arguments.

Con: More writing for MSR developers.

Examples

I0 = InfectionInitializationProcess(
    "I0_initialization",
    DistributionalRV(dist=dist.LogNormal(2.5, 1), name="I0"),
    InitializeInfectionsZeroPad(pmf_array.size),
    t_unit=1,
)

...would change to

I0 = InfectionInitializationProcess(
    name="I0_initialization",
    I_pre_seed_rv=DistributionalRV(
        dist=dist.LogNormal(loc=2.5, scale=1), name="I0"),
    infection_seed_method=InitializeInfectionsZeroPad(
        n_timepoints=pmf_array.size),
    t_unit=1,
)

Further thoughts are welcome. I do not feel particularly strongly about this, I just believe it might help clarify things to people in the tutorials somewhat.

@AFg6K7h4fhy2 AFg6K7h4fhy2 added the documentation Improvements or additions to documentation label Jul 23, 2024
@AFg6K7h4fhy2 AFg6K7h4fhy2 changed the title Consider Using Parameter Names In Calls In Tutorials Consider Using More Argument Names In Calls In Tutorials Jul 23, 2024
@AFg6K7h4fhy2 AFg6K7h4fhy2 changed the title Consider Using More Argument Names In Calls In Tutorials Consider Using More Argument Names In Tutorials Jul 23, 2024
@dylanhmorris
Copy link
Collaborator

I like this suggestion, and in general I like using named arguments for code readability even internally.

@dylanhmorris
Copy link
Collaborator

We have moved toward doing this both in code and tutorials. @AFg6K7h4fhy2 would you be willing to add a note to the developer docs recommending this?

@dylanhmorris dylanhmorris changed the title Consider Using More Argument Names In Tutorials Document convention of preferring named arguments even for mandatory (positional) args Sep 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants