Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
\endpythondoc
'''

from . import pythonization

from ._generic import _add_getitem_checked

Check failure on line 42 in bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tarray.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tarray.py:40:1: I001 Import block is un-sorted or un-formatted


@pythonization("TArray", is_prefix=True)
Expand All @@ -48,10 +48,7 @@
# klass: class to be pythonized
# name: string containing the name of the class

if name == 'TArray':
# Support `len(a)` as `a.GetSize()`
klass.__len__ = klass.GetSize
else:
if not name == 'TArray':
# Add checked __getitem__. It has to be directly added to the TArray
# subclasses, which have a default __getitem__.
# The new __getitem__ allows to throw pythonic IndexError when index
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
# For the list of contributors see $ROOTSYS/README/CREDITS. #
################################################################################

from . import pythonization
import cppyy

Check failure on line 12 in bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcollection.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tcollection.py:11:1: I001 Import block is un-sorted or un-formatted


# Python-list-like methods
Expand Down Expand Up @@ -98,9 +98,6 @@
# Parameters:
# klass: class to be pythonized

# Support `len(c)` as `c.GetEntries()`
klass.__len__ = klass.GetEntries

# Add Python lists methods
klass.append = klass.Add
klass.remove = _remove_pyz
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ def pythonize_tstring(klass):
# Parameters:
# klass: class to be pythonized

# Support `len(s)` as `s.Length()`
klass.__len__ = klass.Length

# Add string representation
klass.__str__ = klass.Data
klass.__repr__ = lambda self: "'{}'".format(self)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# For the list of contributors see $ROOTSYS/README/CREDITS. #
################################################################################

from . import pythonization

from ._generic import _add_getitem_checked

Check failure on line 13 in bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tvector3.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tvector3.py:11:1: I001 Import block is un-sorted or un-formatted


@pythonization('TVector3')
Expand All @@ -18,9 +18,6 @@
# Parameters:
# klass: class to be pythonized

# `len(v)` is always 3
klass.__len__ = lambda _: 3

# Add checked __getitem__.
# Allows to throw pythonic IndexError when index is out of range
# and to iterate over the vector.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
# For the list of contributors see $ROOTSYS/README/CREDITS. #
################################################################################

from . import pythonization

from ._generic import _add_getitem_checked

Check failure on line 13 in bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tvectort.py

View workflow job for this annotation

GitHub Actions / ruff

Ruff (I001)

bindings/pyroot/pythonizations/python/ROOT/_pythonization/_tvectort.py:11:1: I001 Import block is un-sorted or un-formatted


@pythonization('TVectorT', is_prefix=True)
Expand All @@ -18,9 +18,6 @@
# Parameters:
# klass: class to be pythonized

# Support `len(v)` as `v.GetNoElements()`
klass.__len__ = klass.GetNoElements

# Add checked __getitem__.
# Allows to throw pythonic IndexError when index is out of range
# and to iterate over the vector.
Expand Down
1 change: 1 addition & 0 deletions core/base/inc/TString.h
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,7 @@ friend std::strong_ordering operator<=>(const TString &s1, const TString &s2) {
Bool_t IsWhitespace() const { return (Length() == CountChar(' ')); }
Ssiz_t Last(char c) const;
Ssiz_t Length() const { return IsLong() ? GetLongSize() : GetShortSize(); }
inline std::size_t size() const { return Length(); }
Bool_t MaybeRegexp() const;
Bool_t MaybeWildcard() const;
TString MD5() const;
Expand Down
2 changes: 2 additions & 0 deletions core/cont/inc/TArray.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ class TArray {
Int_t GetSize() const { return fN; }
virtual void Set(Int_t n) = 0;

inline std::size_t size() const { return GetSize(); }

virtual Double_t GetAt(Int_t i) const = 0;
virtual void SetAt(Double_t v, Int_t i) = 0;

Expand Down
1 change: 1 addition & 0 deletions core/cont/inc/TCollection.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ class TCollection : public TObject {
TObject *operator()(const char *name) const;
TObject *FindObject(const TObject *obj) const override;
virtual Int_t GetEntries() const { return GetSize(); }
inline std::size_t size() const { return GetEntries(); }
const char *GetName() const override;
virtual TObject **GetObjectRef(const TObject *obj) const = 0;
/// Return the *capacity* of the collection, i.e. the current total amount of space that has been allocated so far.
Expand Down
3 changes: 3 additions & 0 deletions math/physics/inc/TVector3.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ class TVector3 : public TObject {
~TVector3() override = default;
// Destructor

/// The length is always 3. For compatibility with the standard library.
constexpr std::size_t size() const { return 3; }

Double_t operator () (int) const;
inline Double_t operator [] (int) const;
// Get components by index (Geant4).
Expand Down
Loading