Skip to content

concatenate_data_sets change data label of input sacc's #64

@carlosggarcia

Description

@carlosggarcia

If labels are passed to concatenate_data_sets, this will not only modify the label in the final sacc file, but also in the input ones.

Expected behavior: the original sacc's are left the same.

I guess the problem is with this line:

sacc/sacc/sacc.py

Line 1261 in e4c23bc

d = copy.copy(d)
; which is not copying everything but referring to the memory for some quantities of the sacc file.

This can be reproduced with this code (basically from test/test_sacc2.py)

import numpy as np
import sacc

s1 = sacc.Sacc()

# Tracer
z = np.arange(0., 1.0, 0.01)
nz = (z-0.5)**2/0.1**2
s1.add_tracer('NZ', 'source_0', z, nz)

for i in range(20):
    ee = 0.1 * i
    tracers = ('source_0', 'source_0')
    s1.add_data_point(sacc.standard_types.galaxy_shear_cl_ee,
                      tracers, ee, ell=10.0*i)

s2 = sacc.Sacc()

# Tracer
z = np.arange(0., 1.0, 0.01)
nz = (z-0.5)**2/0.1**2
s2.add_tracer('NZ', 'source_0', z, nz,
              quantity='galaxy_shear', spin=2)

for i in range(20):
    ee = 0.1 * i
    tracers = ('source_0', 'source_0')
    s2.add_data_point(sacc.standard_types.galaxy_shear_cl_ee,
                      tracers, ee, ell=10.0*i, label='xxx')


# Clash
s3 = sacc.concatenate_data_sets(s1, s2, labels=['1', '2'])

for i in range(20):
    # assert s2.data[i].get_tag('label') == 'xxx'
    print(s2.data[i].get_tag('label'))

for i in range(20):
    # assert s1.data[i].get_tag('label') is None
    print(s1.data[i].get_tag('label'))

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions