Skip to content

Remove initval from dist() API and add docstrings, type hints, tests #4913

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

Merged
merged 5 commits into from
Aug 10, 2021

Conversation

michaelosthege
Copy link
Member

This PR makes initial_values a property with docstring and type hints. It also adds some more type hints and docstrings to related functions and properties.

For the UNSET constant I added its own type, because inspecting signatures with UNSET kwargs (for example pm.Normal) results in confusing output, as demonstrated by this example:

>>> UNSET = object()
>>>
>>> def say_hello(name=UNSET):
...     print("Hi!" if name is UNSET else f"Hello {name}.")
...
>>>
>>> help(say_hello)
Help on function say_hello in module __main__:

say_hello(name=<object object at 0x0000018BD4226150>)
#                👆

With the new repr it just becomes

Help on function say_hello in module __main__:

say_hello(name=UNSET)

Depending on what your PR does, here are a few things you might want to address in the description:

@codecov
Copy link

codecov bot commented Aug 8, 2021

Codecov Report

Merging #4913 (03b22c3) into main (06d1412) will increase coverage by 0.03%.
The diff coverage is 96.96%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #4913      +/-   ##
==========================================
+ Coverage   73.12%   73.15%   +0.03%     
==========================================
  Files          86       86              
  Lines       13856    13868      +12     
==========================================
+ Hits        10132    10145      +13     
+ Misses       3724     3723       -1     
Impacted Files Coverage Δ
pymc3/model.py 83.59% <94.11%> (+0.11%) ⬆️
pymc3/distributions/continuous.py 96.24% <100.00%> (-0.02%) ⬇️
pymc3/distributions/distribution.py 81.88% <100.00%> (+1.44%) ⬆️
pymc3/util.py 74.35% <100.00%> (+0.84%) ⬆️
pymc3/backends/report.py 89.51% <0.00%> (-2.10%) ⬇️
pymc3/parallel_sampling.py 88.21% <0.00%> (+1.01%) ⬆️

@michaelosthege michaelosthege changed the title Add or fix initval-related docstrings, type hints etc. Remove initval from dist() API and add docstrings, type hints, tests Aug 8, 2021
@michaelosthege michaelosthege force-pushed the initval-docstrings branch 3 times, most recently from 2c558d3 to bed1057 Compare August 8, 2021 12:23
@michaelosthege michaelosthege force-pushed the initval-docstrings branch 2 times, most recently from 6f5cfd9 to 10f1105 Compare August 8, 2021 14:59
@michaelosthege michaelosthege merged commit 6a75744 into pymc-devs:main Aug 10, 2021
@michaelosthege michaelosthege deleted the initval-docstrings branch August 10, 2021 15:08
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.

2 participants