File tree 2 files changed +18
-3
lines changed
2 files changed +18
-3
lines changed Original file line number Diff line number Diff line change 5
5
:doc:`uproot.exceptions.KeyInFileError`.
6
6
"""
7
7
8
-
9
8
import uproot
10
9
11
10
11
+ class NameConflictWarning (Warning ):
12
+ pass
13
+
14
+
12
15
class KeyInFileError (KeyError ):
13
16
"""
14
17
Exception raised by attempts to find ROOT objects in ``TDirectories``
Original file line number Diff line number Diff line change 10
10
11
11
12
12
import ast
13
+ import warnings
13
14
14
15
import numpy
15
16
@@ -402,16 +403,27 @@ def compute_expressions(
402
403
arrays (dict of arrays): Inputs to the computation.
403
404
expression_context (list of (str, dict) tuples): Expression strings
404
405
and a dict of metadata about each.
405
- keys (list of str): Names of branches or aliases (for aliases that
406
+ keys (set of str): Names of branches or aliases (for aliases that
406
407
refer to aliases).
407
- aliases (list of str): Names of aliases.
408
+ aliases (dict of str \u2192 str ): Names of aliases and their definitions .
408
409
file_path (str): File path for error messages.
409
410
object_path (str): Object path for error messages.
410
411
411
412
Computes an array for each expression.
412
413
"""
413
414
values = {}
414
415
416
+ if len (aliases ) < len (keys ):
417
+ shorter , longer = aliases , keys
418
+ else :
419
+ shorter , longer = keys , aliases
420
+ for x in shorter :
421
+ if x in longer :
422
+ warnings .warn (
423
+ f"{ x !r} is both an alias and a branch name" ,
424
+ uproot .exceptions .NameConflictWarning ,
425
+ )
426
+
415
427
def getter (name ):
416
428
if name not in values :
417
429
values [name ] = _expression_to_function (
You can’t perform that action at this time.
0 commit comments