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

Changed float division to integer division #35

Merged
merged 1 commit into from
Jun 10, 2020

Conversation

GodotMisogi
Copy link
Contributor

Purpose

range() and np.zeros() in Python 3 throw errors as /3 returns a float, so //3 for integer division is done instead.

Type of change

  • Bugfix
  • Breaking change

Testing

Python 2

>>> xs = np.array([1,2,3,4,5,6])
>>> range(xs.size/3)
[0, 1]
>>> np.zeros(xs.size/3)
array([0., 0.])

Python 3

>>> import numpy as np
xs = np.array([1,2,3,4,5,6])
>>> range(xs.size/3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer
>>> np.zeros(xs.size/3)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: 'float' object cannot be interpreted as an integer
>>> np.zeros(xs.size//3)
array([0., 0.])
>>> range(xs.size//3)
range(0, 2)

`range()` and `np.zeros()` throw errors as `/3` returns a float, so `//3` for integer division is done instead.
@GodotMisogi GodotMisogi requested a review from a team as a code owner June 6, 2020 03:48
@GodotMisogi GodotMisogi requested review from bbrelje and anilyil June 6, 2020 03:48
@GodotMisogi GodotMisogi marked this pull request as draft June 6, 2020 23:40
@GodotMisogi GodotMisogi marked this pull request as ready for review June 9, 2020 04:28
@bbrelje bbrelje merged commit 3c60786 into mdolab:master Jun 10, 2020
bernardopacini pushed a commit to bernardopacini/pygeo that referenced this pull request Mar 17, 2021
`range()` and `np.zeros()` throw errors as `/3` returns a float, so `//3` for integer division is done instead.
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