Question

So, I currently need to understand the following code properly:

J = p['M'].repeat(p['N'],1).T

p is a dictionary in which the entry under key M is simply an array, the T transposes, that much is clear. But, the only version I can find for the repeat function is syntax in the form of

numpy.repeat(array , repeats [,axis])

This leaves me wondering what the meaning of a syntax of type array.repeat(something) actually means and I can neither find an answer in my head or the internet for now. This is numpy though, isnt it? It is imported, without being tagged with an 'as' clause. So currently am on a machine without a python/numpy shell installed to simply try it, so I thought I give this a shot: What is repeated how many times? My first interpretation would be p['M'] is repeated p['N'] times along the first axis, then transposed, but every example specifying an axis I find uses something like axis=1. Thanks a lot =)

Was it helpful?

Solution

There is another version of repeat in numpy: numpy.ndarray.repeat

Please see the documentation here

Hope this helps

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top