Skip to content

Subscripting with a scalar value a signal with dimensions along its last dimension produces a signal that cannot be subscripted #3069

Description

@merlea

Affiliation
SPC/EPFL

Version(s) Affected
stable_release-7-158-2
I tested this back to version stable_release-7-0-X but not before and all versions seem to have the same behaviour.

Platform(s)
Ubuntu 24.04

Installation Method(s)
DEB package

Describe the bug
Starting from a 2D signal (or any signal with more than 1 dimensions) where the dimensions are explicitely defined. If this signal is subscripted using a scalar value along its last dimension, the resulting signal has 1D data but still 2 explicit dimensions.

As a result of this any attempt to subscript this new signal will fail since it will not pass the test

if (narg - 1 > dimct || (psig && psig->ndesc - 2 > dimct))
(number of descriptors minus 2 is larger than the number of dimensions of the data).

To Reproduce
Steps to reproduce the behavior:

  1. Open tdic
  2. Create a 2D signal with dimensions TDI> _aa = make_Signal([5:15,-5:5],*,make_dim(*,(0:10)*1e-3),make_dim(*,[0.903,1.010]))
  3. Create a new signal by subscripting it along its second dimension with a scalar value TDI> _bb = _aa[*,0.903]
  4. Attempt to subscript signal _bb will result in an error
TDI> _bb[*:*:1e-2]
%TDI Error in SUBSCRIPT(_bb, * : * : .01)
%TDI Error in EXECUTE("_bb[*:*:1e-2]")

Expected behavior
The result of the first subscripting operation should be a well-formed signal with consistent number of dimensions for the data and the signal, which should allow subsequent uses of the subscript function.

Screenshots
N/A

Additional context
This issue does not appear if the last dimension of the original signal is not defined (or replaced by *) or if it is not a signal (pure data array).

I think the fix should simply get rid of the trailing scalar dimensions. If one is interested in keeping these last dimensions, subscripting with an array of size 1 instead of a scalar value will provide a well-formed signal.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugAn unexpected problem or unintended behavior

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions