From 6ca52be0aeed7e7dfe524cbbe9c4a78f7e93ce74 Mon Sep 17 00:00:00 2001 From: Neil Toronto Date: Mon, 3 Dec 2012 22:11:02 -0700 Subject: [PATCH] Stopped exporting `slice-indexes-array' --- collects/math/private/array/array-indexing.rkt | 7 ++----- collects/math/private/array/typed-array-indexing.rkt | 7 ++----- collects/math/scribblings/math-array.scrbl | 11 +++-------- collects/math/tests/array-tests.rkt | 2 +- 4 files changed, 8 insertions(+), 19 deletions(-) diff --git a/collects/math/private/array/array-indexing.rkt b/collects/math/private/array/array-indexing.rkt index f1a7af2c2e..cb33b189f9 100644 --- a/collects/math/private/array/array-indexing.rkt +++ b/collects/math/private/array/array-indexing.rkt @@ -5,8 +5,7 @@ array-ref array-set! array-indexes-ref - array-indexes-set! - slice-indexes-array)) + array-indexes-set!)) (require/untyped-contract (begin (require "array-struct.rkt" @@ -16,8 +15,7 @@ [array-ref (All (A) ((Array A) (Vectorof Integer) -> A))] [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-set! (All (A) ((Settable-Array A) (Array (Vectorof Integer)) (Array A) -> Void))] - [slice-indexes-array ((Vectorof Integer) (Listof Slice-Spec) -> (Array Indexes))]) + [array-indexes-set! (All (A) ((Settable-Array A) (Array (Vectorof Integer)) (Array A) -> Void))]) (provide array-ref @@ -36,5 +34,4 @@ ::... slice-dots? ::new slice-new-axis? slice-new-axis-length array-slice-ref - slice-indexes-array array-slice-set!) diff --git a/collects/math/private/array/typed-array-indexing.rkt b/collects/math/private/array/typed-array-indexing.rkt index 2753fc72ed..3cd804bf6c 100644 --- a/collects/math/private/array/typed-array-indexing.rkt +++ b/collects/math/private/array/typed-array-indexing.rkt @@ -237,13 +237,10 @@ (match-define (cons k dk) na) (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))) (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))) ;; --------------------------------------------------------------------------------------------------- diff --git a/collects/math/scribblings/math-array.scrbl b/collects/math/scribblings/math-array.scrbl index 4d0e78d586..f4fa879fd5 100644 --- a/collects/math/scribblings/math-array.scrbl +++ b/collects/math/scribblings/math-array.scrbl @@ -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)])) (array-indexes-set! arr idxs (array -1)) 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)]{ @@ -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)]) Void]{ 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))] 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. } -@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} @defidform[Slice-Spec]{ diff --git a/collects/math/tests/array-tests.rkt b/collects/math/tests/array-tests.rkt index 0cda5804f9..948c618910 100644 --- a/collects/math/tests/array-tests.rkt +++ b/collects/math/tests/array-tests.rkt @@ -613,7 +613,7 @@ [slices (list (:: 0 4 2) (:: 2 -1 -2))]) (check-equal? (array-indexes-ref arr idxs) (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-indexes-set! arr idxs vals) (check-equal? arr (array #[#['a 1 2 3 4 5]