# numpy equivalent functionality

6 messages
Open this post in threaded view
|
Report Content as Inappropriate

## numpy equivalent functionality

 Hi guys,I have 2 short numpy-related questions.In numpy, if one can invert an arbitrary array arr along a given axis using the syntax    arr[::-1,...]What is the equivalent idiom in Julia?The other issue is, how can I truncate an array between a lower and upper bound? In numpy, this is easily done with np.clip:    http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.htmlTnx!A
Open this post in threaded view
|
Report Content as Inappropriate

## Re: numpy equivalent functionality

 Check out `clamp` for your second question: http://docs.julialang.org/en/latest/stdlib/base/#Base.clamp On Wed, Jul 23, 2014 at 10:07 AM, Andrei Berceanu wrote: Hi guys,I have 2 short numpy-related questions.In numpy, if one can invert an arbitrary array arr along a given axis using the syntax    arr[::-1,...]What is the equivalent idiom in Julia? The other issue is, how can I truncate an array between a lower and upper bound? In numpy, this is easily done with np.clip:    http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html Tnx!A
Open this post in threaded view
|
Report Content as Inappropriate

## Re: numpy equivalent functionality

 In reply to this post by Andrei Berceanu On Wednesday, July 23, 2014 10:07:20 AM UTC-4, Andrei Berceanu wrote:In numpy, if one can invert an arbitrary array arr along a given axis using the syntax    arr[::-1,...]And with regards to this, I think you're after `flipdim` — http://docs.julialang.org/en/latest/stdlib/base/#Base.flipdimThere's also the Matlab-like names flipud and fliplr for the first two axes (up/down and left/right).
Open this post in threaded view
|
Report Content as Inappropriate

## Re: numpy equivalent functionality

 In reply to this post by Andrei Berceanu A[end:-1:1, ...] On Wednesday, July 23, 2014 07:07:20 AM Andrei Berceanu wrote: > Hi guys, > > I have 2 short numpy-related questions. > > In numpy, if one can invert an arbitrary array *arr* along a given axis > using the syntax > >     *arr[::-1,...]* > > What is the equivalent idiom in Julia? > > The other issue is, how can I truncate an array between a lower and upper > bound? > In numpy, this is easily done with np.clip: > >     http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html> > Tnx! > A
Open this post in threaded view
|
Report Content as Inappropriate

## Re: numpy equivalent functionality

 Thanks guys, works like a charm!AOn Wednesday, July 23, 2014 4:32:56 PM UTC+2, Tim Holy wrote:A[end:-1:1, ...] On Wednesday, July 23, 2014 07:07:20 AM Andrei Berceanu wrote: > Hi guys, > > I have 2 short numpy-related questions. > > In numpy, if one can invert an arbitrary array *arr* along a given axis > using the syntax > >     *arr[::-1,...]* > > What is the equivalent idiom in Julia? > > The other issue is, how can I truncate an array between a lower and upper > bound? > In numpy, this is easily done with np.clip: > >     http://docs.scipy.org/doc/numpy/reference/generated/numpy.clip.html > > Tnx! > A