Skip to content

add documentation on [::-1] - #51

Merged
davidkoski merged 1 commit into
ml-explore:mainfrom
davidkoski:reverse
Mar 21, 2024
Merged

davidkoski merged 1 commit into
ml-explore:mainfrom
davidkoski:reverse

Conversation

@davidkoski

Copy link
Copy Markdown
Member

Documentation for cases like #50

`array[:, -1, :]` | `array[-1, axis: 1]`
`array[..., ::2]` | `array[stride: 2, axis: -1]`
`array[::-1]` | `array[stride: -1, axis: 0]` -- reverse first dimension of array
`array[..., ::-1]` | `array[stride: -1, axis: -1]` or `array[stride: -1]` -- reverse last dimension of array

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These are the patterns we see

image

// reverse first dimension
assertEqual(a.reshaped(1, 1, 4)[stride: -1, axis: 0], MLXArray(0 ..< 4).reshaped(1, 1, 4))

}

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests to serve as an example (and that I could use to make sure I was doing it right!)

@awni awni left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants