rogerlew / pyvttbl

Automatically exported from code.google.com/p/pyvttbl
10 stars 8 forks source link

_num2binvec issue #15

Open Szepi opened 7 years ago

Szepi commented 7 years ago

Hi, Not sure whether this is the official source. Long story short, I was trying to use pyvttbl, following the code here: http://www.marsja.se/two-way-anova-repeated-measures-using-python/ The example breaks on line: aov = df.anova('rt', sub='Sub_id', wfactors=['iv1', 'iv2']) The end of the error message is:

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/pyvttbl/stats/_anova.pyc in _num2binvec(self, d, p)
   1238                 d=floor(d/2.)
   1239
-> 1240         return list(array(list(zeros((p-len(b))))+b)+1.)
   1241
   1242 ##    def output2html(self, fname, script=''):

TypeError: 'float' object cannot be interpreted as an index

The problem is that num2binvec converts p to float, and zeros does not look a float argument. I wonder how this was working before? Anyhow, by just replacing line 1240 with return list(array(list(zeros((int(p)-len(b))))+b)+1.) on my computer, the problem goes away. I am using a freshly installed python-2.7 on Mac and I installed python packages using port (they supposed to be the latest and bestest). Cheers, Csaba

colizoli commented 7 years ago

return list(array(list(zeros(int(p-len(b))))+b)+1.)

This fixed it for me (I'm also using python-2.7 on a Unix server)

basterix commented 6 years ago

Thanks @colizoli, your solution worked for me too - while yours @Szepi was generating a new issue for me:( Anaconda2 on Ubuntu 18.04, pyvttbl 0.5.2.2 and numpy 1.14.3

Szepi commented 6 years ago

And what was that issue if you don’t mind me asking? I am curious..

basterix commented 6 years ago

Apologies, I should have mentioned it:

... aov = df.anova('AE',sub='ID',wfactors=['session'])

File "/home/.../anaconda2/lib/python2.7/site-packages/pyvttbl/base.py", line 1973, in anova aov=stats.Anova()

File "/home/.../anaconda2/lib/python2.7/site-packages/pyvttbl/stats/_anova.py", line 605, in init super(Anova, self).init()

TypeError: super(type, obj): obj must be an instance or subtype of type

Szepi commented 6 years ago

What type is mentioned at the end? Is the error message cut in half?

basterix commented 6 years ago

Nope, that's all I get :(

Szepi commented 6 years ago

Oh, actually, I understand the error message now. But the error message is weird: self at this stage has no reason not to be of type Anova. Between, the two solutions, as far as I can see it, should be equivalent. If you can copy paste here a minimum example that is breaking, I can try to test it.

basterix commented 6 years ago

Apologies @Szepi - but on another computer (Linux Mint 18, just upgraded to pandas 0.23.4) - your solution actually did work just now.

Szepi commented 6 years ago

Interesting.. and puzzling.. Thanks for the update!

aappriou commented 5 years ago

Hi guys, I got the same issue as yours @basterix (TypeError: super(type, obj): obj must be an instance or subtype of type, for line 605 "super(Anova, self).init()")

Don't ask me why, but I just quit my jupyter notebook from my terminal after having corrected line 1240 (by replacing "p" by "Int(p)", I reopened jupyter notebook, ran my few lines and there was no longer the error from line 605 I don't know if it will work in your case, but it could be useful in the future if you don't want to change your OS to run a "simple" ANOVA ;) Cheers