mailRe: Removal of the reduce() builtin function from the relaxation dispersion code in the trunk.


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Edward d'Auvergne on July 30, 2014 - 18:45:
For future reference, here is how to replace it with a loop (see the
top answer):

https://stackoverflow.com/questions/9474412/python-alternative-to-reduce

When you see what this code is doing, I'm sure you'll find a quick
alternative to counting all grid points.

Cheers,

Edward



On 30 July 2014 18:44, Edward d'Auvergne <edward@xxxxxxxxxxxxx> wrote:
Hi,

Strange!  This is for the current version of the trunk (r24850).  When
I run the command, I see:

$ grep -r "reduce(" . --exclude-dir=.svn
./specific_analyses/relax_disp/optimisation.py:
print("Unconstrained grid search size: %s (constraints may decrease
this size).\n" % reduce(mul, inc, 1))
./specific_analyses/relax_disp/optimisation.py:
print("Unconstrained grid search size: %s (constraints may decrease
this size).\n" % reduce(mul, self.inc, 1))
./extern/numpy_future.py:    return
add.reduce(sorted[indexer]*weights, axis=axis, out=out)/sumval
$

The first two matches are preventing the code from working on Python 3.

Regards,

Edward




On 30 July 2014 18:40, Troels Emtekær Linnet <tlinnet@xxxxxxxxxxxxx> wrote:
Hi Ed.

I cannot find the reduce problem?

A search gives:
grep -r "reduce(" .
./extern/numpy_future.py:    return
add.reduce(sorted[indexer]*weights, axis=axis, out=out)/sumval

So the "reduce" is here an extension to numpy.add.

Have you seen this problem anywhere else?

Best
troels



2014-07-30 18:16 GMT+02:00 Edward d'Auvergne <edward@xxxxxxxxxxxxx>:
Hi Troels,

Would you be able to remove you additions of the reduce() function in
the relax trunk?  This was introduced with the merger of the
disp_spin_speed branch.  However this function is not present in
Python 3, hence the relaxation dispersion analysis no longer operates
for these Python versions.  To find the failure points, just run the
Relax_disp system tests on Python 3.  This problem is a release
blocker.

For some history, here is the reason directly from Guido van Rossum:

http://www.artima.com/weblogs/viewpost.jsp?thread=98196

This post is the main reason why I try to avoid map(), lambda,
reduce(), etc.  These functions in relax have always caused pain as
Python has evolved.

Cheers,

Edward



Related Messages


Powered by MHonArc, Updated Wed Jul 30 20:40:19 2014