Thanks! This helped me with the problem at hand, but it would still be nice 
to know if there's a more general way of doing this type of evaluation in 
PyCall.

On Tuesday, March 15, 2016 at 12:23:55 PM UTC-4, Robin Deits wrote:
>
> This isn't pretty, but it might do the job: 
>
> julia> np.mgrid[:__getitem__]((pybuiltin(:slice)(0,5), 
> pybuiltin(:slice)(0,5)))
> 2x5x5 Array{Int64,3}:
> [:, :, 1] =
>  0  1  2  3  4
>  0  0  0  0  0
>
> [:, :, 2] =
>  0  1  2  3  4
>  1  1  1  1  1
>
> [:, :, 3] =
>  0  1  2  3  4
>  2  2  2  2  2
>
> [:, :, 4] =
>  0  1  2  3  4
>  3  3  3  3  3
>
> [:, :, 5] =
>  0  1  2  3  4
>  4  4  4  4  4
>
> It's just a deconstruction of the actual call that happens in python: 
>
> In [7]: np.mgrid.__getitem__((slice(0,5), slice(0,5)))
> Out[7]:
> array([[[0, 0, 0, 0, 0],
>         [1, 1, 1, 1, 1],
>         [2, 2, 2, 2, 2],
>         [3, 3, 3, 3, 3],
>         [4, 4, 4, 4, 4]],
>
>        [[0, 1, 2, 3, 4],
>         [0, 1, 2, 3, 4],
>         [0, 1, 2, 3, 4],
>         [0, 1, 2, 3, 4],
>         [0, 1, 2, 3, 4]]])
>
> On Tuesday, March 15, 2016 at 12:01:06 PM UTC-4, Chris wrote:
>>
>> I'm trying to use numpy's mgrid (
>> https://docs.scipy.org/doc/numpy-1.10.0/reference/generated/numpy.mgrid.html)
>>  
>> via PyCall, but I can't figure out what the syntax should be. I've tried 
>> every permutation I can think of, could someone help me out?
>>
>> The python call looks like:
>>
>> >>> np.mgrid[0:5,0:5]array([[[0, 0, 0, 0, 0],        [1, 1, 1, 1, 1],        
>> >>> [2, 2, 2, 2, 2],        [3, 3, 3, 3, 3],        [4, 4, 4, 4, 4]],       
>> >>> [[0, 1, 2, 3, 4],        [0, 1, 2, 3, 4],        [0, 1, 2, 3, 4],        
>> >>> [0, 1, 2, 3, 4],        [0, 1, 2, 3, 4]]])
>>
>>
>> Thanks in advance.
>>
>

Reply via email to