Skip to content

Entry order in output from operations between DataGroups is unpredictable #3768

Description

@nvaytet

Example:

import scipp as sc

a = sc.DataGroup({'1': sc.scalar(1.0, unit='m'),
                  '2': sc.scalar(2.0, unit='m'),
                  '3': sc.scalar(3.0, unit='m'),
                  '4': sc.scalar(4.0, unit='m'),
                 })

b = a**2
b.keys()
dict_keys(['1', '2', '3', '4'])

Order is preserved.
Then doing c = a * b yields c.keys() as ['3', '2', '4', '1']

I understand that if the two operands don't have the same keys, you need to output only the keys found in both.
But if both operands have the same keys, can we preserve the order? (I guess we would have to pick the order of e.g. the first operand)

A use case where the current behaviour is causing problems:
Making a plot with a, you have the blue line corresponding to entry '1'.
Then making a plot with c, the blue line is now corresponding to entry '3'.

Activity

  1. self-assigned this
    on Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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