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

Refined 'tests/array_split.py' w/ more essential input shapes #178

Merged
merged 4 commits into from
Jan 28, 2022

Conversation

sbak5
Copy link
Contributor

@sbak5 sbak5 commented Jan 27, 2022

Refined this test w/ reduced input shapes.
Instead, more essential test cases are included w/ empty, singleton arrays

tests/array_split.py Outdated Show resolved Hide resolved
tests/array_split.py Outdated Show resolved Hide resolved
# divisible integer
input_arr.append(even_div)
# indivisble integer
if even_div != uneven_div and uneven_div is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

the first condition seems very confusing. I believe even_div and uneven_div meant to be different, but why are you checking if they are different?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can both 1 if a.shape[axis] is prime.

Copy link
Contributor

Choose a reason for hiding this comment

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

ok then is there reason that you don't test with even_div == a.shape[axis] in that case? I feel this is another unnecessary complication in this test that is just confusing.

even_div = div
else:
uneven_div = div
if even_div is not None and uneven_div is not None:
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think I'm a big fan of this condition, as the values that would be chosen for even_div and uneven_div are somewhat unpredictable. I feel we're trying to be too smart here, as we won't really run this test with non-default test parameters.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I see. This tests take any size of matrix so the dimension could be prime or not, which I tried to handle that.
What do you mean by 'non-defualt' test parameters?

Copy link
Contributor

Choose a reason for hiding this comment

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

I mean, practically no one will try to run this unit test with the size overriden by the --dim_size flag. I'm saying the test is overly complicated for cases that would happen very rarely.

c = getattr(num, routine)(a, input_opt, axis)
is_equal = True
err_arr = [b, c]
for routine, input_opt in itertools.product(
Copy link
Contributor

Choose a reason for hiding this comment

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

again, what's the point of doing product if this test only tests array_split?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It used to have split w/ error checking codes to see if both cunumeric and numpy produces the same error for non-viable options. I'll delete this

err_arr = [b, c]
else:
for each in zip(b, c):
sub_set = list(each)
Copy link
Contributor

Choose a reason for hiding this comment

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

why do you need to create a fresh list here? isn't each already a tuple that you can access with index expression?

Copy link
Contributor

@magnatelee magnatelee left a comment

Choose a reason for hiding this comment

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

I only have one petty comment, looks good otherwise.

print_msg = f"np.{routine}({a.shape}, {input_opt}" f", {axis})"
# Check if both impls produce the error
# for non-viable options
b = getattr(np, routine)(a, input_opt, axis)
Copy link
Contributor

Choose a reason for hiding this comment

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

again, why can't you just call np.array_split here?

@magnatelee
Copy link
Contributor

Looks good to me.

@magnatelee magnatelee merged commit 5fc7532 into nv-legate:branch-22.01 Jan 28, 2022
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