- attached bcc.xml
Data type issue in freud.kspace.AnalyzeSFactor3D class
When I call the getSvsQ and getPeakList functions from the freud.kspace.AnalyzeSFactor3D class, I get errors. I think the code is expecting an integer instead of a float for the self.g variable.
For the getSvsQ function I get the following error: 'float' object cannot be interpreted as an integer
For the getPeakList function I get the following error: Cannot cast ufunc subtract output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
I believe this error may come from the value of self.g, which should be an integer instead of a float. In the init function for the freud.kspace.AnalyzeSFactor3D class, self.g = self.grid/2, which makes self.g a float. However, self.g is used later as a parameter in the range function, which only takes integers as input.
I am using Freud version 0.6.2 with python 3.6.
Thank you
Comments (9)
-
reporter -
reporter - attached structurefactor_freud.ipynb
-
reporter I attached a jupyter notebook to test the error. The errors occur on lines 171, 172, 173 for the getPeakList function, and on line 205 for the getSvsQ function.
-
-
assigned issue to
-
assigned issue to
-
- changed status to resolved
Resolving
#148kspace float/integer division bug.→ <<cset 261eee29e2a5>>
-
Resolving
#148kspace float/integer division bug.→ <<cset 261eee29e2a5>>
-
Thanks for reporting this issue, @pchery! I have submitted a pull request fix where we replace
self.g = self.grid / 2
withself.g = self.grid // 2
.This probably came about from code written for Python 2, where the default behavior of division
/
is integer division. This would have produced the intended result (which ignores the extra "0.5"). By explicitly using//
, we get integer division in a way that is compatible with Python 3. -
Merged in issue-148 (pull request #148)
Resolving
#148kspace float/integer division bug.Approved-by: Vyas Ramasubramani vramasub@umich.edu
→ <<cset 79b3e42ac98a>>
-
Merged in issue-148 (pull request #148)
Resolving
#148kspace float/integer division bug.Approved-by: Vyas Ramasubramani vramasub@umich.edu
→ <<cset 79b3e42ac98a>>
- Log in to comment