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

Add get_histogram utility, option to return histogram of bond lengths and angles #33

Merged
merged 14 commits into from
Feb 9, 2022

Conversation

chrisjonesBSU
Copy link
Member

@chrisjonesBSU chrisjonesBSU commented Feb 1, 2022

Both of the angle_distribution and bond_distribution functions are a bit of a misnomer. Currently, they only return an array of the calculated bond angles and lengths, rather than giving the actual distributions.

This PR adds an additional parameter to these functions that returns a distribution of these values. I decided to add a parameter rather than outright changing the behavior of the function in case there are still use cases where we want a list of the actual bond lengths and angles. However, I'm open to changing this if someone thinks there is a better approach.

I still need to add some unit tests.

@codecov
Copy link

codecov bot commented Feb 1, 2022

Codecov Report

Merging #33 (2e68ff1) into master (2ca8753) will increase coverage by 0.01%.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #33      +/-   ##
==========================================
+ Coverage   99.65%   99.67%   +0.01%     
==========================================
  Files           6        7       +1     
  Lines         293      308      +15     
==========================================
+ Hits          292      307      +15     
  Misses          1        1              
Impacted Files Coverage Δ
cmeutils/plotting.py 100.00% <100.00%> (ø)
cmeutils/structure.py 100.00% <100.00%> (ø)

Copy link
Member

@jennyfothergill jennyfothergill left a comment

Choose a reason for hiding this comment

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

A couple minor suggestions. Excited to see all the work you're doing with MSIBI! 🙌

cmeutils/plotting.py Outdated Show resolved Hide resolved
cmeutils/tests/test_plotting.py Outdated Show resolved Hide resolved
cmeutils/structure.py Outdated Show resolved Hide resolved
cmeutils/tests/test_structure.py Show resolved Hide resolved
cmeutils/tests/test_structure.py Show resolved Hide resolved
Copy link
Member

@jennyfothergill jennyfothergill left a comment

Choose a reason for hiding this comment

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

Nice work! One last minor suggestion then LGTM

Comment on lines 30 to 33
s = sum(bin_heights)
bin_heights = np.array(
[float(i)/s for i in bin_heights]
)
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
s = sum(bin_heights)
bin_heights = np.array(
[float(i)/s for i in bin_heights]
)
bin_heights /= sum(bin_heights)

Copy link
Member Author

Choose a reason for hiding this comment

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

This throws an error.

numpy.core._exceptions._UFuncOutputCastingError: Cannot cast ufunc 'true_divide' output from dtype('float64') to dtype('int64') with casting rule 'same_kind'

I did change it so it's a bit cleaner/faster though.

@chrisjonesBSU chrisjonesBSU merged commit 8e33350 into cmelab:master Feb 9, 2022
@chrisjonesBSU chrisjonesBSU deleted the fix_distributions branch February 9, 2022 21:09
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