Honour the explicit format argument of seqStr_2_obj

TL;DR

  • tango.utils.seqStr_2_obj now converts correctly when an explicit tg_format is passed. It previously returned an empty list for every SPECTRUM input, and for IMAGE input of any type other than string, integer or float.
  • A scalar type with no array equivalent, such as DevEnum, now raises ValueError naming the type instead of a bare KeyError.

Reported in #789.

Key Facts

  • The cause was transposed operands: _seqStr_2_obj_from_type takes (seq, tg_type), but all three calls from the format-aware helper passed (tg_type, seq). No type test could then match, so the conversion fell through to its empty-list fallback and returned [] rather than raising. Silent wrong results, not an error.
  • Two accidents limited the blast radius and are worth knowing when reviewing the diff:
    • AttrDataFormat.SCALAR compares equal to zero, so the if tg_format: gate treated an explicit SCALAR as "no format given" and skipped the broken helper entirely, taking the correct path by luck. The gate now tests is not None. Fixing only the gate, without the operand order, would have turned a working SCALAR call into a broken one.
    • The IMAGE branch open-coded its own conversion for string, integer and float using the correctly named operand, which is why only the remaining types reached the transposed call.
  • The IMAGE branch now maps the SPECTRUM conversion over the rows instead of enumerating types. Converting an image row is converting a spectrum, so this removes the per-type special cases and makes boolean images work like the rest.
  • No in-tree caller is affected. tango/device_class.py is the only consumer and always omits tg_format, so it takes the unchanged no-format path. The fixed behaviour is reachable only through the public API, which is why nothing caught this.
  • Review hotspot: scalar_to_array_type() replaces a direct _scalar_to_array_type[...] lookup. That is what converts the KeyError into a ValueError, and it applies to both SPECTRUM and IMAGE.

Caveats

  • The first commit adds the tests and fails on its own; the second makes them pass. Intentional, so the reproduction is in history.
  • IMAGE input that is a flat sequence rather than a sequence of rows is malformed and was previously returned unchanged for DevString. It is now processed per row like any other type. No in-tree caller does this.

🤖 Generated with Claude Code

Merge request reports

Loading
Loading