We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
(untested) use of deprecated numpy.unique1d
Original report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659405

```
statsmodels/sandbox/regression/try_catdata.py:    unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)
statsmodels/sandbox/regression/try_catdata.py:    ix,rind = np.unique1d(factors, return_inverse=1)
statsmodels/sandbox/regression/try_catdata.py:    unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)
```

```
$> python -c 'import numpy as np; print np.__version__; print np.unique1d'
1.7.1
Traceback (most recent call last):
  File "<string>", line 1, in <module>
AttributeError: 'module' object has no attribute 'unique1d'
```


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `statsmodels/sandbox/regression/try_catdata.py`
Content:
```
1 from statsmodels.compat.python import lrange
2 import numpy as np
3 #from numpy import linalg as npla
4 from scipy import stats, optimize
5 
6 '''
7 Working with categorical data
8 =============================
9 
10 use of dummy variables, group statistics, within and between statistics
11 examples for efficient matrix algebra
12 
13 dummy versions require that the number of unique groups or categories is not too large
14 group statistics with scipy.ndimage can handle large number of observations and groups
15 scipy.ndimage stats is missing count
16 
17 new: np.bincount can also be used for calculating values per label
18 '''
19 
20 from scipy import ndimage
21 
22 #problem: ndimage does not allow axis argument,
23 #   calculates mean or var corresponding to axis=None in np.mean, np.var
24 #   useless for multivariate application
25 
26 def labelmeanfilter(y, x):
27    # requires integer labels
28    # from mailing list scipy-user 2009-02-11
29    labelsunique = np.arange(np.max(y)+1)
30    labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))
31    # returns label means for each original observation
32    return labelmeans[y]
33 
34 #groupcount: i.e. number of observation by group/label
35 #np.array(ndimage.histogram(yrvs[:,0],0,10,1,labels=yrvs[:,0],index=np.unique(yrvs[:,0])))
36 
37 def labelmeanfilter_nd(y, x):
38    # requires integer labels
39    # from mailing list scipy-user 2009-02-11
40    # adjusted for 2d x with column variables
41 
42    labelsunique = np.arange(np.max(y)+1)
43    labmeansdata = []
44    labmeans = []
45 
46    for xx in x.T:
47       labelmeans = np.array(ndimage.mean(xx, labels=y, index=labelsunique))
48       labmeansdata.append(labelmeans[y])
49       labmeans.append(labelmeans)
50    # group count:
51    labelcount = np.array(ndimage.histogram(y, labelsunique[0], labelsunique[-1]+1,
52                         1, labels=y, index=labelsunique))
53 
54    # returns array of lable/group counts and of label/group means
55    #         and label/group means for each original observation
56    return labelcount, np.array(labmeans), np.array(labmeansdata).T
57 
58 def labelmeanfilter_str(ys, x):
59     # works also for string labels in ys, but requires 1D
60     # from mailing list scipy-user 2009-02-11
61     unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)
62     labelmeans = np.array(ndimage.mean(x, labels=unilinv, index=np.arange(np.max(unil)+1)))
63     arr3 = labelmeans[unilinv]
64     return arr3
65 
66 def groupstatsbin(factors, values):
67     '''uses np.bincount, assumes factors/labels are integers
68     '''
69     n = len(factors)
70     ix,rind = np.unique1d(factors, return_inverse=1)
71     gcount = np.bincount(rind)
72     gmean = np.bincount(rind, weights=values)/ (1.0*gcount)
73     meanarr = gmean[rind]
74     withinvar = np.bincount(rind, weights=(values-meanarr)**2) / (1.0*gcount)
75     withinvararr = withinvar[rind]
76     return gcount, gmean , meanarr, withinvar, withinvararr
77 
78 
79 def convertlabels(ys, indices=None):
80     '''convert labels based on multiple variables or string labels to unique
81     index labels 0,1,2,...,nk-1 where nk is the number of distinct labels
82     '''
83     if indices == None:
84         ylabel = ys
85     else:
86         idx = np.array(indices)
87         if idx.size > 1 and ys.ndim == 2:
88             ylabel = np.array(['@%s@'%ii[:2].tostring() for ii in ys])[:,np.newaxis]
89             #alternative
90     ##        if ys[:,idx].dtype.kind == 'S':
91     ##            ylabel = nd.array([' '.join(ii[:2]) for ii in ys])[:,np.newaxis]
92         else:
93             # there might be a problem here
94             ylabel = ys
95 
96     unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)
97     return unilinv, np.arange(len(unil)), unil
98 
99 def groupsstats_1d(y, x, labelsunique):
100     '''use ndimage to get fast mean and variance'''
101     labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))
102     labelvars = np.array(ndimage.var(x, labels=y, index=labelsunique))
103     return labelmeans, labelvars
104 
105 def cat2dummy(y, nonseq=0):
106     if nonseq or (y.ndim == 2 and y.shape[1] > 1):
107         ycat, uniques, unitransl =  convertlabels(y, lrange(y.shape[1]))
108     else:
109         ycat = y.copy()
110         ymin = y.min()
111         uniques = np.arange(ymin,y.max()+1)
112     if ycat.ndim == 1:
113         ycat = ycat[:,np.newaxis]
114     # this builds matrix nobs*ncat
115     dummy = (ycat == uniques).astype(int)
116     return dummy
117 
118 def groupsstats_dummy(y, x, nonseq=0):
119     if x.ndim == 1:
120         # use groupsstats_1d
121         x = x[:,np.newaxis]
122     dummy = cat2dummy(y, nonseq=nonseq)
123     countgr = dummy.sum(0, dtype=float)
124     meangr = np.dot(x.T,dummy)/countgr
125     meandata = np.dot(dummy,meangr.T) # category/group means as array in shape of x
126     xdevmeangr = x - meandata  # deviation from category/group mean
127     vargr = np.dot((xdevmeangr * xdevmeangr).T, dummy) / countgr
128     return meangr, vargr, xdevmeangr, countgr
129 
130 
131 if __name__ == '__main__':
132    pass
133
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/statsmodels/sandbox/regression/try_catdata.py b/statsmodels/sandbox/regression/try_catdata.py
--- a/statsmodels/sandbox/regression/try_catdata.py
+++ b/statsmodels/sandbox/regression/try_catdata.py
@@ -58,7 +58,7 @@
 def labelmeanfilter_str(ys, x):
     # works also for string labels in ys, but requires 1D
     # from mailing list scipy-user 2009-02-11
-    unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)
+    unil, unilinv = np.unique(ys, return_index=False, return_inverse=True)
     labelmeans = np.array(ndimage.mean(x, labels=unilinv, index=np.arange(np.max(unil)+1)))
     arr3 = labelmeans[unilinv]
     return arr3
@@ -67,7 +67,7 @@
     '''uses np.bincount, assumes factors/labels are integers
     '''
     n = len(factors)
-    ix,rind = np.unique1d(factors, return_inverse=1)
+    ix,rind = np.unique(factors, return_inverse=1)
     gcount = np.bincount(rind)
     gmean = np.bincount(rind, weights=values)/ (1.0*gcount)
     meanarr = gmean[rind]
@@ -93,7 +93,7 @@
             # there might be a problem here
             ylabel = ys
 
-    unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)
+    unil, unilinv = np.unique(ylabel, return_index=False, return_inverse=True)
     return unilinv, np.arange(len(unil)), unil
 
 def groupsstats_1d(y, x, labelsunique):

{"golden_diff": "diff --git a/statsmodels/sandbox/regression/try_catdata.py b/statsmodels/sandbox/regression/try_catdata.py\n--- a/statsmodels/sandbox/regression/try_catdata.py\n+++ b/statsmodels/sandbox/regression/try_catdata.py\n@@ -58,7 +58,7 @@\n def labelmeanfilter_str(ys, x):\n     # works also for string labels in ys, but requires 1D\n     # from mailing list scipy-user 2009-02-11\n-    unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)\n+    unil, unilinv = np.unique(ys, return_index=False, return_inverse=True)\n     labelmeans = np.array(ndimage.mean(x, labels=unilinv, index=np.arange(np.max(unil)+1)))\n     arr3 = labelmeans[unilinv]\n     return arr3\n@@ -67,7 +67,7 @@\n     '''uses np.bincount, assumes factors/labels are integers\n     '''\n     n = len(factors)\n-    ix,rind = np.unique1d(factors, return_inverse=1)\n+    ix,rind = np.unique(factors, return_inverse=1)\n     gcount = np.bincount(rind)\n     gmean = np.bincount(rind, weights=values)/ (1.0*gcount)\n     meanarr = gmean[rind]\n@@ -93,7 +93,7 @@\n             # there might be a problem here\n             ylabel = ys\n \n-    unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)\n+    unil, unilinv = np.unique(ylabel, return_index=False, return_inverse=True)\n     return unilinv, np.arange(len(unil)), unil\n \n def groupsstats_1d(y, x, labelsunique):\n", "issue": "(untested) use of deprecated numpy.unique1d\nOriginal report: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=659405\n\n```\nstatsmodels/sandbox/regression/try_catdata.py:    unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)\nstatsmodels/sandbox/regression/try_catdata.py:    ix,rind = np.unique1d(factors, return_inverse=1)\nstatsmodels/sandbox/regression/try_catdata.py:    unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)\n```\n\n```\n$> python -c 'import numpy as np; print np.__version__; print np.unique1d'\n1.7.1\nTraceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nAttributeError: 'module' object has no attribute 'unique1d'\n```\n\n", "before_files": [{"content": "from statsmodels.compat.python import lrange\nimport numpy as np\n#from numpy import linalg as npla\nfrom scipy import stats, optimize\n\n'''\nWorking with categorical data\n=============================\n\nuse of dummy variables, group statistics, within and between statistics\nexamples for efficient matrix algebra\n\ndummy versions require that the number of unique groups or categories is not too large\ngroup statistics with scipy.ndimage can handle large number of observations and groups\nscipy.ndimage stats is missing count\n\nnew: np.bincount can also be used for calculating values per label\n'''\n\nfrom scipy import ndimage\n\n#problem: ndimage does not allow axis argument,\n#   calculates mean or var corresponding to axis=None in np.mean, np.var\n#   useless for multivariate application\n\ndef labelmeanfilter(y, x):\n   # requires integer labels\n   # from mailing list scipy-user 2009-02-11\n   labelsunique = np.arange(np.max(y)+1)\n   labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))\n   # returns label means for each original observation\n   return labelmeans[y]\n\n#groupcount: i.e. number of observation by group/label\n#np.array(ndimage.histogram(yrvs[:,0],0,10,1,labels=yrvs[:,0],index=np.unique(yrvs[:,0])))\n\ndef labelmeanfilter_nd(y, x):\n   # requires integer labels\n   # from mailing list scipy-user 2009-02-11\n   # adjusted for 2d x with column variables\n\n   labelsunique = np.arange(np.max(y)+1)\n   labmeansdata = []\n   labmeans = []\n\n   for xx in x.T:\n      labelmeans = np.array(ndimage.mean(xx, labels=y, index=labelsunique))\n      labmeansdata.append(labelmeans[y])\n      labmeans.append(labelmeans)\n   # group count:\n   labelcount = np.array(ndimage.histogram(y, labelsunique[0], labelsunique[-1]+1,\n                        1, labels=y, index=labelsunique))\n\n   # returns array of lable/group counts and of label/group means\n   #         and label/group means for each original observation\n   return labelcount, np.array(labmeans), np.array(labmeansdata).T\n\ndef labelmeanfilter_str(ys, x):\n    # works also for string labels in ys, but requires 1D\n    # from mailing list scipy-user 2009-02-11\n    unil, unilinv = np.unique1d(ys, return_index=False, return_inverse=True)\n    labelmeans = np.array(ndimage.mean(x, labels=unilinv, index=np.arange(np.max(unil)+1)))\n    arr3 = labelmeans[unilinv]\n    return arr3\n\ndef groupstatsbin(factors, values):\n    '''uses np.bincount, assumes factors/labels are integers\n    '''\n    n = len(factors)\n    ix,rind = np.unique1d(factors, return_inverse=1)\n    gcount = np.bincount(rind)\n    gmean = np.bincount(rind, weights=values)/ (1.0*gcount)\n    meanarr = gmean[rind]\n    withinvar = np.bincount(rind, weights=(values-meanarr)**2) / (1.0*gcount)\n    withinvararr = withinvar[rind]\n    return gcount, gmean , meanarr, withinvar, withinvararr\n\n\ndef convertlabels(ys, indices=None):\n    '''convert labels based on multiple variables or string labels to unique\n    index labels 0,1,2,...,nk-1 where nk is the number of distinct labels\n    '''\n    if indices == None:\n        ylabel = ys\n    else:\n        idx = np.array(indices)\n        if idx.size > 1 and ys.ndim == 2:\n            ylabel = np.array(['@%s@'%ii[:2].tostring() for ii in ys])[:,np.newaxis]\n            #alternative\n    ##        if ys[:,idx].dtype.kind == 'S':\n    ##            ylabel = nd.array([' '.join(ii[:2]) for ii in ys])[:,np.newaxis]\n        else:\n            # there might be a problem here\n            ylabel = ys\n\n    unil, unilinv = np.unique1d(ylabel, return_index=False, return_inverse=True)\n    return unilinv, np.arange(len(unil)), unil\n\ndef groupsstats_1d(y, x, labelsunique):\n    '''use ndimage to get fast mean and variance'''\n    labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))\n    labelvars = np.array(ndimage.var(x, labels=y, index=labelsunique))\n    return labelmeans, labelvars\n\ndef cat2dummy(y, nonseq=0):\n    if nonseq or (y.ndim == 2 and y.shape[1] > 1):\n        ycat, uniques, unitransl =  convertlabels(y, lrange(y.shape[1]))\n    else:\n        ycat = y.copy()\n        ymin = y.min()\n        uniques = np.arange(ymin,y.max()+1)\n    if ycat.ndim == 1:\n        ycat = ycat[:,np.newaxis]\n    # this builds matrix nobs*ncat\n    dummy = (ycat == uniques).astype(int)\n    return dummy\n\ndef groupsstats_dummy(y, x, nonseq=0):\n    if x.ndim == 1:\n        # use groupsstats_1d\n        x = x[:,np.newaxis]\n    dummy = cat2dummy(y, nonseq=nonseq)\n    countgr = dummy.sum(0, dtype=float)\n    meangr = np.dot(x.T,dummy)/countgr\n    meandata = np.dot(dummy,meangr.T) # category/group means as array in shape of x\n    xdevmeangr = x - meandata  # deviation from category/group mean\n    vargr = np.dot((xdevmeangr * xdevmeangr).T, dummy) / countgr\n    return meangr, vargr, xdevmeangr, countgr\n\n\nif __name__ == '__main__':\n   pass\n", "path": "statsmodels/sandbox/regression/try_catdata.py"}], "after_files": [{"content": "from statsmodels.compat.python import lrange\nimport numpy as np\n#from numpy import linalg as npla\nfrom scipy import stats, optimize\n\n'''\nWorking with categorical data\n=============================\n\nuse of dummy variables, group statistics, within and between statistics\nexamples for efficient matrix algebra\n\ndummy versions require that the number of unique groups or categories is not too large\ngroup statistics with scipy.ndimage can handle large number of observations and groups\nscipy.ndimage stats is missing count\n\nnew: np.bincount can also be used for calculating values per label\n'''\n\nfrom scipy import ndimage\n\n#problem: ndimage does not allow axis argument,\n#   calculates mean or var corresponding to axis=None in np.mean, np.var\n#   useless for multivariate application\n\ndef labelmeanfilter(y, x):\n   # requires integer labels\n   # from mailing list scipy-user 2009-02-11\n   labelsunique = np.arange(np.max(y)+1)\n   labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))\n   # returns label means for each original observation\n   return labelmeans[y]\n\n#groupcount: i.e. number of observation by group/label\n#np.array(ndimage.histogram(yrvs[:,0],0,10,1,labels=yrvs[:,0],index=np.unique(yrvs[:,0])))\n\ndef labelmeanfilter_nd(y, x):\n   # requires integer labels\n   # from mailing list scipy-user 2009-02-11\n   # adjusted for 2d x with column variables\n\n   labelsunique = np.arange(np.max(y)+1)\n   labmeansdata = []\n   labmeans = []\n\n   for xx in x.T:\n      labelmeans = np.array(ndimage.mean(xx, labels=y, index=labelsunique))\n      labmeansdata.append(labelmeans[y])\n      labmeans.append(labelmeans)\n   # group count:\n   labelcount = np.array(ndimage.histogram(y, labelsunique[0], labelsunique[-1]+1,\n                        1, labels=y, index=labelsunique))\n\n   # returns array of lable/group counts and of label/group means\n   #         and label/group means for each original observation\n   return labelcount, np.array(labmeans), np.array(labmeansdata).T\n\ndef labelmeanfilter_str(ys, x):\n    # works also for string labels in ys, but requires 1D\n    # from mailing list scipy-user 2009-02-11\n    unil, unilinv = np.unique(ys, return_index=False, return_inverse=True)\n    labelmeans = np.array(ndimage.mean(x, labels=unilinv, index=np.arange(np.max(unil)+1)))\n    arr3 = labelmeans[unilinv]\n    return arr3\n\ndef groupstatsbin(factors, values):\n    '''uses np.bincount, assumes factors/labels are integers\n    '''\n    n = len(factors)\n    ix,rind = np.unique(factors, return_inverse=1)\n    gcount = np.bincount(rind)\n    gmean = np.bincount(rind, weights=values)/ (1.0*gcount)\n    meanarr = gmean[rind]\n    withinvar = np.bincount(rind, weights=(values-meanarr)**2) / (1.0*gcount)\n    withinvararr = withinvar[rind]\n    return gcount, gmean , meanarr, withinvar, withinvararr\n\n\ndef convertlabels(ys, indices=None):\n    '''convert labels based on multiple variables or string labels to unique\n    index labels 0,1,2,...,nk-1 where nk is the number of distinct labels\n    '''\n    if indices == None:\n        ylabel = ys\n    else:\n        idx = np.array(indices)\n        if idx.size > 1 and ys.ndim == 2:\n            ylabel = np.array(['@%s@'%ii[:2].tostring() for ii in ys])[:,np.newaxis]\n            #alternative\n    ##        if ys[:,idx].dtype.kind == 'S':\n    ##            ylabel = nd.array([' '.join(ii[:2]) for ii in ys])[:,np.newaxis]\n        else:\n            # there might be a problem here\n            ylabel = ys\n\n    unil, unilinv = np.unique(ylabel, return_index=False, return_inverse=True)\n    return unilinv, np.arange(len(unil)), unil\n\ndef groupsstats_1d(y, x, labelsunique):\n    '''use ndimage to get fast mean and variance'''\n    labelmeans = np.array(ndimage.mean(x, labels=y, index=labelsunique))\n    labelvars = np.array(ndimage.var(x, labels=y, index=labelsunique))\n    return labelmeans, labelvars\n\ndef cat2dummy(y, nonseq=0):\n    if nonseq or (y.ndim == 2 and y.shape[1] > 1):\n        ycat, uniques, unitransl =  convertlabels(y, lrange(y.shape[1]))\n    else:\n        ycat = y.copy()\n        ymin = y.min()\n        uniques = np.arange(ymin,y.max()+1)\n    if ycat.ndim == 1:\n        ycat = ycat[:,np.newaxis]\n    # this builds matrix nobs*ncat\n    dummy = (ycat == uniques).astype(int)\n    return dummy\n\ndef groupsstats_dummy(y, x, nonseq=0):\n    if x.ndim == 1:\n        # use groupsstats_1d\n        x = x[:,np.newaxis]\n    dummy = cat2dummy(y, nonseq=nonseq)\n    countgr = dummy.sum(0, dtype=float)\n    meangr = np.dot(x.T,dummy)/countgr\n    meandata = np.dot(dummy,meangr.T) # category/group means as array in shape of x\n    xdevmeangr = x - meandata  # deviation from category/group mean\n    vargr = np.dot((xdevmeangr * xdevmeangr).T, dummy) / countgr\n    return meangr, vargr, xdevmeangr, countgr\n\n\nif __name__ == '__main__':\n   pass\n", "path": "statsmodels/sandbox/regression/try_catdata.py"}]}