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

PSDP Algorithms #198

Merged
merged 14 commits into from
Jan 3, 2023
Merged

PSDP Algorithms #198

merged 14 commits into from
Jan 3, 2023

Conversation

abhishekmittal15
Copy link
Contributor

Hi @FanwangM , I have implemented the 1st algorithm mentioned in #194 , the Projected Gradient method and written the tests for it by taking the input matrices from the woodgate algorithm tests and the error percentages are better in certain cases. I will fix the docstrings soon and start implementing the Fast Gradient method. Looking forward to your feedback on the current code. Also I had a question regarding the file psdp.py, is it advisable to add all the algorithms to the same file, as the file is already getting really large, maybe we can shift some helper functions somewhere else and probably create a folder for PSDP and put each algorithm into its own file? What do you suggest we do?

@codecov
Copy link

codecov bot commented Nov 7, 2022

Codecov Report

Merging #198 (ea5941b) into master (025426f) will increase coverage by 0.08%.
The diff coverage is 96.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #198      +/-   ##
==========================================
+ Coverage   94.58%   94.67%   +0.08%     
==========================================
  Files          11       11              
  Lines         757      807      +50     
==========================================
+ Hits          716      764      +48     
- Misses         41       43       +2     
Impacted Files Coverage Δ
procrustes/psdp.py 95.54% <96.00%> (+0.14%) ⬆️

@FanwangM FanwangM mentioned this pull request Nov 7, 2022
@FanwangM
Copy link
Collaborator

FanwangM commented Nov 7, 2022

We can keep it in psdp.py for now. Please tag me once you think it's ready for review. I just put two rough comments.
Thank you for contributing! @abhishekmittal15

@@ -34,10 +34,90 @@
__all__ = [
"psdp_woodgate",
"psdp_peng",
"psdp_opt"
"psdp_opt",
"psdp_projgrad"
Copy link
Collaborator

Choose a reason for hiding this comment

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

"psdp_projgrad",

It's a good practice to have a comma to make the Git history clean.

Copy link
Member

Choose a reason for hiding this comment

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

In the end we may wish to split off some helper functions. The key criterion is that helper functions that are generically useful (not tired to pdsp) can be split off, provided we can make them "generic" enough to be useful outside the pdsp context. Otherwise better to keep encapsulated with the rest of the pdsp code.

It's really a matter of style. In the bad old days of programming, people deal with very long files. Nowadays people prefer shorter files, but if the number of files gets too large, it can be difficult to find what you are looking for in the code. Ideal, I think, is to hopefully make it so that when you need to find something, you can guess which file it will be in with two-three guesses, which suggests relatively few files, but not too few.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the suggestions. It makes a lot of sense to me.

@FanwangM
Copy link
Collaborator

Once you fix the testing errors and you think it's ready for code review, please tag me. Thanks. @abhishekmittal15

@abhishekmittal15
Copy link
Contributor Author

Hi @FanwangM , sure will do that.

Improved readability of psdp_projgrad and added explicit stop conditions for the algorithm
@abhishekmittal15
Copy link
Contributor Author

abhishekmittal15 commented Nov 18, 2022

Hi @FanwangM , I think you can now review my projection gradient implementation. There are some linting tests that fail and I am not sure exactly why its failing. The force push above was because I had squashed some commits into one, rewriting the previous pushed commit, hope thats not an issue

@FanwangM
Copy link
Collaborator

FanwangM commented Nov 18, 2022

That's not an issue at all. But you can fix the linter errors by checking out the detailed log at https://github.com/theochem/procrustes/actions/runs/3496401782/jobs/5854272424 by googling the error numbers, for example "procrustes/psdp.py:197:10: N806 variable 'F' in function should be lowercase". For something you are unsure of, you can google it and find people has some posts already, especially in StackOverflow. @abhishekmittal15

Thanks.

@abhishekmittal15
Copy link
Contributor Author

Hi, I am not sure if thats the reason the linting is failing. Because when I run linter locally, then it shows lint errors (most common error is "variable name doesnt conform to snake case styling") even in the psdp_opt, psdp_peng etc, but these implementations passed the checks.

@FanwangM
Copy link
Collaborator

That's strange. Can you check if you are using the same version of linters as that is in GitHub Actions?

@abhishekmittal15
Copy link
Contributor Author

Sorry for the delay in getting back to you, I had my end semester exams and projects. I have fixed all of the linting errors, but one remains and that is the C0302: Too many lines in module (1035/1000) (too-many-lines). What are your thoughts on how to proceed ahead with this error

@FanwangM FanwangM self-requested a review December 16, 2022 05:08
Copy link
Collaborator

@FanwangM FanwangM left a comment

Choose a reason for hiding this comment

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

This PR is good to merge now. Thanks for contributing!

Comment on lines 925 to 928
if e1 < e2 or choice == 1:
return S1
elif e2 < e1 or choice == 2:
return S2
Copy link
Collaborator

Choose a reason for hiding this comment

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

The return should be a ProcrustesResult object. Also, we need an empty line at the end of the file as a convention.

@@ -34,10 +34,90 @@
__all__ = [
"psdp_woodgate",
"psdp_peng",
"psdp_opt"
"psdp_opt",
"psdp_projgrad"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks for the suggestions. It makes a lot of sense to me.

@FanwangM FanwangM merged commit 39d90f9 into theochem:master Jan 3, 2023
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.

3 participants