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

Avoid division by zero error #3

Merged
merged 3 commits into from
Feb 5, 2019
Merged

Avoid division by zero error #3

merged 3 commits into from
Feb 5, 2019

Conversation

federkasten
Copy link
Member

This PR fixes division-by-zero error in signature-count->matrix when given an empty signature.
I also renamed signature-count->matrix to signature->vector.

Copy link
Contributor

@iku000888 iku000888 left a comment

Choose a reason for hiding this comment

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

@federkasten
Thanks for the great catch!
I left some nitty gritty but the change looks fine.

(let [counts (map #(get data % 0) trans-patterns)
sum (apply + counts)]
(map (comp double #(/ % sum)) counts)))
(if (pos? sum)
Copy link
Contributor

Choose a reason for hiding this comment

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

I think when would be better here

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks 👍 I have modified.

@iku000888 iku000888 merged commit 8211ad7 into master Feb 5, 2019
@iku000888 iku000888 deleted the fix/division-by-zero branch February 5, 2019 07:34
@iku000888
Copy link
Contributor

Thanks!

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