Closed AlexandreBohyn closed 4 years ago
Which version of Python are you using? I get this in 2.7:
>>> from pyDOE import fracfact
>>> gen = 'a b ab'
>>> fracfact(gen)
[[-1. -1. 1.]
[ 1. -1. -1.]
[-1. 1. -1.]
[ 1. 1. 1.]]
>>> re.split('\-?\s?\+?', gen)
['a', 'b', 'ab']
Could this be an issue in 3.X only or did I miss something?
Hello,
Yes I'm using python 3.7.4 so that might be the source of the problem.
I'm getting this outpout from 3.X:
>>> import pyDOE
>>> gen = 'a b ab'
>>> pyDOE.fracfact(gen)
array([[-1., -1., -1., -1.],
[ 1., -1., -1., -1.],
[-1., 1., -1., -1.],
[ 1., 1., -1., -1.],
[-1., -1., 1., -1.],
[ 1., -1., 1., -1.],
[-1., 1., 1., -1.],
[ 1., 1., 1., -1.],
[-1., -1., -1., 1.],
[ 1., -1., -1., 1.],
[-1., 1., -1., 1.],
[ 1., 1., -1., 1.],
[-1., -1., 1., 1.],
[ 1., -1., 1., 1.],
[-1., 1., 1., 1.],
[ 1., 1., 1., 1.]])
>>> re.split('\-?\s?\+?', gen)
['', 'a', '', 'b', '', 'a', 'b', '']
but using the new regex I have:
>>> re.split('\-?\s+\+?', gen)
['a', 'b', 'ab']
It works fine in the pyDOE2 package, so I guess the problem has been solved later on.
There is an issue with the fracfact() function when specifying the generator. The following code should give me a 2^(3-1) design in 4 runs
gen = 'a b ab'; fracfact(gen)
But instead it treats the the generator string as "a b a b" and gives me a 2^4 design in 16 runs. This comes from the following code in the fracfact() function:A = [item for item in re.split('\-?\s?\+?', gen) if item]
The regex string should be '-?\s+?', this way the space isn't optional and it treats a string 'ab' as an interaction and not as two factor 'a' 'b' put together.