Implement named argument to disallow some dimensions from automatic assignment #25

Open
opened 2025-10-13 23:23:06 +00:00 by UserCurt · 0 comments
UserCurt commented 2025-10-13 23:23:06 +00:00 (Migrated from codeberg.org)

This issue proposes the new feature that strictly forbids the automatic assignment of certain dimensions, as specified by the user. This would be done through a named argument, here proposed as DisallowedDimensions.

There would be no interaction with the Dimensions named argument if there are no shared dimensions between these two named arguments. If there is a shared dimension between these two named arguments, it will be ignored from Dimensions and disallowed from automatic assignment.

If a dimension specifier is given with a dimension equal to one listed in DisallowedDimensions, that dimension would still be used in that spot but would not be allowed for automatic assignment, not only due to being part of DisallowedDimensions but also from being used once already. It would be redundant to include a manually-assigned dimension as one in DisallowedDimensions as it would already be disallowed from automatic dimension assignment.

Here are a number of examples showing the proposed behavior:

S = struct(A=struct(X=1, Y=2, Z=3), B=struct(X=4, Y=5, Z=6));

mpath.get(S, "/*/*") % 2×3

mpath.get(S, "/*/*", DisallowedDimensions=1)      % 1×2×3
mpath.get(S, "/*/*", DisallowedDimensions=2)      % 2×1×3
mpath.get(S, "/*/*", DisallowedDimensions=[1 2])  % 1×1×2×3
mpath.get(S, "/*/*", DisallowedDimensions=[2 1])  % 1×1×2×3, order does not matter

mpath.get(S, "/*/*", Dimensions=1, DisallowedDimensions=1)  % 1×2×3, Dimensions=1 is ignored
mpath.get(S, "/*/*", Dimensions=1, DisallowedDimensions=2)  % 2×1×3
mpath.get(S, "/*/*", Dimensions=2, DisallowedDimensions=1)  % 1×2×3
mpath.get(S, "/*/*", Dimensions=2, DisallowedDimensions=2)  % 2×1×3, Dimensions=2 is ignored

mpath.get(S, "/*#1/*", DisallowedDimensions=1)  % 2×3, DisallowedDimensions=1 is redundant
mpath.get(S, "/*#1/*", DisallowedDimensions=2)  % 2×1×3
mpath.get(S, "/*/*#1", DisallowedDimensions=1)  % 3×2, DisallowedDimensions=1 is redundant
mpath.get(S, "/*/*#1", DisallowedDimensions=2)  % 3×1×2
This issue proposes the new feature that strictly forbids the automatic assignment of certain dimensions, as specified by the user. This would be done through a named argument, here proposed as `DisallowedDimensions`. There would be no interaction with the `Dimensions` named argument if there are no shared dimensions between these two named arguments. If there is a shared dimension between these two named arguments, it will be ignored from `Dimensions` and disallowed from automatic assignment. If a dimension specifier is given with a dimension equal to one listed in `DisallowedDimensions`, that dimension would still be used in that spot but would not be allowed for automatic assignment, not only due to being part of `DisallowedDimensions` but also from being used once already. It would be redundant to include a manually-assigned dimension as one in `DisallowedDimensions` as it would already be disallowed from automatic dimension assignment. Here are a number of examples showing the proposed behavior: ```matlab S = struct(A=struct(X=1, Y=2, Z=3), B=struct(X=4, Y=5, Z=6)); mpath.get(S, "/*/*") % 2×3 mpath.get(S, "/*/*", DisallowedDimensions=1) % 1×2×3 mpath.get(S, "/*/*", DisallowedDimensions=2) % 2×1×3 mpath.get(S, "/*/*", DisallowedDimensions=[1 2]) % 1×1×2×3 mpath.get(S, "/*/*", DisallowedDimensions=[2 1]) % 1×1×2×3, order does not matter mpath.get(S, "/*/*", Dimensions=1, DisallowedDimensions=1) % 1×2×3, Dimensions=1 is ignored mpath.get(S, "/*/*", Dimensions=1, DisallowedDimensions=2) % 2×1×3 mpath.get(S, "/*/*", Dimensions=2, DisallowedDimensions=1) % 1×2×3 mpath.get(S, "/*/*", Dimensions=2, DisallowedDimensions=2) % 2×1×3, Dimensions=2 is ignored mpath.get(S, "/*#1/*", DisallowedDimensions=1) % 2×3, DisallowedDimensions=1 is redundant mpath.get(S, "/*#1/*", DisallowedDimensions=2) % 2×1×3 mpath.get(S, "/*/*#1", DisallowedDimensions=1) % 3×2, DisallowedDimensions=1 is redundant mpath.get(S, "/*/*#1", DisallowedDimensions=2) % 3×1×2 ```
Sign in to join this conversation.
No description provided.