Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: consistent slice behavior with Python #352

Merged
merged 1 commit into from
Feb 7, 2024

Conversation

usamoi
Copy link
Collaborator

@usamoi usamoi commented Feb 7, 2024

Current subslice behavior is consistent with PostgreSQL:

SELECT ('{0, 1, 2, 3, 4, 5, 6, 7}'::real[])[3:6];
  float4   
-----------
 {2,3,4,5}
(1 row)

SELECT ('[0, 1, 2, 3, 4, 5, 6, 7]'::vector)[3:6];
  vector   
-----------
 [2, 3, 4, 5]
(1 row)

Making it consistent with Python should be better.

>>> [0, 1, 2, 3, 4, 5, 6, 7][3:6]
[3, 4, 5]

SELECT ('[0, 1, 2, 3, 4, 5, 6, 7]'::vector)[3:6];
  vector   
-----------
 [3, 4, 5]
(1 row)

Signed-off-by: usamoi <usamoi@outlook.com>
@usamoi usamoi requested a review from VoVAllen February 7, 2024 03:00
@usamoi usamoi changed the title chore: consistent slice behavior with python chore: consistent slice behavior with Python Feb 7, 2024
@gaocegege gaocegege requested a review from kemingy February 7, 2024 03:21
Copy link
Member

@VoVAllen VoVAllen left a comment

Choose a reason for hiding this comment

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

haha. Programmers should count from 0, unless you are a mathematician.

@usamoi usamoi added this pull request to the merge queue Feb 7, 2024
Merged via the queue into tensorchord:main with commit c6dabc7 Feb 7, 2024
7 checks passed
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