Skip to content

Commit

Permalink
more tests
Browse files Browse the repository at this point in the history
more tests

fix

print everything in PyROOT

add coverage

add coverage
  • Loading branch information
Moelf committed Oct 17, 2024
1 parent f790c8e commit f7a6995
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/cvmfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,15 @@ jobs:
- uses: julia-actions/julia-buildpkg@v1
- name: Generate root file
run: |
julia --project ./test/RNTupleWriting/output_sample.jl test1.root
julia --code-coverage --project ./test/RNTupleWriting/output_sample.jl test1.root
- uses: cvmfs-contrib/github-action-cvmfs@v4
- name: Read root file in C++
run: |
source /cvmfs/sft.cern.ch/lcg/views/dev3/latest/x86_64-ubuntu2204-gcc11-opt/setup.sh
python ./test/RNTupleWriting/test1.py test1.root
- uses: julia-actions/julia-processcoverage@v1
- uses: codecov/codecov-action@v4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: lcov.info
5 changes: 1 addition & 4 deletions src/RNTuple/Writing/TFileWriter.jl
Original file line number Diff line number Diff line change
Expand Up @@ -518,7 +518,7 @@ function schema_to_field_column_records(table)
column_records = UnROOT.ColumnRecord[]

for (input_T, input_name) in zip(input_Ts, input_names)
add_field_column_record!(field_records, column_records, input_T, input_name, parent_field_id=length(field_records), col_field_id=length(column_records))
add_field_column_record!(field_records, column_records, input_T, input_name, parent_field_id=length(field_records))
end
return field_records, column_records
end
Expand Down Expand Up @@ -546,9 +546,6 @@ function write_rntuple(file::IO, table; file_name="test_ntuple_minimal.root", rn
error("Top-level columns must have the same length")
end
input_length = length(input_cols[begin])
if input_length > 65535
error("Input too long: RNTuple writing currently only supports a single page (65535 elements)")
end

rntAnchor_update = Dict{Symbol, Any}()

Expand Down
16 changes: 10 additions & 6 deletions test/RNTupleWriting/output_sample.jl
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
using UnROOT

const RNT_primitive_Ts = [Float64, Float32, Float16, Int64, Int32, Int16, Int8, UInt64, UInt32, UInt16]
Nitems = 10
data = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
newtable = Dict(
"x1" => Float64.(data),
"x2" => Float32.(data),
"x3" => Int32.(data),
"y1" => UInt16.(data),
)

newtable = Dict( "x_$T" => T.(data) for T in RNT_primitive_Ts)
newtable["x_Bool"] = isodd.(data)
newtable["x_String"] = string.(data)

for T in RNT_primitive_Ts
newtable["x_vec_$T"] = [rand(T, data[i]) for i in 1:Nitems]
end

UnROOT.write_rntuple(open(only(ARGS), "w"), newtable; rntuple_name="myntuple")
12 changes: 9 additions & 3 deletions test/RNTupleWriting/test1.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
import ROOT
import sys

Nitems = 10
data = [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]

df = ROOT.RDataFrame("myntuple", sys.argv[1])
if len(list(df.GetColumnNames())) != 4:
sys.exit(1)

if list(df.Take['std::int32_t']("x3")) != [5, 6, 7, 8, 9, 10, 11, 12, 13, 14]:
if list(df.Take['std::int32_t']("x_Int32")) != data:
sys.exit(1)
if list(df.Take['std::int64_t']("x_Int64")) != data:
sys.exit(1)

for n in df.GetColumnNames():
df.Display(n).Print()

0 comments on commit f7a6995

Please sign in to comment.