|
14 | 14 | import six |
15 | 15 | import numpy as np |
16 | 16 | from patsy import PatsyError |
17 | | -from patsy.compat import triu_indices, tril_indices, diag_indices |
18 | 17 | from patsy.util import (repr_pretty_delegate, repr_pretty_impl, |
19 | 18 | safe_issubdtype, |
20 | 19 | no_pickling, assert_no_pickling) |
@@ -479,8 +478,8 @@ def _helmert_contrast(self, levels): |
479 | 478 |
|
480 | 479 | #r-like |
481 | 480 | contr = np.zeros((n, n - 1)) |
482 | | - contr[1:][diag_indices(n - 1)] = np.arange(1, n) |
483 | | - contr[triu_indices(n - 1)] = -1 |
| 481 | + contr[1:][np.diag_indices(n - 1)] = np.arange(1, n) |
| 482 | + contr[np.triu_indices(n - 1)] = -1 |
484 | 483 | return contr |
485 | 484 |
|
486 | 485 | def code_with_intercept(self, levels): |
@@ -539,14 +538,14 @@ def _diff_contrast(self, levels): |
539 | 538 | contr = np.zeros((nlevels, nlevels-1)) |
540 | 539 | int_range = np.arange(1, nlevels) |
541 | 540 | upper_int = np.repeat(int_range, int_range) |
542 | | - row_i, col_i = triu_indices(nlevels-1) |
| 541 | + row_i, col_i = np.triu_indices(nlevels-1) |
543 | 542 | # we want to iterate down the columns not across the rows |
544 | 543 | # it would be nice if the index functions had a row/col order arg |
545 | 544 | col_order = np.argsort(col_i) |
546 | 545 | contr[row_i[col_order], |
547 | 546 | col_i[col_order]] = (upper_int-nlevels)/float(nlevels) |
548 | 547 | lower_int = np.repeat(int_range, int_range[::-1]) |
549 | | - row_i, col_i = tril_indices(nlevels-1) |
| 548 | + row_i, col_i = np.tril_indices(nlevels-1) |
550 | 549 | # we want to iterate down the columns not across the rows |
551 | 550 | col_order = np.argsort(col_i) |
552 | 551 | contr[row_i[col_order]+1, col_i[col_order]] = lower_int/float(nlevels) |
|
0 commit comments