[Numpy-discussion] loop through values in a array and find maximum as looping
Derek Homeier
derek at astro.physik.uni-goettingen.de
Wed Dec 7 00:11:27 EST 2011
On 07.12.2011, at 5:54AM, questions anon wrote:
> sorry the 'all_TSFC' is for my other check of maximum using concatenate and N.max, I know that works so I am comparing it to this method. The only reason I need another method is for memory error issues.
> I like the code I have written so far as it makes sense to me. I can't get the extra examples I have been given to work and that is most likely because I don't understand them, these are the errors I get :
>
> Traceback (most recent call last):
> File "d:\plot_summarystats\test_plot_remove_memoryerror_max.py", line 46, in <module>
> N.maximum(a,TSFC,out=a)
> ValueError: non-broadcastable output operand with shape (106,193) doesn't match the broadcast shape (721,106,193)
>
> and
>
OK, then it seems we did not indeed grasp the entire scope of the problem -
since you have initialised a from the previous array TSFC (not from TSFC[0]?!), this can
only mean the arrays read in come in different shapes? I don't quite understand how the
previous version did not raise an error then; but if you only want the (106,193)-subarray
you have indeed to keep the loop
for b in TSFC[:]:
N.maximum(a,b,out=a)
But you would have to find some way to distinguish between ndim=2 and ndim=3 input,
if really both can occur...
>
> Traceback (most recent call last):
> File "d:\plot_summarystats\test_plot_remove_memoryerror_max.py", line 45, in <module>
> if not instance(a, N.ndarray):
> NameError: name 'instance' is not defined
>
Sorry, typing error (or devious auto-correct?) - this should be 'isinstance()'
Cheers,
Derek
More information about the NumPy-Discussion
mailing list