In article mailman.16378.1417111312.18130.python-l...@python.org,
Peter Otten __pete...@web.de wrote:
Albert van der Horst wrote:
In the Rosetta code I come across this part of
LU-decomposition.
def pivotize(m):
Creates the pivoting matrix for m.
n = len(m)
ID = [[float(i ==
On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
If there is more than one item with the maximum calculated the first is
given, so for your attempt
max(xrange(100,200), key=lambda i: i%17==0 )
the values False, False, True, False, ... are calculated and
In article mailman.16552.1417688329.18130.python-l...@python.org,
Chris Angelico ros...@gmail.com wrote:
On Thu, Dec 4, 2014 at 9:09 PM, Albert van der Horst
alb...@spenarnc.xs4all.nl wrote:
If there is more than one item with the maximum calculated the first is
given, so for your attempt
Albert van der Horst writes:
Useful as that function [Python's max with a key] may be, it
shouldn't have been called max.
The meaning of the key should be added to help(max), if it still isn't
- returns a maximal element or an element that maximizes the key.
In some communities they call it
Albert van der Horst writes:
Chris Angelico wrote:
If there's no clear maximum, it can't do any better than
that. It's still returning something for which there is no
greater.
I agree that it is a useful function and that it is doing
the right thing. What is wrong is the name.
I refer
Albert van der Horst wrote:
In article mailman.16378.1417111312.18130.python-l...@python.org,
Peter Otten __pete...@web.de wrote:
Albert van der Horst wrote:
In the Rosetta code I come across this part of
LU-decomposition.
def pivotize(m):
Creates the pivoting matrix for m.
n =
Albert van der Horst wrote:
I agree that it is a useful function and that it is doing
the right thing. What is wrong is the name.
I refer to the fact that it is not returning the maximum.
It returns the iterator value that leads to the maximum.
A function that doesn't return a maximum
Jussi Piitulainen wrote:
Would you also want sorted called something else when used with a key?
Because it doesn't produce a sorted list of the keys either:
data = (short, long, average)
sorted(data, key=len)
['long', 'short', 'average']
max(data, key=len)
'average'
I
Albert van der Horst wrote:
I agree that it is a useful function and that it is doing
the right thing. What is wrong is the name.
I refer to the fact that it is not returning the maximum.
It returns the iterator value that leads to the maximum.
That is incorrect. It returns the maximum
Steven D'Aprano writes:
Jussi Piitulainen wrote:
Would you also want sorted called something else when used with a
key? Because it doesn't produce a sorted list of the keys either:
data = (short, long, average)
sorted(data, key=len)
['long', 'short', 'average']
On Thu, Dec 4, 2014, at 05:09, Albert van der Horst wrote:
So in that case max doesn't return the maximum (True), but instead
something else.
If you want to find the largest item in a list of of strings, sorted
case-insensitively, you might use str.lower or locale.strxfrm as the key
function.
On 12/4/2014 5:35 AM, Albert van der Horst wrote:
I agree that it is a useful function and that it is doing
the right thing. What is wrong is the name.
I refer to the fact that it is not returning the maximum.
It returns the iterator value that leads to the maximum.
A function that doesn't
In the Rosetta code I come across this part of
LU-decomposition.
def pivotize(m):
Creates the pivoting matrix for m.
n = len(m)
ID = [[float(i == j) for i in xrange(n)] for j in xrange(n)]
for j in xrange(n):
row = max(xrange(j, n), key=lambda i: abs(m[i][j]))
if j
Albert van der Horst wrote:
In the Rosetta code I come across this part of
LU-decomposition.
def pivotize(m):
Creates the pivoting matrix for m.
n = len(m)
ID = [[float(i == j) for i in xrange(n)] for j in xrange(n)]
for j in xrange(n):
row = max(xrange(j, n),
14 matches
Mail list logo