tisimst / pyDOE

Design of experiments for Python
BSD 3-Clause "New" or "Revised" License
263 stars 114 forks source link

TypeError Python 3.5.2 #8

Closed e-neu closed 7 years ago

e-neu commented 7 years ago

Hi,

I get the following TypeError with newer versions of Python. Any suggestions how to fix this?

Kind regards, e-neu

pyDOE.fullfact([1, 2])

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-65-d26355a11123> in <module>()
----> 1 pyDOE.fullfact([1, 2])

C:\Users\XXX\AppData\Roaming\Python\Python35\site-packages\pydoe-0.3.8-py3.5.egg\pyDOE\doe_factorial.py in fullfact(levels)
     76         for j in range(levels[i]):
     77             lvl += [j]*level_repeat
---> 78         rng = lvl*range_repeat
     79         level_repeat *= levels[i]
     80         H[:, i] = rng

TypeError: 'numpy.float64' object cannot be interpreted as an integer
import sys
sys.version

'3.5.2 |Anaconda custom (64-bit)| (default, Jul 5 2016, 11:41:13) [MSC v.1900 64 bit (AMD64)]'

import pyDOE
pyDOE.__version__

'0.3.8'

e-neu commented 7 years ago

Ok, I looked into it and the solution seems to be quite simple. Just change the float division

range_repeat /= levels[i]

into a integer division.

range_repeat //= levels[i]

I've only recently started using Python, so I am not sure how this will affect earlier Python versions.