This repository has been archived by the owner on Jun 21, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 67
/
_help.py
2551 lines (1744 loc) · 89.3 KB
/
_help.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
# BSD 3-Clause License; see https://github.com/scikit-hep/uproot/blob/master/LICENSE
from __future__ import absolute_import
import uproot
import uproot._connect._pandas
def _method(x):
if hasattr(x, "__func__"):
return x.__func__
else:
return x
################################################################ uproot.rootio fragments
open_fragments = {
# localsource
"localsource": u"""localsource : function: path \u21d2 :py:class:`Source <uproot.source.source.Source> or ``dict`` of keyword arguments`
function that will be applied to the path to produce an uproot :py:class:`Source <uproot.source.source.Source>` object if the path is a local file. Default is ``MemmapSource.defaults`` for memory-mapped files. If a ``dict``, the ``dict`` is passed as keyword arguments to :py:class:`MemmapSource <uproot.source.memmap.MemmapSource>` constructor.""",
# xrootdsource
"xrootdsource": u"""xrootdsource : function: path \u21d2 :py:class:`Source <uproot.source.source.Source> or ``dict`` of keyword arguments`
function that will be applied to the path to produce an uproot :py:class:`Source <uproot.source.source.Source>` object if the path is an XRootD URL. Default is ``uproot.source.xrootd.XRootDSource.defaults`` for XRootD with default chunk size/caching. (See :py:class:`XRootDSource <uproot.source.xrootd.XRootDSource>` constructor for details.) If a ``dict``, the ``dict`` is passed as keyword arguments to :py:class:`XRootDSource <uproot.source.xrootd.XRootDSource>` constructor.""",
# httpsource
"httpsource": u"""httpsource : function: path \u21d2 :py:class:`Source <uproot.source.source.Source> or ``dict`` of keyword arguments`
function that will be applied to the path to produce an uproot :py:class:`Source <uproot.source.source.Source>` object if the path is an HTTP URL. Default is ``uproot.source.http.HTTPSource.defaults`` for HTTP with default chunk size/caching. (See :py:class:`HTTPSource <uproot.source.http.HTTPSource>` constructor for details.) If a ``dict``, the ``dict`` is passed as keyword arguments to :py:class:`HTTPSource <uproot.source.http.HTTPSource>` constructor.""",
# options
"options": u"""options
passed to :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>` constructor.""",
}
rootdirectory_fragments = {
# recursive
"recursive": u"""recursive : bool
if ``False`` *(default)*, only iterate over this directory level; if ``True``, depth-first iterate over all subdirectories as well.""",
# filtername
"filtername": u"""filtername : function: str \u21d2 bool
only keys for which ``filtername(name)`` returns ``True`` are returned (does not eliminate subdirectories if ``recursive=True``). Default returns ``True`` for all input.""",
# filterclass
"filterclass": u"""filterclass : function: class object \u21d2 bool
only keys for which ``filterclass(class object)`` returns ``True`` are returned (does not eliminate subdirectories if ``recursive=True``). Default returns ``True`` for all input. Note that all class objects passed to this function have a ``classname`` attribute for the C++ class name (may differ from the Python class name for syntactic reasons).""",
}
################################################################ uproot.rootio.open
uproot.rootio.open.__doc__ = \
u"""Opens a ROOT file (local or remote), specified by file path.
Parameters
----------
path : str
local file path or URL specifying the location of a file (note: not a Python file object!). If the URL schema is "root://", :py:func:`xrootd <uproot.xrootd>` will be called; if "http://", :py:func:`http <uproot.http>` will be called.
{localsource}
{xrootdsource}
{httpsource}
{options}
Returns
-------
:py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`
top-level directory of the ROOT file.
Notes
-----
The ROOTDirectory returned by this function is not necessarily an open file. File handles are managed internally by :py:class:`Source <uproot.source.source.Source>` objects to permit parallel reading. Although this function can be used in a ``with`` construct (which protects against unclosed files), the ``with`` construct has no meaning when applied to this function. Files will be opened or closed as needed to read data on demand.
""".format(**open_fragments)
################################################################ uproot.rootio.xrootd
uproot.rootio.xrootd.__doc__ = \
u"""Opens a remote ROOT file with XRootD (if installed).
Parameters
----------
path : str
URL specifying the location of a file.
{xrootdsource}
{options}
Returns
-------
:py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`
top-level directory of the ROOT file.
""".format(**open_fragments)
################################################################ uproot.rootio.http
uproot.rootio.http.__doc__ = \
u"""Opens a remote ROOT file with HTTP (if ``requests`` is installed).
Parameters
----------
path : str
URL specifying the location of a file.
{httpsource}
{options}
Returns
-------
:py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`
top-level directory of the ROOT file.
""".format(**open_fragments)
################################################################ uproot.rootio.ROOTDirectory
uproot.rootio.ROOTDirectory.__doc__ = \
u"""Represents a ROOT file or directory, an entry point for reading objects.
Although this class has a constructor that could be called by a user, objects are usually created from ROOT files through :py:func:`open <uproot.rootio.open>` or :py:func:`xrootd <uproot.rootio.xrootd>`.
:py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>` objects may be accessed as Python containers:
- square brackets (``__getitem__``) read objects from the file by key name (see :py:meth:`get <uproot.rootio.ROOTDirectory.get>`).
- the ``len`` function (``__len__``) returns the number of keys.
- iteration (``__iter__``) iterates over the *names* of the keys only (like a ``dict``, see :py:meth:`keys <uproot.rootio.ROOTDirectory.keys>`).
**Attributes, properties, and methods:**
- **name** (*bytes*) name of the file or directory *as read from the ROOT file*. (ROOT files may be imprinted with a different name than they have in the file system.)
- **compression** (:py:class:`Compression <uproot.source.compressed.Compression>`) the compression algorithm and level specified in the file header. (Some objects, including TTree branches, may have different compression settings than the global file settings.)
- :py:meth:`get <uproot.rootio.ROOTDirectory.get>` read an object from the file, selected by name.
- :py:meth:`iterkeys <uproot.rootio.ROOTDirectory.iterkeys>` iterate over key names in this directory.
- :py:meth:`itervalues <uproot.rootio.ROOTDirectory.itervalues>` iterate over objects in this directory.
- :py:meth:`iteritems <uproot.rootio.ROOTDirectory.iteritems>` iterate over *(key name, object)* pairs in this directory, like a ``dict``.
- :py:meth:`iterclasses <uproot.rootio.ROOTDirectory.iterclasses>` iterate over *(key name, class object)* pairs in this directory.
- :py:meth:`keys <uproot.rootio.ROOTDirectory.keys>` return key names in this directory.
- :py:meth:`values <uproot.rootio.ROOTDirectory.values>` return objects in this directory.
- :py:meth:`items <uproot.rootio.ROOTDirectory.items>` return *(key name, object)* pairs in this directory, like a ``dict``.
- :py:meth:`classes <uproot.rootio.ROOTDirectory.classes>` return *(key name, class object)* pairs in this directory.
- :py:meth:`allkeys <uproot.rootio.ROOTDirectory.allkeys>` return keys at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`keys <uproot.rootio.ROOTDirectory.keys>`).
- :py:meth:`allvalues <uproot.rootio.ROOTDirectory.allvalues>` return objects at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`values <uproot.rootio.ROOTDirectory.values>`).
- :py:meth:`allitems <uproot.rootio.ROOTDirectory.allitems>` return *(key name, object)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`items <uproot.rootio.ROOTDirectory.items>`).
- :py:meth:`allclasses <uproot.rootio.ROOTDirectory.allclasses>` return *(key name, class object)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`classes <uproot.rootio.ROOTDirectory.classes>`).
"""
_method(uproot.rootio.ROOTDirectory.get).__doc__ = \
u"""Read an object from the ROOT file or directory by name.
Parameters
----------
name : str (str)
name of the object. Any text before a "``/``" is interpreted as a subdirectory, and subdirectories of any depth may be searched. A number after a "``;``" indicates a `TKey <uproot.rootio.TKey>` cycle.
cycle : ``None`` or int
`TKey <uproot.rootio.TKey>` cycle number to disambiguate keys of the same name. This argument overrides a number after a "``;``".
Returns
-------
:py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`
a freshly read object from the ROOT file.
Notes
-----
This method, without the ``cycle`` argument, can be accessed more directly through square brackets (``__getitem__``) on the :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>` object.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.iterkeys).__doc__ = \
u"""Iterate over key names in this directory.
This method does not read objects.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
iterator over bytes
names of objects and subdirectories in the file.
Notes
-----
This method can be accessed more directly by simply iterating over a :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>` object.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.itervalues).__doc__ = \
u"""Iterate over objects in this directory.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
iterator over :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`
freshly read objects from the ROOT file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.iteritems).__doc__ = \
u"""Iterate over *(key name, object)* pairs in this directory, like a ``dict``.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
iterator over (bytes, :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`)
name-object pairs from the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.iterclasses).__doc__ = \
u"""Iterate over *(key name, class object)* pairs in this directory.
This method does not read objects.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
iterator over (bytes, class object)
name-class object pairs from the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.keys).__doc__ = \
u"""Return key names in this directory.
This method does not read objects.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
list of bytes
names of objects and subdirectories in the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.values).__doc__ = \
u"""Return objects in this directory.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
list of :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`
freshly read objects from the ROOT file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.items).__doc__ = \
u"""Return *(key name, object)* pairs in this directory, like a ``dict``.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
list of (bytes, :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`)
name-object pairs from the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.classes).__doc__ = \
u"""Return *(key name, class object)* pairs in this directory.
This method does not read objects.
Parameters
----------
{recursive}
{filtername}
{filterclass}
Returns
-------
list of (bytes, class object)
name-class object pairs from the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.allkeys).__doc__ = \
u"""Return keys at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`keys <uproot.rootio.ROOTDirectory.keys>`).
This method does not read objects.
Parameters
----------
{filtername}
{filterclass}
Returns
-------
list of bytes
names of objects and subdirectories in the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.allvalues).__doc__ = \
u"""Return objects at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`values <uproot.rootio.ROOTDirectory.values>`).
Parameters
----------
{filtername}
{filterclass}
Returns
-------
list of :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`
freshly read objects from the ROOT file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.allitems).__doc__ = \
u"""Return *(key name, object)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`items <uproot.rootio.ROOTDirectory.items>`).
Parameters
----------
{filtername}
{filterclass}
Returns
-------
list of (bytes, :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`)
name-object pairs from the file.
""".format(**rootdirectory_fragments)
_method(uproot.rootio.ROOTDirectory.allclasses).__doc__ = \
u"""Return *(key name, class object)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`classes <uproot.rootio.ROOTDirectory.classes>`).
This method does not read objects.
Parameters
----------
{filtername}
{filterclass}
Returns
-------
list of (bytes, class object)
name-class object pairs from the file.
""".format(**rootdirectory_fragments)
################################################################ uproot.rootio.ROOTObject and uproot.rootio.ROOTStreamedObject
uproot.rootio.ROOTObject.__doc__ = \
u"""Superclass of all objects read out of a ROOT file (except :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`).
If a :py:class:`ROOTObject <uproot.rootio.ROOTObject>` is not a :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>`, then its class definition is hard-coded, not derived from the file's *streamer info*.
"""
uproot.rootio.ROOTStreamedObject.__doc__ = \
u"""Superclass of all objects read out of a ROOT file with an automatically generated class, derived from the file's *streamer info*.
Each subclass of a :py:class:`ROOTStreamedObject <uproot.rootio.ROOTStreamedObject>` has a ``classversion`` attribute, corresponding to the class version in the *streamer info*. If this version does not match the version of the serialized class, an error is raised during the read.
"""
################################################################ uproot.tree fragments
tree_fragments = {
# entrystart
"entrystart": u"""entrystart : ``None`` or int
entry at which reading starts (inclusive). If ``None`` *(default)*, start at the beginning of the branch.""",
# entrystop
"entrystop": u"""entrystop : ``None`` or int
entry at which reading stops (exclusive). If ``None`` *(default)*, stop at the end of the branch.""",
# entrysteps
"entrysteps": u"""entrysteps : ``None``, positive int, ``float("inf")``, string matching number + /[kMGTPEZY]?B/i, or iterable of *(int, int)* pairs
if ``None`` *(default)*, iterate in steps of TTree clusters (number of entries for which all branches' baskets align); if an integer, iterate in steps of equal numbers of entries (except at the end of a file); if infinite, take file-sized steps; if a string, iterate in steps of approximately equal memory, given by a memory size string; otherwise, iterate in explicit, user-specified *(start, stop)* intervals ("start" is inclusive and "stop" is exclusive).""",
# entrysteps_tree
"entrysteps_tree": u"""entrysteps : ``None``, positive int, ``float("inf")``, string matching number + /[kMGTPEZY]?B/i, or iterable of *(int, int)* pairs
if ``None`` *(default)*, iterate in steps of TTree clusters (number of entries for which all branches' baskets align); if an integer, iterate in steps of equal numbers of entries; if infinite, iterate over the whole file in one step; if a string, iterate in steps of approximately equal memory, given by a memory size string; otherwise, iterate in explicit, user-specified *(start, stop)* intervals ("start" is inclusive and "stop" is exclusive).""",
# branch
"branch": u"""branch : str
name of the branch to read.""",
# interpretation
"interpretation": u"""interpretation : ``None`` or :py:class:`Interpretation <uproot.interp.interp.Interpretation>`
the meaning imposed upon the bytes of the file and the ultimate form to instantiate. If ``None`` *(default)*, :py:func:`interpret <uproot.interp.auto.interpret>` will be applied to the branch to generate an interpretation.""",
# branches
"branches": u"""branches
- if ``None`` *(default)*, select all *interpretable* branches;
- if a list of str, select branches by name;
- if a single str, select a single branch (though the return value is still a container type, not a single array). The selection by string can include filename-like glob characters (``*``, ``?``, ``[...]``) or it can be a full regular expression (Python flavored) if surrounded by slashes, like ``/pattern/i`` (where ``i`` is an optional `Python re flag <https://docs.python.org/2/library/re.html>`_);
- if a function :py:class:`TBranchMethods <uproot.tree.TBranchMethods>` \u21d2 ``True`` or ``False``, select branches that return ``True``;
- if a function :py:class:`TBranchMethods <uproot.tree.TBranchMethods>` \u21d2 ``None`` or :py:class:`Interpretation <uproot.interp.interp.Interpretation>`, select branches for which the function does not return ``None`` and use the interpretation it returns otherwise;
- if a ``dict`` of str \u2192 :py:class:`Interpretation <uproot.interp.interp.Interpretation>`, select branches named by keys and use interpretations from the associated values.""",
# outputtype
"outputtype": u"""outputtype : type
constructor for the desired yield type, such as ``dict`` *(default)*, ``OrderedDict``, ``tuple``, ``namedtuple``, custom user class, etc.""",
# namedecode
"namedecode": u"""namedecode : None or str
if ``None`` *(default)* return names as uninterpreted byte strings (type ``bytes`` in Python 3); if a string like ``"ascii"`` or ``"utf-8"``, decode bytes to a string using the specified encoding.""",
# reportpath
"reportpath": u"""reportpath : bool
if ``True`` *(not default)*, yield the current path (string) before the arrays (and any other reported objects) as a tuple.""",
# reportfile
"reportfile": u"""reportfile : bool
if ``True``, *(not default)*, yield the current file (object) before the arrays (and any other reported objects except reportpath) as a tuple.""",
# reportentries
"reportentries": u"""reportentries : bool
if ``True`` *(not default)*, yield the current entry start and entry stop (integers) before the arrays, where *entry start* is inclusive and *entry stop* is exclusive.""",
# flatten
"flatten": u"""flatten : None or bool
if ``True``, convert JaggedArrays into flat Numpy arrays. If False *(default)*, make JaggedArrays lists. If None, remove JaggedArrays.""",
# flatname
"flatname": u"""flatname : None or (branchname, fieldname, index) \u2192 str
if ``None`` *(default)*, use ``uproot._connect._pandas.default_flatname`` to convert a branchname with a subfield and regular index number into a Pandas column name; otherwise, take a user-defined function.""",
# profile
"profile": u"""profile : None or str
if a string *(not default)*, format the lazy arrays using a module from uproot_methods.profiles named by the string.""",
# awkwardlib
"awkwardlib": u"""awkwardlib : ``None``, str, or module
if ``None`` *(default)*, use ``import awkward`` to get awkward-array constructors. Otherwise, parse the module string name or use the provided module.""",
# cache
"cache": u"""cache : ``None`` or ``dict``-like object
if not ``None`` *(default)*, fully interpreted arrays will be saved in the ``dict``-like object for later use. Accessing the same arrays with a different interpretation or a different entry range results in a cache miss.""",
# basketcache
"basketcache": u"""basketcache : ``None`` or ``dict``-like object
if not ``None`` *(default)*, raw basket data will be saved in the ``dict``-like object for later use. Accessing the same arrays with a different interpretation or a different entry range fully utilizes this cache, since the interpretation/construction from baskets is performed after retrieving data from this cache.""",
# keycache
"keycache": u"""keycache : ``None`` or ``dict``-like object
if not ``None`` *(default)*, basket TKeys will be saved in the ``dict``-like object for later use. TKeys are small, but require file access, so caching them can speed up repeated access.""",
# executor
"executor": u"""executor : `concurrent.futures.Executor <https://docs.python.org/3/library/concurrent.futures.html>`_
if not ``None`` *(default)*, parallelize basket-reading and decompression by scheduling tasks on the executor. Assumes caches are thread-safe.""",
# blocking
"blocking": u"""blocking : bool
if ``True`` *(default)*, do not exit this function until the arrays are read, and return those arrays. If ``False``, exit immediately and return a zero-argument function. That zero-argument function returns the desired array, and it blocks until the array is available. This option is only useful with a non-``None`` executor.""",
# persistvirtual
"persistvirtual": u"""persistvirtual : bool
if ``False`` *(default)*, the resulting awkward.VirtualArrays would convert themselves into real arrays (materialize) before being saved in awkward-array's persistence methods; if ``True``, the "virtualness" of the arrays is preserved\u2014that is, only instructions for reconstituting the arrays is saved, not the array data themselves.""",
# recursive
"recursive": u"""recursive : bool
if ``False`` *(default)*, only iterate at this tree/branch level; if ``True``, depth-first iterate over all subbranches as well.""",
# filtername
"filtername": u"""filtername : function: str \u21d2 bool
only branches for which ``filtername(name)`` returns ``True`` are returned. Default returns ``True`` for all input.""",
# filtertitle
"filtertitle": u"""filtertitle : function: str \u21d2 bool
only branches for which ``filtertitle(title)`` returns ``True`` are returned. Default returns ``True`` for all input.""",
# i
"i": u"""i : non-negative int
basket number (must be greater than or equal to zero and strictly less than *numbaskets*).""",
# chunked
"chunked": u"""chunked : bool
if ``True`` *(default)*, produced chunked lazy arrays using awkward.ChunkedArray. If ``False``, produce bare VirtualArrays. This option implies ``entrysteps = float('inf')``.""",
}
################################################################ uproot.tree.iterate
uproot.tree.iterate.__doc__ = \
u"""Opens a series of ROOT files (local or remote), yielding the same number of entries from all selected branches in each step.
Depending on the "entrysteps" parameter, the number of entries in one step may differ from the number of entries in the next step, but in every step, the same number of entries is retrieved from all *baskets.*
All but the first two parameters are identical to :py:meth:`uproot.tree.TreeMethods.iterate`.
Parameters
----------
path : str or list of str
glob pattern(s) for local file paths (POSIX wildcards like "``*``") or URLs specifying the locations of the files. A list of filenames are processed in the given order, but glob patterns get pre-sorted to ensure a predictable order.
treepath : str
path within each ROOT file to find the TTree (may include "``/``" for subdirectories or "``;``" for cycle numbers).
{branches}
{entrysteps}
{outputtype}
{namedecode}
{reportpath}
{reportfile}
{reportentries}
{flatten}
{flatname}
{awkwardlib}
{cache}
{basketcache}
{keycache}
{executor}
{blocking}
{localsource}
{xrootdsource}
{httpsource}
{options}
Returns
-------
iterator over (str, :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`, int, int, outputtype) (if *reportpath*, *reportfile*, *reportentries*) or just outputtype (otherwise)
aligned array segments from the files.
""".format(**dict(list(open_fragments.items()) + list(tree_fragments.items())))
################################################################ uproot.pandas.iterate
uproot.pandas.iterate.__doc__ = \
u"""Opens a series of ROOT files (local or remote), yielding Pandas DataFrames in each step.
Depending on the "entrysteps" parameter, the number of entries in one step may differ from the number of entries in the next step, but in every step, the same number of entries is retrieved from all *baskets.*
Parameters
----------
path : str or list of str
glob pattern(s) for local file paths (POSIX wildcards like "``*``") or URLs specifying the locations of the files. A list of filenames are processed in the given order, but glob patterns get pre-sorted to ensure a predictable order.
treepath : str
path within each ROOT file to find the TTree (may include "``/``" for subdirectories or "``;``" for cycle numbers).
{branches}
{entrysteps}
{namedecode}
{reportpath}
{reportfile}
{flatten}
{flatname}
{awkwardlib}
{cache}
{basketcache}
{keycache}
{executor}
{blocking}
{localsource}
{xrootdsource}
{httpsource}
{options}
Returns
-------
iterator over (str, :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>`, pandas.Dataframe) (if *reportpath* and *reportfile*) or just pandas.DataFrame (otherwise)
aligned array segments from the files.
""".format(**dict(list(open_fragments.items()) + list(tree_fragments.items())))
################################################################ uproot.tree.TTreeMethods
uproot.tree.TTreeMethods.__doc__ = \
u"""Adds array reading methods to TTree objects that have been streamed from a ROOT file.
- square brackets (``__getitem__``) returns a branch by name (see :py:meth:`get <uproot.tree.TTreeMethods.get>`).
- the ``len`` function (``__len__``) returns the number of entries (same as ``numentries``).
- iteration (``__iter__``) has no implementation. This is to avoid confusion between iterating over all branches (probably not what you want, but fitting the pattern set by :py:class:`ROOTDirectory <uproot.rootio.ROOTDirectory>` and ``dict``) and iterating over the data.
**Attributes, properties, and methods:**
- **name** (*bytes*) name of the TTree.
- **title** (*bytes*) title of the TTree.
- **numentries** (*int*) number of entries in the TTree (same as ``len``).
- **pandas** connector to `Pandas <http://pandas.pydata.org/>`_ functions
- :py:meth:`get <uproot.tree.TTreeMethods.get>` return a branch by name (at any level of depth).
- :py:meth:`iterkeys <uproot.tree.TTreeMethods.iterkeys>` iterate over branch names.
- :py:meth:`itervalues <uproot.tree.TTreeMethods.itervalues>` iterate over branches.
- :py:meth:`iteritems <uproot.tree.TTreeMethods.iteritems>` iterate over *(branch name, branch)* pairs.
- :py:meth:`keys <uproot.tree.TTreeMethods.keys>` return branch names.
- :py:meth:`values <uproot.tree.TTreeMethods.values>` return branches.
- :py:meth:`items <uproot.tree.TTreeMethods.items>` return *(branch name, branch)* pairs.
- :py:meth:`allkeys <uproot.tree.TTreeMethods.allkeys>` return branch names at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`keys <uproot.tree.TTreeMethods.keys>`).
- :py:meth:`allvalues <uproot.tree.TTreeMethods.allvalues>` return branches at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`values <uproot.tree.TTreeMethods.values>`).
- :py:meth:`allitems <uproot.tree.TTreeMethods.allitems>` return *(branch name, branch)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`items <uproot.tree.TTreeMethods.items>`).
- :py:meth:`clusters <uproot.tree.TTreeMethods.clusters>` iterate over *(int, int)* pairs representing cluster entry starts and stops in this TTree.
- :py:meth:`mempartitions <uproot.tree.TTreeMethods.mempartitions>` iterate over *(int, int)* pairs representing entry starts and stops that attempt to maintain a constant memory footprint.
**Methods for reading array data:**
- :py:meth:`array <uproot.tree.TTreeMethods.array>` read one branch into an array (or other object if provided an alternate *interpretation*).
- :py:meth:`arrays <uproot.tree.TTreeMethods.arrays>` read many branches into arrays (or other objects if provided alternate *interpretations*).
- :py:meth:`lazyarray <uproot.tree.TTreeMethods.lazyarray>` create a lazy array that would read the branch as needed.
- :py:meth:`lazyarrays <uproot.tree.TTreeMethods.lazyarrays>` create many lazy arrays.
- :py:meth:`iterate <uproot.tree.TTreeMethods.iterate>` iterate over many arrays at once, yielding the same number of entries from all selected branches in each step.
"""
_method(uproot.tree.TTreeMethods.get).__doc__ = \
u"""Return a branch by name (at any level of depth).
Parameters
----------
name : str
name of the branch to return.
Returns
-------
:py:class:`TBranch <upoot.tree.TBranchMethods>`
selected branch.
Notes
-----
This method can be accessed more directly through square brackets (``__getitem__``) on the :py:class:`TTree <uproot.tree.TTreeMethods>` object.
"""
_method(uproot.tree.TTreeMethods.iterkeys).__doc__ = \
u"""Iterate over branch names.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
iterator over bytes
names of branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.itervalues).__doc__ = \
u"""Iterate over branches.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
iterator over :py:class:`TBranch <uproot.tree.TBranchMethods>`
branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.iteritems).__doc__ = \
u"""Iterate over *(branch name, branch)* pairs.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
iterator over (bytes, :py:class:`TBranch <uproot.tree.TBranchMethods>`)
name-branch pairs.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.keys).__doc__ = \
u"""Return branch names.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
list of bytes
names of branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.values).__doc__ = \
u"""Return branches.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
list of :py:class:`TBranch <uproot.tree.TBranchMethods>`
branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.items).__doc__ = \
u"""Return *(branch name, branch)* pairs.
Parameters
----------
{recursive}
{filtername}
{filtertitle}
Returns
-------
list of (bytes, :py:class:`TBranch <uproot.tree.TBranchMethods>`)
name-branch pairs.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.allkeys).__doc__ = \
u"""Return branch names at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`keys <uproot.tree.TTreeMethods.keys>`).
Parameters
----------
{filtername}
{filtertitle}
Returns
-------
list of bytes
names of branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.allvalues).__doc__ = \
u"""Return branches at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`values <uproot.tree.TTreeMethods.values>`).
Parameters
----------
{filtername}
{filtertitle}
Returns
-------
list of :py:class:`TBranch <uproot.tree.TBranchMethods>`
branches.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.allitems).__doc__ = \
u"""Return *(branch name, branch)* pairs at all levels of depth (shortcut for passing ``recursive=True`` to :py:meth:`items <uproot.tree.TTreeMethods.items>`).
Parameters
----------
{filtername}
{filtertitle}
Returns
-------
list of (bytes, :py:class:`TBranch <uproot.tree.TBranchMethods>`
name-branch pairs.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.clusters).__doc__ = \
u"""Return entry starts and stops as *(int, int)* pairs representing clusters for a given set of branches this TTree.
Rather than using ROOT's self-reported clusters (which don't exist in every ROOT file), this method finds the minimal step sizes in which a given set of branches have basket thresholds for the same entry number. For a single branch, this is exactly the basket boundaries. It is possible for a given set of branches to never line up, in which case, the cluster is the entire file.
Parameters
----------
{branches}
{entrystart}
{entrystop}
strict : bool
if ``False`` *(default)*, the potential ``start, stop`` pair must satisfy ``entrystart < stop and start < entrystop``; if ``True``, the potential ``start, stop`` pair must satisfy ``entrystart <= start and stop <= entrystop``.
Returns
-------
list of (int, int)
start (inclusive) and stop (exclusive) pairs for each cluster.
"""
_method(uproot.tree.TTreeMethods.mempartitions).__doc__ = \
u"""Return entry starts and stops as *(int, int)* pairs of (approximately) equal-memory partitions for a given set of branches in this TTree.
Similar to :py:meth:`clusters <uproot.tree.TTreeMethods.clusters>` in that it provides a list of (start, stop) entry pairs, but instead of fitting baskets, this method attempts to keep the memory use constant.
Parameters
----------
numbytes : positive number (int or float) or string matching number + /[kMGTPEZY]?B/i
target number of bytes in each step (not an upper limit, but an average); if a string, parse the memory size
{branches}
{entrystart}
{entrystop}
{keycache}
linear : bool
if ``True`` *(default)*, the step size is uniform (same number of entries in each step); any variations in entry size as a function of entry number are averaged over. Non-linear steps (``False``), which would take into account bigger entry sizes at the beginning or end of the file, have not been implemented.
Returns
-------
list of (int, int)
start (inclusive) and stop (exclusive) pairs for each equal-memory partition.
"""
_method(uproot.tree.TTreeMethods.array).__doc__ = \
u"""Read one branch into an array (or other object if provided an alternate *interpretation*).
Parameters
----------
{branch}
{interpretation}
{entrystart}
{entrystop}
{flatten}
{awkwardlib}
{cache}
{basketcache}
{keycache}
{executor}
{blocking}
Returns
-------
array or other object, depending on *interpretation*.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.arrays).__doc__ = \
u"""Read many branches into arrays (or other objects if provided alternate *interpretations*).
Parameters
----------
{branches}
{outputtype}
{namedecode}
{entrystart}
{entrystop}
{flatten}
{flatname}
{awkwardlib}
{cache}
{basketcache}
{keycache}
{executor}
{blocking}
Returns
-------
outputtype of arrays or other objects, depending on *interpretation*
branch data.
""".format(**tree_fragments)
_method(uproot.tree.TTreeMethods.lazyarray).__doc__ = \
u"""Create a lazy array that would read the branch as needed.
Parameters
----------
{branch}
{interpretation}
{entrysteps_tree}
{entrystart}
{entrystop}
{flatten}
{awkwardlib}
{cache}
{basketcache}
{keycache}
{executor}
{persistvirtual}
{chunked}
Returns