Skip to content

Commit 51a21be

Browse files
MAINT: random: Simplify a bit of code in 'disc()' in _common.pyx.
Remove 'and is_scalar' from expressions where we know is_scalar is True.
1 parent 98f02a9 commit 51a21be

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

numpy/random/_common.pyx

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -918,31 +918,33 @@ cdef object disc(void *func, void *state, object size, object lock,
918918
else:
919919
raise NotImplementedError("No vector path available")
920920

921+
# At this point, we know is_scalar is True.
922+
921923
if narg_double > 0:
922924
_da = PyFloat_AsDouble(a)
923-
if a_constraint != CONS_NONE and is_scalar:
925+
if a_constraint != CONS_NONE:
924926
check_constraint(_da, a_name, a_constraint)
925927

926928
if narg_double > 1:
927929
_db = PyFloat_AsDouble(b)
928-
if b_constraint != CONS_NONE and is_scalar:
930+
if b_constraint != CONS_NONE:
929931
check_constraint(_db, b_name, b_constraint)
930932
elif narg_int64 == 1:
931933
_ib = <int64_t>b
932-
if b_constraint != CONS_NONE and is_scalar:
934+
if b_constraint != CONS_NONE:
933935
check_constraint(<double>_ib, b_name, b_constraint)
934936
else:
935937
if narg_int64 > 0:
936938
_ia = <int64_t>a
937-
if a_constraint != CONS_NONE and is_scalar:
939+
if a_constraint != CONS_NONE:
938940
check_constraint(<double>_ia, a_name, a_constraint)
939941
if narg_int64 > 1:
940942
_ib = <int64_t>b
941-
if b_constraint != CONS_NONE and is_scalar:
943+
if b_constraint != CONS_NONE:
942944
check_constraint(<double>_ib, b_name, b_constraint)
943945
if narg_int64 > 2:
944946
_ic = <int64_t>c
945-
if c_constraint != CONS_NONE and is_scalar:
947+
if c_constraint != CONS_NONE:
946948
check_constraint(<double>_ic, c_name, c_constraint)
947949

948950
if size is None:

0 commit comments

Comments
 (0)