Support implicit expansion and array slicing in set #44

Open
opened 2026-07-23 07:37:55 +00:00 by UserCurt · 0 comments
UserCurt commented 2026-07-23 07:37:55 +00:00 (Migrated from codeberg.org)

When performing an assignment with set, sizes between resolved paths and value must currently match. Depending on the combination of UniformValues and UniformPaths, exactly which sizes matches (cell array and their contents) can differ though.

This issue proposes relaxing this requirement in two ways.

Implicit expansion (broadcasting)

Allow values with singleton dimensions to expand to match the size of the target. For example, if a path resolves to be 2×3 in size while the value being assigned is only 1×3, this would be allowed as the effective size of the value would expand to match 2×3 target grid.

Values may expand to match targets, but targets should never expand to match values.

With UniformPaths=true, expansion applies to the combined target grid. With UniformPaths=false, expansion applies independently inside each path group. Whether the outer cell array used by UniformPaths=false may itself expand across input path groups remains an open question.

Array slicing

Allow values to be decomposed into slices when matching the size of the target. For example, if a path resolves to be 1×3 and the user provides a 2×3 double, slicing this double into individual 2×1 slices for assignment. This would be in contrast to assigning the 2×3 double for each of the three paths.

A choice can be made for each dimension, whether it is to be sliced or repeated. For example, if a path resolves to be 1×3×4 and the user provides a 2×3×4 double, then there would be four possibilities:

  • The supplied 2×3×4 value is assigned to each of the three paths (no slicing)
  • Each 2×1×4 slice would be assigned to each of the three paths
  • Each 2×3×1 slice would be assigned to each of the three paths
  • Each 2×1×1 slice would be assigned to each of the three paths

With UniformPaths=true, decompose the array relative to the combined target dimensions. With UniformPaths=false, decompose each outer cell’s value relative to that path group’s target dimensions.

When UniformValues=true, the same array remains one complete payload.

With UniformPaths=true, decompose the array relative to the combined target dimensions. With UniformPaths=false, decompose each outer cell’s value relative to that path group’s target dimensions. When UniformValues=true, the same array remains one complete payload.

When performing an assignment with `set`, sizes between resolved paths and value must currently match. Depending on the combination of `UniformValues` and `UniformPaths`, exactly which sizes matches (cell array and their contents) can differ though. This issue proposes relaxing this requirement in two ways. ## Implicit expansion (broadcasting) Allow values with singleton dimensions to expand to match the size of the target. For example, if a path resolves to be 2×3 in size while the value being assigned is only 1×3, this would be allowed as the effective size of the value would expand to match 2×3 target grid. Values may expand to match targets, but targets should never expand to match values. With `UniformPaths=true`, expansion applies to the combined target grid. With `UniformPaths=false`, expansion applies independently inside each path group. Whether the outer cell array used by `UniformPaths=false` may itself expand across input path groups remains an open question. ## Array slicing Allow values to be decomposed into slices when matching the size of the target. For example, if a path resolves to be 1×3 and the user provides a 2×3 double, slicing this double into individual 2×1 slices for assignment. This would be in contrast to assigning the 2×3 double for each of the three paths. A choice can be made for each dimension, whether it is to be sliced or repeated. For example, if a path resolves to be 1×3×4 and the user provides a 2×3×4 double, then there would be four possibilities: - The supplied 2×3×4 value is assigned to each of the three paths (no slicing) - Each 2×1×4 slice would be assigned to each of the three paths - Each 2×3×1 slice would be assigned to each of the three paths - Each 2×1×1 slice would be assigned to each of the three paths With `UniformPaths=true`, decompose the array relative to the combined target dimensions. With `UniformPaths=false`, decompose each outer cell’s value relative to that path group’s target dimensions. When `UniformValues=true`, the same array remains one complete payload. With `UniformPaths=true`, decompose the array relative to the combined target dimensions. With `UniformPaths=false`, decompose each outer cell’s value relative to that path group’s target dimensions. When `UniformValues=true`, the same array remains one complete payload.
Sign in to join this conversation.
No description provided.