numpy/numpy — pull request #458 by bfroehle (2012-09-24 22:55:44+00:00)
Title: Add `return_index` option to set operations (`setxor1d`, etc)

Not ready for merge, just asking for comments.

From `numpy.lib.arraysetops`:

> To do: Optionally return indices analogously to unique for all functions.

I've gone ahead and implemented a `return_index` parameter for _one_ function -- `setxor1d` -- and I'd like some feedback before I plunge ahead to write the corresponding options for the rest of the functions (`setdiff1d`, `union1d`, etc).

Questions to be addressed:

1. Is the name `return_index` alright, even thought it returns two sets of indices? It is the same name as used in `np.unique`.
2. Will you accept this without a corresponding `return_inverse`? I would think yes, as MATLAB doesn't allow for such an option and it's not necessarily obvious what it would even mean.
3. Code style... is it alright? Or would you prefer more of a global block format:

```
def setxor1d(ar1, ar2, assume_sorted=False, return_index=False):

if return_index:
< new code >
else:
< old code >
```