Skip to content

Fix recfunctions.join_by bugs (issue #4216) #4524

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions numpy/lib/recfunctions.py
Original file line number Diff line number Diff line change
Expand Up @@ -909,6 +909,11 @@ def join_by(key, r1, r2, jointype='inner', r1postfix='1', r2postfix='2',
# Make temporary arrays of just the keys
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])

# Keys need to be in same order
r1k = r1k[list(key)]
r2k = r2k[list(key)]


# Concatenate the two arrays for comparison
aux = ma.concatenate((r1k, r2k))
Expand Down Expand Up @@ -958,9 +963,9 @@ def join_by(key, r1, r2, jointype='inner', r1postfix='1', r2postfix='2',
current[0] += r1postfix
desc[0] += r2postfix
ndtype.insert(nameidx + 1, desc)
#... we haven't: just add the description to the current list
# ... we haven't: just add the description to the current list
else:
names.extend(desc[0])
names.append(desc[0])
ndtype.append(desc)
# Revert the elements to tuples
ndtype = [tuple(_) for _ in ndtype]
Expand Down