2 back ticks removed from titles
| link

Assigning `Sequence`Sequence to `Part`Part of a `SparseArray`SparseArray (bug?)

1
source | link

Assigning `Sequence` to `Part` of a `SparseArray` (bug?)

Part

▪ You can make an assignment like t[[spec]]=value to modify any part or sequence of parts in an expression.

▪ If expr is a SparseArray object, expr[[...]] gives the parts in the corresponding ordinary array.

SparseArray

▪ List and matrix operations are typically set up to work as they do on Normal[SparseArray[...]].

Part extracts specified parts of the array represented by a SparseArray object, rather than parts of the SparseArray expression itself.

array = Range[10]
(* {1, 2, 3, 4, 5, 6, 7, 8, 9, 10} *)

array[[2]] = Sequence[0, 0, 0];

array
(* {1, 0, 0, 0, 3, 4, 5, 6, 7, 8, 9, 10} *)

sparse = SparseArray[Range[10]];

sparse[[2]] = Sequence[0, 0, 0];

sparse[[2]]
(* {10} *)

ArrayRules[sparse]
(* ArrayRules::rect: Nonrectangular array encountered. >> *)
(* ArrayRules[SparseArray[Automatic, {10}, 0,
     {1, {{0, 10}, {{1}, {2}, {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}}}, 
     {1, 0, 0, 0, 3, 4, 5, 6, 7, 8, 9, 10}}]] *)

Is it a bug?