<p dir="auto">Is this a bug (note the different dtypes of the output)?</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="In [1]: np.array([1, 2, 3], dtype=str)
Out[1]: 
array(['1', '2', '3'], 
      dtype='|S1')

In [2]: np.array([1, 2, 3]).astype(str)
Out[2]: 
array(['1', '2', '3'], 
      dtype='|S24')"><pre class="notranslate"><code class="notranslate">In [1]: np.array([1, 2, 3], dtype=str)
Out[1]: 
array(['1', '2', '3'], 
      dtype='|S1')

In [2]: np.array([1, 2, 3]).astype(str)
Out[2]: 
array(['1', '2', '3'], 
      dtype='|S24')
</code></pre></div>
<p dir="auto">This behavior is new to numpy 1.7.0 (and breaks some unit tests in one of my packages).</p>
<p dir="auto">I came across something that might be a bug in the numpy unique function. Here is an example.</p>
<p dir="auto">In my case, a is a numpy array holding indices referring to pairwise equal elements in two other vectors (not shown). It could for instance be:</p>
<p dir="auto">a=np.array([[1,2],[3,4],[1,2],[5,6,7]])</p>
<p dir="auto">In this case, element 1 and 2 are pairwise equal in the two arrays not show. The same goes for element 3 and 4, and elements 5,6,7.</p>
<p dir="auto">Since the [1,2] pair is occuring twice, I want to remove the duplicate entry. I use</p>
<p dir="auto">In [18]: np.unique(a)<br>
Out[18]: array([[1, 2], [3, 4], [5, 6, 7]], dtype=object)</p>
<p dir="auto">However, what causes me trouble, is when there are only two pairwise identical elements:</p>
<p dir="auto">In [19]: a=np.array([[1,2],[3,4],[1,2],[5,6]])<br>
In [20]: np.unique(a)<br>
Out[20]: array([1, 2, 3, 4, 5, 6])</p>
<p dir="auto">Now, the output has a completely different meaning for my purpose.</p>
<p dir="auto">Is the unique function supposed to work this way?</p>