Stopped exporting `slice-indexes-array'
This commit is contained in:
parent
897ebeae83
commit
6ca52be0ae
|
@ -5,8 +5,7 @@
|
||||||
array-ref
|
array-ref
|
||||||
array-set!
|
array-set!
|
||||||
array-indexes-ref
|
array-indexes-ref
|
||||||
array-indexes-set!
|
array-indexes-set!))
|
||||||
slice-indexes-array))
|
|
||||||
|
|
||||||
(require/untyped-contract
|
(require/untyped-contract
|
||||||
(begin (require "array-struct.rkt"
|
(begin (require "array-struct.rkt"
|
||||||
|
@ -16,8 +15,7 @@
|
||||||
[array-ref (All (A) ((Array A) (Vectorof Integer) -> A))]
|
[array-ref (All (A) ((Array A) (Vectorof Integer) -> A))]
|
||||||
[array-set! (All (A) ((Settable-Array A) (Vectorof Integer) A -> Void))]
|
[array-set! (All (A) ((Settable-Array A) (Vectorof Integer) A -> Void))]
|
||||||
[array-indexes-ref (All (A) ((Array A) (Array (Vectorof Integer)) -> (Array A)))]
|
[array-indexes-ref (All (A) ((Array A) (Array (Vectorof Integer)) -> (Array A)))]
|
||||||
[array-indexes-set! (All (A) ((Settable-Array A) (Array (Vectorof Integer)) (Array A) -> Void))]
|
[array-indexes-set! (All (A) ((Settable-Array A) (Array (Vectorof Integer)) (Array A) -> Void))])
|
||||||
[slice-indexes-array ((Vectorof Integer) (Listof Slice-Spec) -> (Array Indexes))])
|
|
||||||
|
|
||||||
(provide
|
(provide
|
||||||
array-ref
|
array-ref
|
||||||
|
@ -36,5 +34,4 @@
|
||||||
::... slice-dots?
|
::... slice-dots?
|
||||||
::new slice-new-axis? slice-new-axis-length
|
::new slice-new-axis? slice-new-axis-length
|
||||||
array-slice-ref
|
array-slice-ref
|
||||||
slice-indexes-array
|
|
||||||
array-slice-set!)
|
array-slice-set!)
|
||||||
|
|
|
@ -237,13 +237,10 @@
|
||||||
(match-define (cons k dk) na)
|
(match-define (cons k dk) na)
|
||||||
(array-axis-insert arr k dk)))))
|
(array-axis-insert arr k dk)))))
|
||||||
|
|
||||||
(: slice-indexes-array (In-Indexes (Listof Slice-Spec) -> (Array Indexes)))
|
|
||||||
(define (slice-indexes-array ds slices)
|
|
||||||
(array-slice-ref (indexes-array ds) slices))
|
|
||||||
|
|
||||||
(: array-slice-set! (All (A) ((Settable-Array A) (Listof Slice-Spec) (Array A) -> Void)))
|
(: array-slice-set! (All (A) ((Settable-Array A) (Listof Slice-Spec) (Array A) -> Void)))
|
||||||
(define (array-slice-set! arr slices vals)
|
(define (array-slice-set! arr slices vals)
|
||||||
(array-indexes-set! arr (slice-indexes-array (array-shape arr) slices) vals))
|
(let ([idxs (array-slice-ref (indexes-array (array-shape arr)) slices)])
|
||||||
|
(array-indexes-set! arr idxs vals)))
|
||||||
|
|
||||||
;; ---------------------------------------------------------------------------------------------------
|
;; ---------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
|
@ -1042,7 +1042,8 @@ If @racket[idxs] and @racket[vals] do not have the same shape, they are @tech{br
|
||||||
(define idxs (array #['#(0 0) '#(1 1)]))
|
(define idxs (array #['#(0 0) '#(1 1)]))
|
||||||
(array-indexes-set! arr idxs (array -1))
|
(array-indexes-set! arr idxs (array -1))
|
||||||
arr]
|
arr]
|
||||||
When indexes are repeated in @racket[idxs], they are mutated in some unspecified order.
|
When two indexes in @racket[idxs] are the same, the element at that index is mutated more
|
||||||
|
than once in some unspecified order.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(array-slice-ref [arr (Array A)] [specs (Listof Slice-Spec)]) (Array A)]{
|
@defproc[(array-slice-ref [arr (Array A)] [specs (Listof Slice-Spec)]) (Array A)]{
|
||||||
|
@ -1053,18 +1054,12 @@ Returns a transformation of @racket[arr] according to the list of slice specific
|
||||||
@defproc[(array-slice-set! [arr (Settable-Array A)] [specs (Listof Slice-Spec)] [vals (Array A)])
|
@defproc[(array-slice-set! [arr (Settable-Array A)] [specs (Listof Slice-Spec)] [vals (Array A)])
|
||||||
Void]{
|
Void]{
|
||||||
Like @racket[array-indexes-set!], but for slice specifications. Equivalent to
|
Like @racket[array-indexes-set!], but for slice specifications. Equivalent to
|
||||||
@racketblock[(let ([idxs (slice-indexes-array (array-shape arr) specs)])
|
@racketblock[(let ([idxs (array-slice-ref (indexes-array (array-shape arr)) specs)])
|
||||||
(array-indexes-set! arr idxs vals))]
|
(array-indexes-set! arr idxs vals))]
|
||||||
When a slice specification refers to an element in @racket[arr] more than once, the element is
|
When a slice specification refers to an element in @racket[arr] more than once, the element is
|
||||||
mutated more than once in some unspecified order.
|
mutated more than once in some unspecified order.
|
||||||
}
|
}
|
||||||
|
|
||||||
@defproc[(slice-indexes-array [ds In-Indexes] [specs (Listof Slice-Spec)]) (Array Indexes)]{
|
|
||||||
Returns the indexes of the elements that would be retrieved if an array with shape @racket[ds]
|
|
||||||
were sliced according to @racket[specs].
|
|
||||||
Equivalent to @racketblock[(array-slice-ref (indexes-array ds) specs)]
|
|
||||||
}
|
|
||||||
|
|
||||||
@subsection[#:tag "array:slice-specs"]{Slice Specifications}
|
@subsection[#:tag "array:slice-specs"]{Slice Specifications}
|
||||||
|
|
||||||
@defidform[Slice-Spec]{
|
@defidform[Slice-Spec]{
|
||||||
|
|
|
@ -613,7 +613,7 @@
|
||||||
[slices (list (:: 0 4 2) (:: 2 -1 -2))])
|
[slices (list (:: 0 4 2) (:: 2 -1 -2))])
|
||||||
(check-equal? (array-indexes-ref arr idxs)
|
(check-equal? (array-indexes-ref arr idxs)
|
||||||
(array #[0 2 3 5 7 8]))
|
(array #[0 2 3 5 7 8]))
|
||||||
(check-equal? (array-indexes-ref arr (slice-indexes-array (array-shape arr) slices))
|
(check-equal? (array-indexes-ref arr (array-slice-ref (indexes-array (array-shape arr)) slices))
|
||||||
(array-slice-ref arr slices))
|
(array-slice-ref arr slices))
|
||||||
(array-indexes-set! arr idxs vals)
|
(array-indexes-set! arr idxs vals)
|
||||||
(check-equal? arr (array #[#['a 1 2 3 4 5]
|
(check-equal? arr (array #[#['a 1 2 3 4 5]
|
||||||
|
|
Loading…
Reference in New Issue
Block a user