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

mypy init #78

Merged
merged 26 commits into from
Mar 31, 2023
Merged

mypy init #78

merged 26 commits into from
Mar 31, 2023

Conversation

juanitorduz
Copy link
Contributor

First steps towards adding mypy support, see #76

@juanitorduz juanitorduz marked this pull request as draft March 20, 2023 21:15
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/pgbart.py Outdated Show resolved Hide resolved
@juanitorduz
Copy link
Contributor Author

@aloctavodia I think I have made good progress. I still need to work on the docstrings and the rest of the files. Still, I think this is a good checkpoint to get some feedback as I am touching many places :) Don't feel pressured to review as I will continue working on it.

pymc_bart/pgbart.py Outdated Show resolved Hide resolved
juanitorduz and others added 4 commits March 24, 2023 21:11
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/utils.py Show resolved Hide resolved
@juanitorduz
Copy link
Contributor Author

juanitorduz commented Mar 30, 2023

Test are passing locally but on the ci/cd we are getting

 ModuleNotFoundError: No module named 'pymc.logprob.joint_logprob'

because of pymc-devs/pymc#6599. I updated the path in ccd98b8

@juanitorduz juanitorduz marked this pull request as ready for review March 30, 2023 21:22
Copy link
Member

@aloctavodia aloctavodia left a comment

Choose a reason for hiding this comment

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

LGTM!

pymc_bart/utils.py Show resolved Hide resolved
@juanitorduz
Copy link
Contributor Author

LGTM!

Great! I did change some small things which should not have any real impact on the code performance but feel free to test without rushing :)

Copy link
Member

@aloctavodia aloctavodia left a comment

Choose a reason for hiding this comment

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

The changes introduced a performance drop of around 50% to 65%. The main reason seem to be the change from list to array and then performing operations such as np.append on arrays. Such operations are too slow, the difference is small for a few calls, but for thousands of call, the effect quickly adds up to many seconds.

I have suggested changes, but not sure if mypy is going to complain.

pymc_bart/utils.py Outdated Show resolved Hide resolved
leaf_node = self.get_node(node_index)
output[leaf_node.idx_data_points] = leaf_node.value

if self.idx_leaf_nodes is not None:
Copy link
Member

Choose a reason for hiding this comment

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

self.idx_leaf_nodes should not be None when calling _predict, it can only be None after trimming, but then we don't call _predict

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unfortunately, mypy just cares about the type and does not follow what is happening outside the methods 😞

pymc_bart/pgbart.py Outdated Show resolved Hide resolved
pymc_bart/pgbart.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
pymc_bart/tree.py Outdated Show resolved Hide resolved
@juanitorduz
Copy link
Contributor Author

Thank you @aloctavodia ! I will look into your comments in detail!

juanitorduz and others added 8 commits March 31, 2023 16:35
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
Co-authored-by: Osvaldo A Martin <aloctavodia@gmail.com>
@juanitorduz
Copy link
Contributor Author

@aloctavodia I addressed your comments... would you mind running the benchmark to see if we do not have performance degradation with these changes? Thanks :)

@aloctavodia
Copy link
Member

According to the benchmark, this may be 5% faster or 5% slower, haha.

Joking aside I think this is ready to merge, I am going to wait a little bit in case @fjloyola has some comments to add.

@juanitorduz
Copy link
Contributor Author

Amazing! Thanks for the feedback!

@aloctavodia aloctavodia merged commit be9dbf0 into pymc-devs:main Mar 31, 2023
3 checks passed
@aloctavodia
Copy link
Member

Thanks @juanitorduz!!!

@juanitorduz juanitorduz deleted the mypy branch April 1, 2023 09:31
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.

None yet

2 participants