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

python3 error #23

Open
andreacortis opened this issue Oct 30, 2018 · 5 comments
Open

python3 error #23

andreacortis opened this issue Oct 30, 2018 · 5 comments

Comments

@andreacortis
Copy link

(doe) LC25423:Envs corti938$ ipython
Python 3.6.4 |Anaconda, Inc.| (default, Jan 16 2018, 12:04:33)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.1.1 -- An enhanced Interactive Python. Type '?' for help.

In [1]: from pyDOE import *

In [2]: import pyDOE

In [3]: pyDOE.version
Out[3]: '0.3.8'

In [4]: fullfact([2, 3])

TypeError Traceback (most recent call last)
in
----> 1 fullfact([2, 3])

~/my_codes/Envs/doe/lib/python3.6/site-packages/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: can't multiply sequence by non-int of type 'numpy.float64'

@StefanNa
Copy link

I have the same issue

Can we get the version of numpy and scipy that were used for testing the package?

Also what python 3 version?

@bgoodman44
Copy link

Hopefully this isn't dead...but heres my versions

numpy: 1.15.1
python: 3.5
scipy: 1.2.0

@cruoti
Copy link

cruoti commented Jan 23, 2019

I too have the same issue (using python 3.7.2, pyDOE 0.3.8). This led me to do some digging.

The error stems from the fact that Python 3.x updated the behavior of division. Dividing two ints now produces a float.

PEP 238: https://www.python.org/dev/peps/pep-0238/
Stack Overflow: https://stackoverflow.com/q/1282945

# python 3.7.2
>>> 1/2
0.5

If you want to continue using floor division in python 3.x then you use the // operator.

# python 3.7.2
>>> 1//2
0

The nice thing is that the // operator also works in at least python 2.7 (I haven't tested any other 2.x version).

It'll work if you change doe_factorial.py line 74 to use the // operator.

    range_repeat = np.prod(levels)
    for i in range(n):
        range_repeat //= levels[i]    # updated from range_repeat /= levels[i]

It looks like #8 was created to fix the same problem that manifested itself slightly differently. The solution was merged into master with PR #20. However, as #19 calls out, the update has not been released to PyPI (nor has the version been incremented in __init__.py).

pyDOE2 was forked from this repo to release this fix and others to PyPI. Install using: pip install pyDOE2. I'm doing my import in the following way so I didn't have to change any of the rest of my code:

import pyDOE2 as pyDOE

@tisimst
What's the plan on releasing this fix to PyPI? I saw your note on #17 saying that you've been too busy to make updates. I can understand that. Do you recommend moving to pyDOE2 permanently? Like the comment in #17, have you given thought to allowing other contributors on the repo? Thanks for the great package thus far, it's been great for all of my work in 2.7.

@maraujo
Copy link

maraujo commented May 28, 2019

From @Cruti comments and because I'm using python 3. The current solution is to uninstall pyDOE and install pyDOE2.

@rsyanting
Copy link

From @Cruti comments and because I'm using python 3. The current solution is to uninstall pyDOE and install pyDOE2.

hi my dear friend,I use pyDoe2 and everything be fine. Thank a lot !

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

No branches or pull requests

6 participants