It's not exactly an interaction between Visual and Numpy but rather between
the random function imported through RandomArray and a random function
imported from whrandom by Visual. I guess the rule is "the last import
wins" in determining the meaning of a name. If you import RandomArray last,
it overrules the whrandom definition.
Here is what is imported by Visual (see PythonNN/visual/__init__.py):
from math import *
from Numeric import *
from whrandom import random, randint, uniform
import copy_reg
Note that Visual itself imports Numeric. Visual also imports math, because
a major use of VPython is by novice programmers doing scientific
computation and visualization, and it is important that for example "sqrt"
and "cos" are present without having to invoke them specially.
Frankly, I don't see a good excuse for Visual to import from whrandom.
Perhaps that's just historical having to do with early testing (Dave
Scherer, can you comment?). It would probably be clearer to remove that
import. What do others think?
Bruce Sherwood
--On Monday, November 19, 2001 7:01 PM +0100 Nils Wagner
<nw...@me...> wrote:
> Hi,
>
> It seems to me that there is a conflict between Vpython and Numpy.
>
> To make this clear check the following example
>
> from Numeric import *
> from visual import *
> from RandomArray import *
> # from visual import * # conflict with Numpy
> print random((2,3))
>
> Visual-2001-09-24
> [[ 0.82224834 0.79405266 0.1088888 ]
> [ 0.36729395 0.4097493 0.35424358]]
>
> but if one activates the line just before print random
>
> Visual-2001-09-24
> Traceback (most recent call last):
> File "random.py", line 5, in ?
> print random((2,3))
> TypeError: random() takes exactly 1 argument (2 given)
>
>
> Any suggestion ?
>
> Nils
|