Skip to content

invalid looping over the std::array<long double,..> objects in PyROOT #21732

@VanyaBelyaev

Description

@VanyaBelyaev

Check duplicate issues.

  • Checked for duplicates

Description

Dear Experts

I've observed invalid &cobstrintuitive behavioos of loopingover std.array<lnog double,..> objects in PyRoot. It looks like __getitem__-based loop is correct, whle for-loop (__iter___ -based? )
produces weird results.
f

Reproducer

Reproducer is simple

import ROOT
std = ROOT.std

N  = 5 
A1 = std.array['int',N]
A2 = std.array['long double',N]

a1 = A1 ()
a2 = A2 ()

l1 = len ( a1 )
l2 = len ( a2 )

for i in range ( l1 ) : a1[i] = i
for i in range ( l2 ) : a2[i] = i

print ( 'a1:' , [ v for v in a1 ] , [ a1 [ i ] for i in range ( l1 ) ] ) 
print ( 'a2:' , [ v for v in a2 ] , [ a2 [ i ] for i in range ( l2 ) ] ) 

The output is

$ python ./tst_620.py
a1: [0, 1, 2, 3, 4] [0, 1, 2, 3, 4]
a2: [0, 0, 9223372036854775808, 16383, 9223372036854775808] [0.0, 1.0, 2.0, 3.0, 4.0]

ROOT version

ROOT 6.39 from LCG dev3 cvmfs nightly build

Installation method

LCG cvmfs nighly

Operating system

Linux

Additional context

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions