Skip to content

Commit 5cbd3df

Browse files
ArmavicaricardoV94
authored andcommitted
Fix more double negatives
1 parent f9f930c commit 5cbd3df

File tree

12 files changed

+14
-14
lines changed

12 files changed

+14
-14
lines changed

pytensor/compile/compiledir.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def cleanup():
6565
have_npy_abi_version = False
6666
break
6767

68-
if not have_npy_abi_version or not have_c_compiler:
68+
if not (have_npy_abi_version and have_c_compiler):
6969
try:
7070
# This can happen when we move the compiledir.
7171
if keydata.key_pkl != filename:

pytensor/compile/debugmode.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,7 @@ def _check_preallocated_output(
980980
changed_inner_mode = False
981981
if isinstance(getattr(node, "op", None), HasInnerGraph):
982982
fn = node.op.fn
983-
if not fn or not hasattr(fn, "maker") or not hasattr(fn.maker, "mode"):
983+
if not (fn and hasattr(fn, "maker") and hasattr(fn.maker, "mode")):
984984
_logger.warning(f"Expected pytensor function not found in {node.op}.fn")
985985
else:
986986
if isinstance(fn.maker.mode, DebugMode):

pytensor/graph/rewriting/basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3073,7 +3073,7 @@ def check_stack_trace(f_or_fgraph, ops_to_check="last", bug_print="raise"):
30733073

30743074
for node in apply_nodes_to_check:
30753075
for output in node.outputs:
3076-
if not hasattr(output.tag, "trace") or not output.tag.trace:
3076+
if not (hasattr(output.tag, "trace") and output.tag.trace):
30773077
return False
30783078

30793079
return True
@@ -3092,7 +3092,7 @@ def on_import(self, fgraph, node, reason):
30923092
apply_nodes_to_check = fgraph.apply_nodes
30933093
for node in apply_nodes_to_check:
30943094
for output in node.outputs:
3095-
if not hasattr(output.tag, "trace") or not output.tag.trace:
3095+
if not (hasattr(output.tag, "trace") and output.tag.trace):
30963096
output.tag.trace = [
30973097
[
30983098
(

pytensor/link/basic.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ def __init__(
6262
allow_downcast: bool | None = None,
6363
name: str | None = None,
6464
) -> None:
65-
if not isinstance(storage, list) or not len(storage) >= 1:
65+
if not (isinstance(storage, list) and len(storage) >= 1):
6666
raise TypeError("storage must be a list of length at least one")
6767
if isinstance(r, Variable):
6868
self.type = r.type

pytensor/link/c/cmodule.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2288,7 +2288,7 @@ def join_options(init_part):
22882288
default_compilation_result, default_execution_result = try_march_flag(
22892289
GCC_compiler.march_flags
22902290
)
2291-
if not default_compilation_result or not default_execution_result:
2291+
if not (default_compilation_result and default_execution_result):
22922292
march_success = False
22932293
march_ind = None
22942294
mtune_ind = None

pytensor/misc/may_share_memory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ def may_share_memory(a, b, raise_other_type=True):
3030

3131
a_sparse = _is_sparse(a)
3232
b_sparse = _is_sparse(b)
33-
if not (a_ndarray or a_sparse) or not (b_ndarray or b_sparse):
33+
if not ((a_ndarray or a_sparse) and (b_ndarray or b_sparse)):
3434
if raise_other_type:
3535
raise TypeError("may_share_memory support only ndarray and scipy.sparse")
3636
return False

pytensor/printing.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -653,8 +653,8 @@ def get_id_str(
653653
else:
654654
print(var_output, file=file)
655655

656-
if not already_done and (
657-
not stop_on_name or not (hasattr(var, "name") and var.name is not None)
656+
if not already_done and not (
657+
stop_on_name and hasattr(var, "name") and var.name is not None
658658
):
659659
new_prefix = prefix_child + " ├─ "
660660
new_prefix_child = prefix_child + " │ "

pytensor/sparse/type.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ def values_eq_approx(self, a, b, eps=1e-6):
187187
# WARNING: equality comparison of sparse matrices is not fast or easy
188188
# we definitely do not want to be doing this un-necessarily during
189189
# a FAST_RUN computation..
190-
if not scipy.sparse.issparse(a) or not scipy.sparse.issparse(b):
190+
if not (scipy.sparse.issparse(a) and scipy.sparse.issparse(b)):
191191
return False
192192
diff = abs(a - b)
193193
if diff.nnz == 0:

pytensor/tensor/blas_headers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -769,7 +769,7 @@ def blas_header_text():
769769
"npy_float": "NPY_FLOAT64",
770770
"precision": "d",
771771
}
772-
if not common_code or not template_code:
772+
if not (common_code and template_code):
773773
raise OSError(
774774
"Unable to load NumPy implementation of BLAS functions from C source files."
775775
)

pytensor/tensor/rewriting/math.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1016,7 +1016,7 @@ def simplify_factors(self, num, denum):
10161016
for v in inter:
10171017
num.remove(v)
10181018
denum.remove(v)
1019-
if not redo or not inter:
1019+
if not (redo and inter):
10201020
break
10211021
else:
10221022
for v in list(num):

0 commit comments

Comments
 (0)