uproot-custom 2.5.0__tar.gz → 2.5.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.pre-commit-config.yaml +2 -2
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/PKG-INFO +3 -3
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/README.md +1 -1
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/cpp/include/uproot-custom/uproot-custom.hh +46 -9
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/cpp/src/uproot-custom.cc +76 -182
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/Doxyfile +1 -1
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/conf.py +10 -2
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/example/override-streamer.md +5 -5
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/example/read-tobjarray.md +5 -5
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/index.md +1 -1
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/api/uproot-custom-ref.md +0 -1
- uproot_custom-2.5.2/docs/reference/binary-format.md +662 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/reader-backends.md +26 -15
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader/pipeline.md +5 -5
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader/port-to-cpp.md +3 -3
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader.md +4 -4
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/pyproject.toml +3 -3
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/test_readers.py +9 -39
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/__init__.py +2 -2
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/_version.py +3 -3
- uproot_custom-2.5.0/uproot_custom/AsCustom.py → uproot_custom-2.5.2/uproot_custom/as_custom.py +33 -34
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/cpp.pyi +0 -2
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/factories.py +85 -209
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/readers/_forth.py +47 -205
- uproot_custom-2.5.2/uproot_custom/readers/backend.py +93 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/readers/python.py +26 -141
- uproot_custom-2.5.0/docs/reference/api/cpp-module.md +0 -6
- uproot_custom-2.5.0/docs/reference/binary-format.md +0 -167
- uproot_custom-2.5.0/uproot_custom/readers/_numba.py +0 -1315
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.clang-format +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/release.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/build-wheels.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/deploy-docs.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/python-publish.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/semantic-pr-titles.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/test-package.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.github/workflows/weekly-build.yml +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/.gitignore +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/LICENSE +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/cpp/CMakeLists.txt +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/cpp/share/cmake/uproot-customConfig.cmake +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/get-started.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/api/.gitignore +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/api/cpp-api.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/api.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/reference/version-requirements.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader/investigate-data.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader/project-setup.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/docs/tutorial/customize-factory-reader/reader-and-factory.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/conftest.py +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_cstyle_array.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_pointers.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_primitive.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_pure_struct.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_root_objects.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_simple_obj.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_array.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_complicated.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_map.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_map_with_obj.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_nested.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_seq_with_obj.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_sequence.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/data/test_stl_string.root +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/CMakeLists.txt +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/README.md +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/LinkDef.h +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TBasicTypes.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TCStyleArray.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TComplicatedSTL.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TNestedSTL.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TPointers.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TPureStruct.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TRootObjects.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLArray.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLMap.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLMapWithObj.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLSeqWithObj.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLSequence.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSTLString.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/include/TSimpleObject.hh +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/gen-test-data/src/main.cc +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/tests/test_AsCustom.py +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/readers/__init__.py +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/readers/cpp.py +1 -1
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/share/cmake/__init__.py +0 -0
- {uproot_custom-2.5.0 → uproot_custom-2.5.2}/uproot_custom/utils.py +0 -0
|
@@ -23,12 +23,12 @@ repos:
|
|
|
23
23
|
- id: trailing-whitespace
|
|
24
24
|
|
|
25
25
|
- repo: https://github.com/psf/black-pre-commit-mirror
|
|
26
|
-
rev: 26.
|
|
26
|
+
rev: 26.10.1
|
|
27
27
|
hooks:
|
|
28
28
|
- id: black
|
|
29
29
|
|
|
30
30
|
- repo: https://github.com/astral-sh/ruff-pre-commit
|
|
31
|
-
rev: v0.
|
|
31
|
+
rev: v0.17.3
|
|
32
32
|
hooks:
|
|
33
33
|
- id: ruff-check
|
|
34
34
|
args: [--fix, --show-fixes]
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.2
|
|
2
2
|
Name: uproot-custom
|
|
3
|
-
Version: 2.5.
|
|
4
|
-
Summary:
|
|
3
|
+
Version: 2.5.2
|
|
4
|
+
Summary: Uproot extension for reading custom classes
|
|
5
5
|
Author-Email: Mingrun Li <mrli@ihep.ac.cn>
|
|
6
6
|
Classifier: Development Status :: 3 - Alpha
|
|
7
7
|
Classifier: Intended Audience :: Developers
|
|
@@ -38,7 +38,7 @@ Description-Content-Type: text/markdown
|
|
|
38
38
|
Uproot-custom is an extension of [Uproot](https://uproot.readthedocs.io/en/latest/basic.html) that provides an enhanced way to read custom classes stored in `TTree`.
|
|
39
39
|
|
|
40
40
|
> [!WARNING]
|
|
41
|
-
> Because of earlier mistakes in version management, the `v2.x.x` series should still be treated as a development version rather than a stable release.
|
|
41
|
+
> Because of earlier mistakes in version management, the `v2.x.x` series should still be treated as a development version rather than a stable release. Please specify a minor version when using Uproot-custom as a dependency (e.g., `uproot-custom==2.5.*`) to avoid unexpected breaking changes.
|
|
42
42
|
|
|
43
43
|
## What uproot-custom can do
|
|
44
44
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Uproot-custom is an extension of [Uproot](https://uproot.readthedocs.io/en/latest/basic.html) that provides an enhanced way to read custom classes stored in `TTree`.
|
|
4
4
|
|
|
5
5
|
> [!WARNING]
|
|
6
|
-
> Because of earlier mistakes in version management, the `v2.x.x` series should still be treated as a development version rather than a stable release.
|
|
6
|
+
> Because of earlier mistakes in version management, the `v2.x.x` series should still be treated as a development version rather than a stable release. Please specify a minor version when using Uproot-custom as a dependency (e.g., `uproot-custom==2.5.*`) to avoid unexpected breaking changes.
|
|
7
7
|
|
|
8
8
|
## What uproot-custom can do
|
|
9
9
|
|
|
@@ -47,8 +47,17 @@ namespace uproot_custom {
|
|
|
47
47
|
|
|
48
48
|
constexpr uint16_t kStreamedMemberWise = 1 << 14; // streamed member-wise mask
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* @brief A binary stream reader that wraps numpy arrays for efficient ROOT binary parsing.
|
|
52
|
+
*
|
|
53
|
+
* Provides endianness-aware reading of primitive types and manages references
|
|
54
|
+
* between objects during deserialization.
|
|
55
|
+
*/
|
|
50
56
|
class BinaryStream {
|
|
51
57
|
public:
|
|
58
|
+
/**
|
|
59
|
+
* @brief Status bits for TObject, used to track object state flags.
|
|
60
|
+
*/
|
|
52
61
|
enum EStatusBits {
|
|
53
62
|
kCanDelete = 1ULL << 0, ///< if object in a list can be deleted
|
|
54
63
|
// 2 is taken by TDataMember
|
|
@@ -64,20 +73,30 @@ namespace uproot_custom {
|
|
|
64
73
|
<< 13 ///< if object ctor succeeded but object should not be used
|
|
65
74
|
};
|
|
66
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @brief Reference to a class by name.
|
|
78
|
+
*/
|
|
67
79
|
struct RefCls {
|
|
68
|
-
std::string name;
|
|
80
|
+
std::string name; ///< The name of the referenced class.
|
|
69
81
|
};
|
|
70
82
|
|
|
83
|
+
/**
|
|
84
|
+
* @brief Reference to an object by index.
|
|
85
|
+
*/
|
|
71
86
|
struct RefObj {
|
|
72
|
-
int64_t index;
|
|
87
|
+
int64_t index; ///< The index of the referenced object.
|
|
73
88
|
};
|
|
74
89
|
|
|
90
|
+
/**
|
|
91
|
+
* @brief A variant type representing either a class reference or an object reference.
|
|
92
|
+
*/
|
|
75
93
|
using Reference = std::variant<RefCls, RefObj>;
|
|
76
94
|
|
|
77
95
|
/**
|
|
78
96
|
* @brief Construct a BinaryStream from numpy arrays.
|
|
79
97
|
* @param data A numpy array of uint8_t containing the raw data.
|
|
80
98
|
* @param offsets A numpy array of uint32_t containing the offsets for each entry.
|
|
99
|
+
* @param initial_cursor_position Initial cursor position offset for the stream.
|
|
81
100
|
*/
|
|
82
101
|
BinaryStream( py::array_t<uint8_t> data, py::array_t<uint32_t> offsets,
|
|
83
102
|
uint32_t initial_cursor_position )
|
|
@@ -85,7 +104,8 @@ namespace uproot_custom {
|
|
|
85
104
|
, m_offsets( static_cast<uint32_t*>( offsets.request().ptr ) )
|
|
86
105
|
, m_initial_cursor_offset( initial_cursor_position )
|
|
87
106
|
, m_entries( offsets.request().size - 1 )
|
|
88
|
-
, m_cursor( static_cast<uint8_t*>( data.request().ptr ) )
|
|
107
|
+
, m_cursor( static_cast<uint8_t*>( data.request().ptr ) )
|
|
108
|
+
, m_debug_print( getenv( "UPROOT_CUSTOM_DEBUG" ) ) {}
|
|
89
109
|
|
|
90
110
|
/**
|
|
91
111
|
* @brief Read a value of type T from the stream, handling endianness.
|
|
@@ -294,7 +314,11 @@ namespace uproot_custom {
|
|
|
294
314
|
*
|
|
295
315
|
* @param n Number of bytes to print.
|
|
296
316
|
*/
|
|
297
|
-
void debug_print(
|
|
317
|
+
void debug_print( size_t n = 100 ) const {
|
|
318
|
+
if ( !m_debug_print ) return;
|
|
319
|
+
|
|
320
|
+
n = std::min( n, static_cast<size_t>( m_data + m_offsets[m_entries] - m_cursor ) );
|
|
321
|
+
|
|
298
322
|
for ( size_t i = 0; i < n; i++ ) { std::cout << (int)*( m_cursor + i ) << " "; }
|
|
299
323
|
std::cout << std::endl;
|
|
300
324
|
}
|
|
@@ -306,6 +330,7 @@ namespace uproot_custom {
|
|
|
306
330
|
const uint32_t* m_offsets; ///< entry offsets pointer
|
|
307
331
|
const uint32_t m_initial_cursor_offset; ///< initial cursor position, used for
|
|
308
332
|
///< calculating relative offsets
|
|
333
|
+
const bool m_debug_print; ///< whether to print debug information
|
|
309
334
|
|
|
310
335
|
std::map<uint32_t, Reference> m_refs; ///< offset -> reference, used for pointer
|
|
311
336
|
///< reading
|
|
@@ -328,6 +353,16 @@ namespace uproot_custom {
|
|
|
328
353
|
class IReader {
|
|
329
354
|
protected:
|
|
330
355
|
const std::string m_name; ///< name of the reader
|
|
356
|
+
const bool m_debug_print; ///< whether to print debug information
|
|
357
|
+
|
|
358
|
+
template <typename... Args>
|
|
359
|
+
inline void debug_printf( const char* msg, Args... args ) const {
|
|
360
|
+
if ( m_debug_print ) printf( msg, args... );
|
|
361
|
+
}
|
|
362
|
+
|
|
363
|
+
inline void debug_printf( uproot_custom::BinaryStream& stream, const size_t n = 100 ) {
|
|
364
|
+
if ( m_debug_print ) stream.debug_print( n );
|
|
365
|
+
}
|
|
331
366
|
|
|
332
367
|
public:
|
|
333
368
|
/**
|
|
@@ -335,7 +370,8 @@ namespace uproot_custom {
|
|
|
335
370
|
*
|
|
336
371
|
* @param name Name of the reader.
|
|
337
372
|
*/
|
|
338
|
-
IReader( std::string name )
|
|
373
|
+
IReader( std::string name )
|
|
374
|
+
: m_name( name ), m_debug_print( getenv( "UPROOT_CUSTOM_DEBUG" ) ) {}
|
|
339
375
|
|
|
340
376
|
virtual ~IReader() = default;
|
|
341
377
|
|
|
@@ -497,7 +533,10 @@ namespace uproot_custom {
|
|
|
497
533
|
|
|
498
534
|
/**
|
|
499
535
|
* @brief Debug print function. Prints only when environment variable with name
|
|
500
|
-
* `UPROOT_CUSTOM_DEBUG` is defined. Use this function like `printf()`.
|
|
536
|
+
* `UPROOT_CUSTOM_DEBUG` is defined. Use this function like `printf()`. DO NOT
|
|
537
|
+
* use this function in `read()` methods of the reader, since it may significantly
|
|
538
|
+
* slow down the reading process due to frequently retrieving the environment
|
|
539
|
+
* variable.
|
|
501
540
|
*
|
|
502
541
|
* @tparam Args Argument types. No need to specify explicitly.
|
|
503
542
|
* @param msg The format string.
|
|
@@ -518,9 +557,7 @@ namespace uproot_custom {
|
|
|
518
557
|
* @param stream The BinaryStream to print.
|
|
519
558
|
* @param n Number of bytes to print.
|
|
520
559
|
*/
|
|
521
|
-
inline void debug_printf( uproot_custom::BinaryStream& stream,
|
|
522
|
-
bool do_print = getenv( "UPROOT_CUSTOM_DEBUG" );
|
|
523
|
-
if ( !do_print ) return;
|
|
560
|
+
inline void debug_printf( uproot_custom::BinaryStream& stream, size_t n = 100 ) {
|
|
524
561
|
stream.debug_print( n );
|
|
525
562
|
}
|
|
526
563
|
|