Description
When joining two recarrays and the keys are not in the same order in the two recarrays the join_by function fails, because it assumes the key fields to be in the same order.
Example:
from numpy.lib.recfunctions import rec_join
from numpy import recarray
a = recarray((1,), [('key1', int), ('key2', int), ('x', int)])
b = recarray((1,), [('key2', int), ('key1', int), ('y', int)])
a[0] = (0,1,50)
b[0] = (1,0,100)
ab = rec_join(('key1', 'key2'), a, b, jointype='inner', r1postfix='', r2postfix='')
This outputs:
TypeError: invalid type promotion
because the wrong keys are concatenated.
The problem is lines 910-911 in recfunctions.py:
r1k = drop_fields(r1, [n for n in r1names if n not in key])
r2k = drop_fields(r2, [n for n in r2names if n not in key])
After this the fields should also be sorted for both arrays.
Version: Numpy 1.8, python 2.7.1