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

Improve join_nonshared_inputs documentation #6216

Merged
merged 22 commits into from Nov 2, 2022

Conversation

wd60622
Copy link
Contributor

@wd60622 wd60622 commented Oct 14, 2022

What is this PR about?
This PR closes issue 6105 and increase the documentation of join_nonshared_inputs function in pymc/aesaraf.py

Checklist

Major / Breaking Changes

  • ...

Bugfixes / New features

  • ...

Docs / Maintenance

  • Adding type hints for join_nonshared_inputs and improving docstrings

@codecov
Copy link

codecov bot commented Oct 14, 2022

Codecov Report

Merging #6216 (8360f86) into main (ea721e4) will decrease coverage by 2.85%.
The diff coverage is 81.81%.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #6216      +/-   ##
==========================================
- Coverage   94.14%   91.29%   -2.86%     
==========================================
  Files         100      100              
  Lines       21239    21240       +1     
==========================================
- Hits        19996    19391     -605     
- Misses       1243     1849     +606     
Impacted Files Coverage Δ
pymc/aesaraf.py 90.15% <76.47%> (-3.39%) ⬇️
pymc/smc/kernels.py 97.37% <100.00%> (ø)
pymc/step_methods/metropolis.py 54.75% <100.00%> (-28.66%) ⬇️
pymc/tests/step_methods/test_slicer.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/step_methods/hmc/test_nuts.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/tests/step_methods/test_metropolis.py 0.00% <0.00%> (-100.00%) ⬇️
pymc/data.py 47.96% <0.00%> (-32.12%) ⬇️
pymc/step_methods/arraystep.py 89.36% <0.00%> (-4.97%) ⬇️
... and 3 more

@wd60622
Copy link
Contributor Author

wd60622 commented Oct 14, 2022

still WIP. Would like to add more to the docstring. The current example is similar to that of the delta_logp in the metropolis.py

@wd60622 wd60622 marked this pull request as ready for review October 19, 2022 18:52
@wd60622
Copy link
Contributor Author

wd60622 commented Oct 19, 2022

Here is the preview
Screen Shot 2022-10-19 at 3 29 45 PM
Screen Shot 2022-10-19 at 3 29 51 PM

@ricardoV94 ricardoV94 self-assigned this Oct 19, 2022
@ricardoV94
Copy link
Member

Thanks for opening the PR, I will try to review tomorrow

@wd60622
Copy link
Contributor Author

wd60622 commented Oct 19, 2022

Thanks for opening the PR, I will try to review tomorrow

thanks. no rush

pymc/aesaraf.py Outdated Show resolved Hide resolved
Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

Great start! I left some suggestions to be more precise, and more succinct / readable examples. Let me know what you think.

While reviewing I also realized we could come up with much better argument names for the function (and internal variables) instead of xs, vars, and inarray, xs_special. Probably outputs, inputs, joined_inputs, new_outputs, would be more readable?

pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
@ricardoV94 ricardoV94 changed the title join_nonshared_inputs documentation Improve join_nonshared_inputs documentation Oct 20, 2022
@wd60622
Copy link
Contributor Author

wd60622 commented Oct 20, 2022

Thanks for all the suggestions. All very good and am working through the edits

pymc/aesaraf.py Outdated Show resolved Hide resolved
@wd60622 wd60622 force-pushed the aesaraf_join_shared_input_doc branch from f9abe5c to 564ab09 Compare October 20, 2022 19:41
@wd60622
Copy link
Contributor Author

wd60622 commented Oct 25, 2022

Docs seem to be looking good! https://pymcio--6216.org.readthedocs.build/projects/docs/en/6216/api/generated/pymc.join_nonshared_inputs.html#pymc.join_nonshared_inputs

Copy link
Member

@ricardoV94 ricardoV94 left a comment

Choose a reason for hiding this comment

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

This looks amazing! I left one type-hint suggestion and a question that I am not sure about

pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
pymc/aesaraf.py Outdated Show resolved Hide resolved
@wd60622
Copy link
Contributor Author

wd60622 commented Oct 26, 2022

everything should be addressed

The latest: https://pymcio--6216.org.readthedocs.build/projects/docs/en/6216/api/generated/pymc.join_nonshared_inputs.html#pymc.join_nonshared_inputs

EDIT: I forgot to change the one dict mapping lol

@ricardoV94
Copy link
Member

The failing test seems unrelated and I think I already saw it failing before. Do you mind opening an issue to track it?

@michaelosthege
Copy link
Member

Looks like the recent renaming of the SMC files introduced conflicts..

I will give it a try at rebasing

@michaelosthege
Copy link
Member

@wd60622 I was confused why GitHub doesn't show your profile picture (and link) on the commits after I rebased them.
I think this is because the gmail address from the commit information is maybe not linked to your GitHub profile?

You can set it up under https://github.com/settings/emails and then GitHub should show your avatar on the commit messages again.

image

pymc/aesaraf.py Outdated
point: a sample point
xs: list of Aesara tensors
vars: list of variables to join
point : Point
Copy link
Member

Choose a reason for hiding this comment

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

I am not sure point is the right type. It does not match the type signature and it is not a "metatype" meaning a subset of dicts that match these properties but a different amd specific class. Does anybody know?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah. I'm not sure either. I was going off Point being in reference link and the fact that Point function would construct the same type as the alternative.
i.e. Dict[str, np.ndarray]

let me know which fits best with the package

Copy link
Member

Choose a reason for hiding this comment

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

Dict[str, np.ndarray] is the correct type here, but I'd say Point is also fine because users/devs probably understand what is meant in this context.

With the exact type hints in the signature, I treat the hints in the docstring as the "human readable" version, and often times I leave them away to not duplicate the information.

What is our policy, @OriolAbril ?

Copy link
Member

Choose a reason for hiding this comment

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

Then this is what should be used (with the correft numpydoc formatting) instead of point which is therefore an invalid type. This function is on the website and it needs to have the type info properly documented in the docstring having users in mind

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay. So I am hearing to switch back to the dict of {str : array_like}. Is that correct?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why is Point referenced in the docs/.../conf.py
Is there a purpose or usecase?

@wd60622
Copy link
Contributor Author

wd60622 commented Oct 30, 2022

@wd60622 I was confused why GitHub doesn't show your profile picture (and link) on the commits after I rebased them. I think this is because the gmail address from the commit information is maybe not linked to your GitHub profile?

All fixed. I had my account email switch recently. Thanks for the tip. Looks more legit now 😄

@wd60622
Copy link
Contributor Author

wd60622 commented Oct 30, 2022

Not sure why the doc build failed. I haven't seen that error before

@OriolAbril
Copy link
Member

The readthedocs error is a conda error don't have a clue as to why this is happening though. Hopefully it is a fluke

@wd60622
Copy link
Contributor Author

wd60622 commented Nov 1, 2022

Any more items for this PR?

@michaelosthege
Copy link
Member

Any more items for this PR?

IIRC that one Point should become Dict[str, np.ndarray]

@wd60622
Copy link
Contributor Author

wd60622 commented Nov 1, 2022

Any more items for this PR?

IIRC that one Point should become Dict[str, np.ndarray]

Gotcha. Never got confirmation there.

So the type hint is Dict[str, np.ndarray]. However, the docs parameter description is Point. I will change them to Dict[str, np.ndarray] and "dict of {str : array_like}"

@wd60622
Copy link
Contributor Author

wd60622 commented Nov 2, 2022

The code coverage seems unrelated to my changes. and FYI I'm unable to merge bc access

@michaelosthege
Copy link
Member

New git conflicts 😕
I think they might come from some of the 22 commits in the history, because the final diff doesn't change files that would explain the conflict (as far as I can tell).

Squashing the commits from the branch might already help to resolve the conflicts, and should probably be done before rebasing it

@ricardoV94 ricardoV94 merged commit b0d1066 into pymc-devs:main Nov 2, 2022
@ricardoV94
Copy link
Member

Thanks @wd60622!

@wd60622
Copy link
Contributor Author

wd60622 commented Nov 2, 2022

Thanks @wd60622!

Thank you for the help and feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve docstrings of aesaraf.join_non_shared_inputs
4 participants