WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   'int' object not callable (https://forum.worldviz.com/showthread.php?t=582)

enkeli 05-12-2006 05:52 PM

'int' object not callable
 
Quote:

Traceback (most recent call last):
File "C:\Program Files\Vizard25\viz.py", line 5916, in mytimer
curAction.update(elaps,curAction._obj_)
File "C:\Program Files\Vizard25\vizact.py", line 1199, in update
sample = int(p * self.numsamples)
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "DecisonMaking.py", line 1010, in trial
peopleGiveResponse( i, slideNumber )
File "DecisonMaking.py", line 816, in peopleGiveResponse
lookAbout = whrandom.randrange( -1 ,2 ) # -1,0,1
File "C:\Program Files\Vizard25\bin\lib\whrandom.py", line 103, in randrange
istart = int(start)
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "DecisonMaking.py", line 1108, in timer
viz.starttimer( TIMER_BLINK_CLOSE[ i ], whrandom.randrange( 3, 7 ) )
File "C:\Program Files\Vizard25\bin\lib\whrandom.py", line 103, in randrange
istart = int(start)
TypeError: 'int' object is not callable
I am getting these errors sometimes from my program (which has also started crashing/closing on me without any error messages)

These errors appear to be from inside the whrandom, what can I do?

halley 05-15-2006 07:02 AM

That module defines a class called whrandom. You must create an instance of the whrandom class, and then that instance can provide a stream of numbers. This works a bit differently from a simple function.

Code:

import whrandom
rng = whrandom.whrandom()
for loop in range(10):
    num = rng.randrange(1, 5)
    print num

This is a complete example. It loads the whrandom module. It creates an instance of the whrandom class, and we refer to it with the variable "rng". The instance decides on a seed to begin automatically. It then uses that instance to fetch new random numbers. Keep the instance for as long as you need to generate numbers.

enkeli 05-15-2006 03:44 PM

Thank you. I changed the whrandom, but I still get the same error from a different source (viz.py and vizmat.py and vizact.py)

Quote:

Traceback (most recent call last):
File "C:\Program Files\Vizard25\viz.py", line 5916, in mytimer
curAction.update(elaps,curAction._obj_)
File "C:\Program Files\Vizard25\vizact.py", line 1153, in update
quat = vizmat.slerp(self.beginRot,self.endRot,p)
File "C:\Program Files\Vizard25\vizmat.py", line 173, in slerp
return (qFrom*scale_from) + (quatTo*scale_to)
File "C:\Program Files\Vizard25\vizmat.py", line 348, in __mul__
if isinstance(other,Quat) or (type(other) == type([]) and len(other) >= 4):
TypeError: 'int' object is not callable
Traceback (most recent call last):
File "C:\Program Files\Vizard25\viz.py", line 5916, in mytimer
curAction.update(elaps,curAction._obj_)
File "C:\Program Files\Vizard25\vizact.py", line 1199, in update
sample = int(p * self.numsamples)
TypeError: 'int' object is not callable
"C:\Program Files\Vizard25\vizact.py", line 1153, in update
quat = vizmat.slerp(self.beginRot,self.endRot,p)
File "C:\Program Files\Vizard25\vizmat.py", line 173, in slerp
return (qFrom*scale_from) + (quatTo*scale_to)
File "C:\Program Files\Vizard25\vizmat.py", line 348, in __mul__
if isinstance(other,Quat) or (type(other) == type([]) and len(other) >= 4):
TypeError: 'int' object is not callable

enkeli 05-16-2006 01:48 PM

I just got an error even with the whrandom change...

Code:

rand = whrandom.whrandom()
Quote:

Traceback (most recent call last):
File "DecisonMaking.py", line 1114, in timer
viz.starttimer( TIMER_BLINK_CLOSE[ i ], rand.randrange( 3, 7 ) )
File "C:\Program Files\Vizard25\bin\lib\whrandom.py", line 115, in randrange
return istart + int(self.random() *
TypeError: 'int' object is not callable
Help?

Gladsomebeast 05-16-2006 05:04 PM

The “TypeError: 'int' object is not callable” error message indicates that python expected a function in the place of an int object type. Perhaps there is a variable named int like in the following code.

Code:

import viz
viz.go()

int = 4
print int(1.1)


enkeli 05-16-2006 05:10 PM

In my code, there are no variables named "int"

Gladsomebeast 05-16-2006 05:47 PM

Guess I am a little stumped without your complete code context. I suggest that you focus your debuging on the fact that you are getting a Type Error. You could also try utilizing the newer ‘random’ module instead of whrandom.

enkeli 05-16-2006 06:01 PM

Thank you for responding. The trouble with debugging is the fact that this is an intermittent problem which does not occur every time the code is run. And as in one of the earlier posts, the 'int' object not callable error occurs with other modules than just the whrandom.

onina 10-22-2009 04:12 PM

I had the same problem. My mistake was to have declared use the name "range" as a variable before I called the function range(10).


All times are GMT -7. The time now is 11:31 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC