From 37c50521d36f1ed56b812687f65a4a99494d7a8a Mon Sep 17 00:00:00 2001 From: Jim Pivarski Date: Fri, 23 Feb 2024 11:59:40 -0600 Subject: [PATCH 1/2] feat: implement TGraph-writing --- src/uproot/models/TGraph.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/uproot/models/TGraph.py b/src/uproot/models/TGraph.py index 24b288031..717ce606f 100644 --- a/src/uproot/models/TGraph.py +++ b/src/uproot/models/TGraph.py @@ -338,7 +338,16 @@ def _serialize(self, out, header, name, tobject_flags): where = len(out) for x in self._bases: x._serialize(out, True, name, tobject_flags) - raise NotImplementedError("FIXME") + out.extend([ + struct.pack(">i", self._members["fNpoints"]), + b"\x01", + self._members["fX"].astype(">f8").tobytes(), + b"\x01", + self._members["fY"].astype(">f8").tobytes(), + b"@\x00\x00\x1f\xff\xff\xff\xffTList\x00@\x00\x00\x11\x00\x05\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + struct.pack(">d", self._members["fMinimum"]), + struct.pack(">d", self._members["fMaximum"]), + ]) if header: num_bytes = sum(len(x) for x in out[where:]) version = 4 From 403232aa29292c47001f45fd93f3b59e5fed1f93 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 23 Feb 2024 18:05:00 +0000 Subject: [PATCH 2/2] style: pre-commit fixes --- src/uproot/models/TGraph.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/uproot/models/TGraph.py b/src/uproot/models/TGraph.py index 717ce606f..581a40f5e 100644 --- a/src/uproot/models/TGraph.py +++ b/src/uproot/models/TGraph.py @@ -338,16 +338,18 @@ def _serialize(self, out, header, name, tobject_flags): where = len(out) for x in self._bases: x._serialize(out, True, name, tobject_flags) - out.extend([ - struct.pack(">i", self._members["fNpoints"]), - b"\x01", - self._members["fX"].astype(">f8").tobytes(), - b"\x01", - self._members["fY"].astype(">f8").tobytes(), - b"@\x00\x00\x1f\xff\xff\xff\xffTList\x00@\x00\x00\x11\x00\x05\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", - struct.pack(">d", self._members["fMinimum"]), - struct.pack(">d", self._members["fMaximum"]), - ]) + out.extend( + [ + struct.pack(">i", self._members["fNpoints"]), + b"\x01", + self._members["fX"].astype(">f8").tobytes(), + b"\x01", + self._members["fY"].astype(">f8").tobytes(), + b"@\x00\x00\x1f\xff\xff\xff\xffTList\x00@\x00\x00\x11\x00\x05\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00", + struct.pack(">d", self._members["fMinimum"]), + struct.pack(">d", self._members["fMaximum"]), + ] + ) if header: num_bytes = sum(len(x) for x in out[where:]) version = 4