uproot-custom 1.1.2__tar.gz → 1.1.3.dev1__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.
Files changed (40) hide show
  1. uproot_custom-1.1.3.dev1/CHANGELOG.md +3 -0
  2. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/PKG-INFO +5 -2
  3. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/README.md +4 -1
  4. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/cpp/src/uproot-custom.cc +18 -8
  5. uproot_custom-1.1.3.dev1/uproot_custom/_version.py +34 -0
  6. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/readers.py +17 -1
  7. uproot_custom-1.1.2/uproot_custom/_version.py +0 -21
  8. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/.clang-format +0 -0
  9. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/.github/workflows/build-wheels.yml +0 -0
  10. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/.github/workflows/python-publish.yml +0 -0
  11. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/.github/workflows/run-pytest.yml +0 -0
  12. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/.gitignore +0 -0
  13. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/LICENSE +0 -0
  14. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/cpp/CMakeLists.txt +0 -0
  15. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/cpp/include/uproot-custom/uproot-custom.hh +0 -0
  16. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/cpp/share/cmake/uproot-customConfig.cmake +0 -0
  17. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/README.md +0 -0
  18. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/cpp/CMakeLists.txt +0 -0
  19. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/cpp/my_reader.cc +0 -0
  20. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/CMakeLists.txt +0 -0
  21. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/include/LinkDef.h +0 -0
  22. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/include/TComplicatedSTL.hh +0 -0
  23. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/include/TOverrideStreamer.hh +0 -0
  24. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/src/TOverrideStreamer.cc +0 -0
  25. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/gen-demo-data/src/main.cc +0 -0
  26. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/my_reader/OverrideStreamerReader.py +0 -0
  27. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/my_reader/__init__.py +0 -0
  28. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/pyproject.toml +0 -0
  29. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/example/read-data.py +0 -0
  30. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/pyproject.toml +0 -0
  31. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/tests/test-data-1.root +0 -0
  32. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/tests/test-data-2.root +0 -0
  33. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/tests/test_AsCustom.py +0 -0
  34. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/tests/test_downstream_build.py +0 -0
  35. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/tests/test_downstream_build_pyproject.toml +0 -0
  36. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/AsBinary.py +0 -0
  37. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/AsCustom.py +0 -0
  38. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/__init__.py +0 -0
  39. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/cpp.pyi +0 -0
  40. {uproot_custom-1.1.2 → uproot_custom-1.1.3.dev1}/uproot_custom/share/cmake/__init__.py +0 -0
@@ -0,0 +1,3 @@
1
+ ## v1.1.3
2
+
3
+ - Support optionally keep `TObject` data by specifying `item_path` in `TObjectReader`.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: uproot-custom
3
- Version: 1.1.2
3
+ Version: 1.1.3.dev1
4
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
@@ -106,7 +106,7 @@ Since embedding arrays together into `awkward` array in C++ is not straightforwa
106
106
 
107
107
  ### Full example
108
108
 
109
- A complete example of how to impolement your own readers is available in the `example` directory of this repository.
109
+ A complete example of how to impolement your own readers is available in the [`example`](https://github.com/mrzimu/uproot-custom/tree/main/example) directory. You can also refer to the [Python part](https://github.com/mrzimu/uproot-custom/tree/main/uproot_custom/readers.py) and [C++ part](https://github.com/mrzimu/uproot-custom/tree/main/cpp/src/uproot-custom.cc) of predefined readers for implementation details.
110
110
 
111
111
  ### Pre-requisites
112
112
 
@@ -149,6 +149,9 @@ Make sure you have `GCC>13.1`/`Clang>=16.0.0`/`MSVC>=19.31`, `cmake` installed o
149
149
 
150
150
  you can change the `name`, `version`, and other fields as you like.
151
151
 
152
+ > [!WARNING]
153
+ > If you are releasing the project, specify concrete major and minor versions of `uproot-custom` to ensure the header files are compatible. For example, use `uproot-custom~=1.2` instead of `uproot-custom>=1.2` (may not be compatible with future versions).
154
+
152
155
  ### Reader interface
153
156
 
154
157
  For a custom `Reader`, a C++ part and a Python part are both required.
@@ -69,7 +69,7 @@ Since embedding arrays together into `awkward` array in C++ is not straightforwa
69
69
 
70
70
  ### Full example
71
71
 
72
- A complete example of how to impolement your own readers is available in the `example` directory of this repository.
72
+ A complete example of how to impolement your own readers is available in the [`example`](https://github.com/mrzimu/uproot-custom/tree/main/example) directory. You can also refer to the [Python part](https://github.com/mrzimu/uproot-custom/tree/main/uproot_custom/readers.py) and [C++ part](https://github.com/mrzimu/uproot-custom/tree/main/cpp/src/uproot-custom.cc) of predefined readers for implementation details.
73
73
 
74
74
  ### Pre-requisites
75
75
 
@@ -112,6 +112,9 @@ Make sure you have `GCC>13.1`/`Clang>=16.0.0`/`MSVC>=19.31`, `cmake` installed o
112
112
 
113
113
  you can change the `name`, `version`, and other fields as you like.
114
114
 
115
+ > [!WARNING]
116
+ > If you are releasing the project, specify concrete major and minor versions of `uproot-custom` to ensure the header files are compatible. For example, use `uproot-custom~=1.2` instead of `uproot-custom>=1.2` (may not be compatible with future versions).
117
+
115
118
  ### Reader interface
116
119
 
117
120
  For a custom `Reader`, a C++ part and a Python part are both required.
@@ -65,8 +65,9 @@ namespace uproot {
65
65
  class TObjectReader : public IElementReader {
66
66
 
67
67
  public:
68
- TObjectReader( std::string name )
68
+ TObjectReader( std::string name, bool keep_data )
69
69
  : IElementReader( name )
70
+ , m_keep_data( keep_data )
70
71
  , m_unique_id( std::make_shared<std::vector<int32_t>>() )
71
72
  , m_bits( std::make_shared<std::vector<uint32_t>>() )
72
73
  , m_pidf( std::make_shared<std::vector<uint16_t>>() )
@@ -75,18 +76,26 @@ namespace uproot {
75
76
  void read( BinaryBuffer& buffer ) override {
76
77
  buffer.skip_fVersion();
77
78
 
78
- m_unique_id->push_back( buffer.read<int32_t>() );
79
-
80
- auto fBits = buffer.read<uint32_t>();
81
- m_bits->push_back( fBits );
79
+ auto fUniqueID = buffer.read<int32_t>();
80
+ auto fBits = buffer.read<uint32_t>();
82
81
 
83
82
  if ( fBits & ( BinaryBuffer::kIsReferenced ) )
84
- { m_pidf->push_back( buffer.read<uint16_t>() ); }
83
+ {
84
+ if ( m_keep_data ) m_pidf->push_back( buffer.read<uint16_t>() );
85
+ else buffer.skip( 2 );
86
+ }
85
87
 
86
- m_pidf_offsets->push_back( m_pidf->size() );
88
+ if ( m_keep_data )
89
+ {
90
+ m_unique_id->push_back( fUniqueID );
91
+ m_bits->push_back( fBits );
92
+ m_pidf_offsets->push_back( m_pidf->size() );
93
+ }
87
94
  }
88
95
 
89
96
  py::object data() const override {
97
+ if ( !m_keep_data ) return py::none();
98
+
90
99
  auto unique_id_array = make_array( m_unique_id );
91
100
  auto bits_array = make_array( m_bits );
92
101
  auto pidf_array = make_array( m_pidf );
@@ -95,6 +104,7 @@ namespace uproot {
95
104
  }
96
105
 
97
106
  private:
107
+ const bool m_keep_data;
98
108
  SharedVector<int32_t> m_unique_id;
99
109
  SharedVector<uint32_t> m_bits;
100
110
  SharedVector<uint16_t> m_pidf;
@@ -467,7 +477,7 @@ namespace uproot {
467
477
 
468
478
  // Other readers
469
479
  register_reader<TStringReader>( m, "TStringReader" );
470
- register_reader<TObjectReader>( m, "TObjectReader" );
480
+ register_reader<TObjectReader, bool>( m, "TObjectReader" );
471
481
  register_reader<BaseObjectReader, std::vector<SharedReader>>( m, "BaseObjectReader" );
472
482
  register_reader<ObjectHeaderReader, std::vector<SharedReader>>( m,
473
483
  "ObjectHeaderReader" );
@@ -0,0 +1,34 @@
1
+ # file generated by setuptools-scm
2
+ # don't change, don't track in version control
3
+
4
+ __all__ = [
5
+ "__version__",
6
+ "__version_tuple__",
7
+ "version",
8
+ "version_tuple",
9
+ "__commit_id__",
10
+ "commit_id",
11
+ ]
12
+
13
+ TYPE_CHECKING = False
14
+ if TYPE_CHECKING:
15
+ from typing import Tuple
16
+ from typing import Union
17
+
18
+ VERSION_TUPLE = Tuple[Union[int, str], ...]
19
+ COMMIT_ID = Union[str, None]
20
+ else:
21
+ VERSION_TUPLE = object
22
+ COMMIT_ID = object
23
+
24
+ version: str
25
+ __version__: str
26
+ __version_tuple__: VERSION_TUPLE
27
+ version_tuple: VERSION_TUPLE
28
+ commit_id: COMMIT_ID
29
+ __commit_id__: COMMIT_ID
30
+
31
+ __version__ = version = '1.1.3.dev1'
32
+ __version_tuple__ = version_tuple = (1, 1, 3, 'dev1')
33
+
34
+ __commit_id__ = commit_id = 'gab4d2fe79'
@@ -603,6 +603,9 @@ class TObjectReader(BaseReader):
603
603
  It will not record any data.
604
604
  """
605
605
 
606
+ # Whether keep TObject data.
607
+ keep_data_itempaths: set[str] = set()
608
+
606
609
  @classmethod
607
610
  def gen_tree_config(
608
611
  cls,
@@ -622,6 +625,7 @@ class TObjectReader(BaseReader):
622
625
  return {
623
626
  "reader": cls,
624
627
  "name": cls_streamer_info["fName"],
628
+ "keep_data": item_path in cls.keep_data_itempaths,
625
629
  }
626
630
 
627
631
  @classmethod
@@ -629,13 +633,19 @@ class TObjectReader(BaseReader):
629
633
  if tree_config["reader"] is not cls:
630
634
  return None
631
635
 
632
- return uproot_custom.cpp.TObjectReader(tree_config["name"])
636
+ return uproot_custom.cpp.TObjectReader(
637
+ tree_config["name"],
638
+ tree_config["keep_data"],
639
+ )
633
640
 
634
641
  @classmethod
635
642
  def reconstruct_array(cls, raw_data, tree_config):
636
643
  if tree_config["reader"] is not cls:
637
644
  return None
638
645
 
646
+ if not tree_config["keep_data"]:
647
+ return None
648
+
639
649
  unique_ids, bits, pidf, pidf_offsets = raw_data
640
650
 
641
651
  return awkward.contents.RecordArray(
@@ -821,6 +831,9 @@ class BaseObjectReader(BaseReader):
821
831
 
822
832
  arr_dict = {}
823
833
  for s_cfg, s_data in zip(sub_tree_configs, raw_data):
834
+ if s_cfg["reader"] == TObjectReader and not s_cfg["keep_data"]:
835
+ continue
836
+
824
837
  s_name = s_cfg["name"]
825
838
  arr_dict[s_name] = reconstruct_array(s_data, s_cfg)
826
839
 
@@ -875,6 +888,9 @@ class ObjectHeaderReader(BaseReader):
875
888
 
876
889
  arr_dict = {}
877
890
  for s_cfg, s_data in zip(sub_tree_configs, raw_data):
891
+ if s_cfg["reader"] == TObjectReader and not s_cfg["keep_data"]:
892
+ continue
893
+
878
894
  s_name = s_cfg["name"]
879
895
  arr_dict[s_name] = reconstruct_array(s_data, s_cfg)
880
896
 
@@ -1,21 +0,0 @@
1
- # file generated by setuptools-scm
2
- # don't change, don't track in version control
3
-
4
- __all__ = ["__version__", "__version_tuple__", "version", "version_tuple"]
5
-
6
- TYPE_CHECKING = False
7
- if TYPE_CHECKING:
8
- from typing import Tuple
9
- from typing import Union
10
-
11
- VERSION_TUPLE = Tuple[Union[int, str], ...]
12
- else:
13
- VERSION_TUPLE = object
14
-
15
- version: str
16
- __version__: str
17
- __version_tuple__: VERSION_TUPLE
18
- version_tuple: VERSION_TUPLE
19
-
20
- __version__ = version = '1.1.2'
21
- __version_tuple__ = version_tuple = (1, 1, 2)