Skip to content

Handle empty arrays in a variety of functions - #1533

Merged
pavanky merged 2 commits into
arrayfire:develfrom
syurkevi:zero_len
Aug 22, 2016
Merged

pavanky merged 2 commits into
arrayfire:develfrom
syurkevi:zero_len

Conversation

@syurkevi

@syurkevi syurkevi commented Aug 4, 2016 •

Copy link
Copy Markdown
Contributor

Allows indexing with empty arrays . Also handles weird cases such as af::det( [ ] ) = 1

Comment thread src/api/c/assign.cpp Outdated

if(rhsDims.ndims() == 0) {
dim_t my_dims[] = { 0, 0, 0, 0 };
return af_create_handle(out, AF_MAX_DIMS, my_dims, rhsType);

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.

This is incorrect. We should check if both rhs and index are empty and then return a retained version of lhs.

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.

If lhs is empty, then return the way you did here.

@shehzan10

Copy link
Copy Markdown
Member

May I suggest tests for all of these?

@syurkevi
syurkevi force-pushed the zero_len branch 2 times, most recently from d074549 to d001252 Compare August 4, 2016 23:33
allow indexing with empty arrays
@shehzan10

Copy link
Copy Markdown
Member

build arrayfire linux ci
build arrayfire osx ci
build arrayfire windows ci

@shehzan10

Copy link
Copy Markdown
Member

build arrayfire linux ci
build arrayfire osx ci
build arrayfire windows ci

@shehzan10

Copy link
Copy Markdown
Member

build arrayfire windows ci

@pavanky
pavanky merged commit 73ed507 into arrayfire:devel Aug 22, 2016
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.

3 participants