Skip to content
This repository was archived by the owner on Nov 17, 2025. It is now read-only.

Commit e137dd8

Browse files
Update pre-commit config
1 parent 5268d20 commit e137dd8

168 files changed

Lines changed: 75 additions & 562 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.pre-commit-config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ repos:
1818
)$
1919
- id: check-merge-conflict
2020
- repo: https://github.com/psf/black
21-
rev: 22.12.0
21+
rev: 23.1.0
2222
hooks:
2323
- id: black
2424
language_version: python3
@@ -47,7 +47,7 @@ repos:
4747
)$
4848
args: ['--in-place', '--remove-all-unused-imports', '--remove-unused-variable']
4949
- repo: https://github.com/pre-commit/mirrors-mypy
50-
rev: v0.991
50+
rev: v1.1.1
5151
hooks:
5252
- id: mypy
5353
additional_dependencies:

aesara/breakpoint.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,6 @@ def __init__(self, name):
6969
self.name = name
7070

7171
def make_node(self, condition, *monitored_vars):
72-
7372
# Ensure that condition is an Aesara tensor
7473
if not isinstance(condition, Variable):
7574
condition = as_tensor_variable(condition)
@@ -150,7 +149,6 @@ def infer_shape(self, fgraph, inputs, input_shapes):
150149
return input_shapes[1:]
151150

152151
def connection_pattern(self, node):
153-
154152
nb_inp = len(node.inputs)
155153
nb_out = nb_inp - 1
156154

aesara/compile/builders.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -953,7 +953,6 @@ def connection_pattern(self, node):
953953
return list(map(list, cpmat_self))
954954

955955
def infer_shape(self, fgraph, node, shapes):
956-
957956
# TODO: Use `fgraph.shape_feature` to do this instead.
958957
out_shapes = infer_shape(self.inner_outputs, self.inner_inputs, shapes)
959958

aesara/compile/debugmode.py

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -567,7 +567,6 @@ def _check_viewmap(fgraph, node, storage_map):
567567
"""
568568

569569
for oi, onode in enumerate(node.outputs):
570-
571570
good_alias, bad_alias = {}, {}
572571
outstorage = storage_map[onode][0]
573572

@@ -590,13 +589,11 @@ def _check_viewmap(fgraph, node, storage_map):
590589
if hasattr(inode.type, "may_share_memory") and inode.type.may_share_memory(
591590
outstorage, in_storage
592591
):
593-
594592
nodeid = id(inode)
595593
bad_alias[nodeid] = ii
596594

597595
# check that the aliasing was declared in [view|destroy]_map
598596
if [ii] == view_map.get(oi, None) or [ii] == destroy_map.get(oi, None):
599-
600597
good_alias[nodeid] = bad_alias.pop(nodeid)
601598

602599
# TODO: make sure this is correct
@@ -1010,7 +1007,7 @@ def _check_preallocated_output(
10101007
aliased_inputs.add(r)
10111008

10121009
_logger.debug("starting preallocated output checking")
1013-
for (name, out_map) in _get_preallocated_maps(
1010+
for name, out_map in _get_preallocated_maps(
10141011
node,
10151012
thunk,
10161013
prealloc_modes,
@@ -1180,7 +1177,6 @@ class _VariableEquivalenceTracker(Feature):
11801177
"""
11811178

11821179
def on_attach(self, fgraph):
1183-
11841180
if hasattr(fgraph, "_eq_tracker_equiv"):
11851181
raise AlreadyThere()
11861182

@@ -1675,7 +1671,6 @@ def f():
16751671
sys.stdout.flush()
16761672

16771673
if thunk_c:
1678-
16791674
clobber = True
16801675
if thunk_py:
16811676
dmap = node.op.destroy_map

aesara/compile/function/pfunc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ def clone_inputs(i):
176176
# Fill update_d and update_expr with provided updates
177177
if updates is None:
178178
updates = []
179-
for (store_into, update_val) in iter_over_pairs(updates):
179+
for store_into, update_val in iter_over_pairs(updates):
180180
if not isinstance(store_into, SharedVariable):
181181
raise TypeError("update target must be a SharedVariable", store_into)
182182
if store_into in update_d:
@@ -471,7 +471,6 @@ def construct_pfunc_ins_and_outs(
471471
)
472472

473473
if not fgraph:
474-
475474
# Extend the outputs with the updates on input variables so they are
476475
# also cloned
477476
additional_outputs = [i.update for i in inputs if i.update]

aesara/compile/function/types.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -597,6 +597,7 @@ def copy(
597597
aesara.Function
598598
Copied aesara.Function
599599
"""
600+
600601
# helper function
601602
def checkSV(sv_ori, sv_rpl):
602603
"""
@@ -761,7 +762,6 @@ def checkSV(sv_ori, sv_rpl):
761762
for in_ori, in_cpy, ori, cpy in zip(
762763
maker.inputs, f_cpy.maker.inputs, self.input_storage, f_cpy.input_storage
763764
):
764-
765765
# Share immutable ShareVariable and constant input's storage
766766
swapped = swap is not None and in_ori.variable in swap
767767

@@ -911,7 +911,6 @@ def restore_defaults():
911911
if hasattr(i_var.type, "may_share_memory"):
912912
is_aliased = False
913913
for j in range(len(args_share_memory)):
914-
915914
group_j = zip(
916915
[
917916
self.maker.inputs[k].variable
@@ -929,7 +928,6 @@ def restore_defaults():
929928
)
930929
for (var, val) in group_j
931930
):
932-
933931
is_aliased = True
934932
args_share_memory[j].append(i)
935933
break
@@ -1057,9 +1055,7 @@ def restore_defaults():
10571055
elif self.unpack_single and len(outputs) == 1 and output_subset is None:
10581056
return outputs[0]
10591057
else:
1060-
10611058
if self.output_keys is not None:
1062-
10631059
assert len(self.output_keys) == len(outputs)
10641060

10651061
if output_subset is None:
@@ -1452,7 +1448,6 @@ def prepare_fgraph(
14521448
update = fgraph_outputs[out_idx]
14531449

14541450
if update.owner and update.owner.op == update_placeholder:
1455-
14561451
# TODO: Consider removing the corresponding
14571452
# `FunctionGraph` input when it has no other
14581453
# references?
@@ -1479,7 +1474,6 @@ def prepare_fgraph(
14791474
# Add deep copy to respect the memory interface
14801475
insert_deepcopy(fgraph, inputs, outputs + additional_outputs)
14811476
finally:
1482-
14831477
# If the rewriter got interrupted
14841478
if rewrite_time is None:
14851479
end_rewriter = time.perf_counter()
@@ -1658,7 +1652,6 @@ def create(self, input_storage=None, trustme=False, storage_map=None):
16581652
for i, ((input, indices, subinputs), input_storage_i) in enumerate(
16591653
zip(self.indices, input_storage)
16601654
):
1661-
16621655
# Replace any default value given as a variable by its
16631656
# container. Note that this makes sense only in the
16641657
# context of shared variables, but for now we avoid

aesara/compile/profiling.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@ def _atexit_print_fn():
6565
destination_file = config.profiling__destination
6666

6767
with extended_open(destination_file, mode="w"):
68-
6968
# Reverse sort in the order of compile+exec time
7069
for ps in sorted(
7170
_atexit_print_list, key=lambda a: a.compile_time + a.fct_call_time
@@ -358,7 +357,7 @@ def class_impl(self):
358357
"""
359358
# timing is stored by node, we compute timing by class on demand
360359
rval = {}
361-
for (fgraph, node) in self.apply_callcount:
360+
for fgraph, node in self.apply_callcount:
362361
typ = type(node.op)
363362
if self.apply_cimpl[node]:
364363
impl = "C "
@@ -401,7 +400,7 @@ def compute_total_times(self):
401400
402401
"""
403402
rval = {}
404-
for (fgraph, node) in self.apply_time:
403+
for fgraph, node in self.apply_time:
405404
if node not in rval:
406405
self.fill_node_total_time(fgraph, node, rval)
407406
return rval
@@ -437,7 +436,7 @@ def op_impl(self):
437436
"""
438437
# timing is stored by node, we compute timing by Op on demand
439438
rval = {}
440-
for (fgraph, node) in self.apply_callcount:
439+
for fgraph, node in self.apply_callcount:
441440
if self.apply_cimpl[node]:
442441
rval[node.op] = "C "
443442
else:
@@ -711,7 +710,7 @@ def summary_nodes(self, file=sys.stderr, N=None):
711710

712711
atimes.sort(reverse=True, key=lambda t: (t[1], t[3]))
713712
tot = 0
714-
for (f, t, a, nd_id, nb_call) in atimes[:N]:
713+
for f, t, a, nd_id, nb_call in atimes[:N]:
715714
tot += t
716715
ftot = tot * 100 / local_time
717716
if nb_call == 0:
@@ -840,7 +839,7 @@ def summary_memory(self, file, N=None):
840839
var_mem = {} # variable->size in bytes; don't include input variables
841840
node_mem = {} # (fgraph, node)->total outputs size (only dense outputs)
842841

843-
for (fgraph, node) in self.apply_callcount:
842+
for fgraph, node in self.apply_callcount:
844843
fct_memory.setdefault(fgraph, {})
845844
fct_memory[fgraph].setdefault(node, [])
846845
fct_shapes.setdefault(fgraph, {})
@@ -1611,7 +1610,7 @@ def exp_float32_op(op):
16111610
printed_tip = True
16121611

16131612
# tip 4
1614-
for (fgraph, a) in self.apply_time:
1613+
for fgraph, a in self.apply_time:
16151614
node = a
16161615
if isinstance(node.op, Dot) and all(
16171616
len(i.type.broadcastable) == 2 for i in node.inputs
@@ -1628,7 +1627,7 @@ def exp_float32_op(op):
16281627
printed_tip = True
16291628

16301629
# tip 5
1631-
for (fgraph, a) in self.apply_time:
1630+
for fgraph, a in self.apply_time:
16321631
node = a
16331632
if isinstance(node.op, RandomVariable):
16341633
printed_tip = True
@@ -1642,7 +1641,7 @@ def exp_float32_op(op):
16421641
break
16431642

16441643
# tip 6
1645-
for (fgraph, a) in self.apply_time:
1644+
for fgraph, a in self.apply_time:
16461645
node = a
16471646
if isinstance(node.op, Dot) and len({i.dtype for i in node.inputs}) != 1:
16481647
print(

aesara/configdefaults.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,6 @@ def short_platform(r=None, p=None):
278278

279279

280280
def add_basic_configvars():
281-
282281
config.add(
283282
"floatX",
284283
"Default floating-point precision for python casts.\n"
@@ -388,7 +387,6 @@ def _is_greater_or_equal_0(x):
388387

389388

390389
def add_compile_configvars():
391-
392390
config.add(
393391
"mode",
394392
"Default compilation mode",
@@ -631,7 +629,6 @@ def _is_valid_cmp_sloppy(v):
631629

632630

633631
def add_tensor_configvars():
634-
635632
# This flag is used when we import Aesara to initialize global variables.
636633
# So changing it after import will not modify these global variables.
637634
# This could be done differently... but for now we simply prevent it from being
@@ -717,7 +714,6 @@ def add_experimental_configvars():
717714

718715

719716
def add_error_and_warning_configvars():
720-
721717
###
722718
# To disable some warning about old bug that are fixed now.
723719
###
@@ -1196,7 +1192,6 @@ def add_vm_configvars():
11961192

11971193

11981194
def add_deprecated_configvars():
1199-
12001195
# TODO: remove this?
12011196
config.add(
12021197
"unittests__rseed",

aesara/gradient.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,6 @@ def Rop(
229229
# Check that each element of wrt corresponds to an element
230230
# of eval_points with the same dimensionality.
231231
for i, (wrt_elem, eval_point) in enumerate(zip(_wrt, _eval_points)):
232-
233232
try:
234233
if wrt_elem.type.ndim != eval_point.type.ndim:
235234
raise ValueError(
@@ -266,7 +265,6 @@ def _traverse(node):
266265
# arguments, like for example random states
267266
local_eval_points.append(None)
268267
elif inp.owner in seen_nodes:
269-
270268
local_eval_points.append(
271269
seen_nodes[inp.owner][inp.owner.outputs.index(inp)]
272270
)
@@ -941,7 +939,6 @@ def account_for(var):
941939
var_idx = app.outputs.index(var)
942940

943941
for i, ipt in enumerate(app.inputs):
944-
945942
# don't process ipt if it is not a true
946943
# parent of var
947944
if not connection_pattern[i][var_idx]:
@@ -1052,7 +1049,6 @@ def access_term_cache(node):
10521049
"""Populates term_dict[node] and returns it"""
10531050

10541051
if node not in term_dict:
1055-
10561052
inputs = node.inputs
10571053

10581054
output_grads = [access_grad_cache(var) for var in node.outputs]
@@ -1267,7 +1263,6 @@ def try_to_copy_if_needed(var):
12671263
]
12681264

12691265
for i, term in enumerate(input_grads):
1270-
12711266
# Disallow Nones
12721267
if term is None:
12731268
# We don't know what None means. in the past it has been
@@ -1383,7 +1378,6 @@ def access_grad_cache(var):
13831378
node_to_idx = var_to_app_to_idx[var]
13841379
for node in node_to_idx:
13851380
for idx in node_to_idx[node]:
1386-
13871381
term = access_term_cache(node)[idx]
13881382

13891383
if not isinstance(term, Variable):
@@ -1868,7 +1862,6 @@ def random_projection():
18681862
)
18691863

18701864
if max_abs_err > abs_tol and max_rel_err > rel_tol:
1871-
18721865
raise GradientError(
18731866
max_arg,
18741867
max_err_pos,
@@ -2052,7 +2045,6 @@ def hessian(cost, wrt, consider_constant=None, disconnected_inputs="raise"):
20522045

20532046
hessians = []
20542047
for input in wrt:
2055-
20562048
if not isinstance(input, Variable):
20572049
raise TypeError("hessian expects a (list of) Variable as `wrt`")
20582050

0 commit comments

Comments
 (0)