Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit d87eb4e

Browse files
committed
rec_join now returns an array that has its rows in the same order as the first record array passed to it.
svn path=/trunk/matplotlib/; revision=4880
1 parent 0a3ffe1 commit d87eb4e

1 file changed

Lines changed: 6 additions & 9 deletions

File tree

lib/matplotlib/mlab.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1990,11 +1990,6 @@ def rec_join(key, r1, r2):
19901990
def makekey(row):
19911991
return tuple([row[name] for name in key])
19921992

1993-
1994-
names = list(r1.dtype.names) + [name for name in r2.dtype.names if name not in set(r1.dtype.names)]
1995-
1996-
1997-
19981993
r1d = dict([(makekey(row),i) for i,row in enumerate(r1)])
19991994
r2d = dict([(makekey(row),i) for i,row in enumerate(r2)])
20001995

@@ -2003,12 +1998,14 @@ def makekey(row):
20031998

20041999
keys = r1keys & r2keys
20052000

2006-
r1ind = [r1d[k] for k in keys]
2007-
r2ind = [r2d[k] for k in keys]
2001+
r1ind = npy.array([r1d[k] for k in keys])
2002+
r2ind = npy.array([r2d[k] for k in keys])
20082003

2004+
# Make sure that the output rows have the same relative order as r1
2005+
sortind = r1ind.argsort()
20092006

2010-
r1 = r1[r1ind]
2011-
r2 = r2[r2ind]
2007+
r1 = r1[r1ind[sortind]]
2008+
r2 = r2[r2ind[sortind]]
20122009

20132010
r2 = rec_drop_fields(r2, r1.dtype.names)
20142011

0 commit comments

Comments
 (0)