File tree Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Expand file tree Collapse file tree 2 files changed +5
-3
lines changed Original file line number Diff line number Diff line change 11
11
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
# See the License for the specific language governing permissions and
13
13
# limitations under the License.
14
+ import itertools
14
15
import warnings
15
16
16
17
import numpy as np
@@ -480,7 +481,7 @@ def transform_warning():
480
481
transform .backward (value , * component .owner .inputs )
481
482
for transform , component in zip (default_transforms , components )
482
483
]
483
- for expr1 , expr2 in zip (backward_expressions [: - 1 ], backward_expressions [ 1 :] ):
484
+ for expr1 , expr2 in itertools . pairwise (backward_expressions ):
484
485
if not equal_computations ([expr1 ], [expr2 ]):
485
486
transform_warning ()
486
487
return None
Original file line number Diff line number Diff line change 13
13
# limitations under the License.
14
14
15
15
import functools as ft
16
+ import itertools
16
17
import sys
17
18
import warnings
18
19
@@ -76,7 +77,7 @@ def invlogit(x, eps=sys.float_info.epsilon):
76
77
77
78
def orderedlogistic_logpdf (value , eta , cutpoints ):
78
79
c = np .concatenate (([- np .inf ], cutpoints , [np .inf ]))
79
- ps = np .array ([invlogit (eta - cc ) - invlogit (eta - cc1 ) for cc , cc1 in zip ( c [: - 1 ], c [ 1 :] )])
80
+ ps = np .array ([invlogit (eta - cc ) - invlogit (eta - cc1 ) for cc , cc1 in itertools . pairwise ( c )])
80
81
p = ps [value ]
81
82
return np .where (np .all (ps >= 0 ), np .log (p ), - np .inf )
82
83
@@ -87,7 +88,7 @@ def invprobit(x):
87
88
88
89
def orderedprobit_logpdf (value , eta , cutpoints ):
89
90
c = np .concatenate (([- np .inf ], cutpoints , [np .inf ]))
90
- ps = np .array ([invprobit (eta - cc ) - invprobit (eta - cc1 ) for cc , cc1 in zip ( c [: - 1 ], c [ 1 :] )])
91
+ ps = np .array ([invprobit (eta - cc ) - invprobit (eta - cc1 ) for cc , cc1 in itertools . pairwise ( c )])
91
92
p = ps [value ]
92
93
return np .where (np .all (ps >= 0 ), np .log (p ), - np .inf )
93
94
You can’t perform that action at this time.
0 commit comments