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 1111# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212# See the License for the specific language governing permissions and
1313# limitations under the License.
14+ import itertools
1415import warnings
1516
1617import numpy as np
@@ -480,7 +481,7 @@ def transform_warning():
480481 transform .backward (value , * component .owner .inputs )
481482 for transform , component in zip (default_transforms , components )
482483 ]
483- for expr1 , expr2 in zip (backward_expressions [: - 1 ], backward_expressions [ 1 :] ):
484+ for expr1 , expr2 in itertools . pairwise (backward_expressions ):
484485 if not equal_computations ([expr1 ], [expr2 ]):
485486 transform_warning ()
486487 return None
Original file line number Diff line number Diff line change 1313# limitations under the License.
1414
1515import functools as ft
16+ import itertools
1617import sys
1718import warnings
1819
@@ -76,7 +77,7 @@ def invlogit(x, eps=sys.float_info.epsilon):
7677
7778def orderedlogistic_logpdf (value , eta , cutpoints ):
7879 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 )])
8081 p = ps [value ]
8182 return np .where (np .all (ps >= 0 ), np .log (p ), - np .inf )
8283
@@ -87,7 +88,7 @@ def invprobit(x):
8788
8889def orderedprobit_logpdf (value , eta , cutpoints ):
8990 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 )])
9192 p = ps [value ]
9293 return np .where (np .all (ps >= 0 ), np .log (p ), - np .inf )
9394
You can’t perform that action at this time.
0 commit comments