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

Print dpnp array #1279

Merged
merged 6 commits into from
Feb 13, 2023
Merged

Print dpnp array #1279

merged 6 commits into from
Feb 13, 2023

Conversation

vtavana
Copy link
Collaborator

@vtavana vtavana commented Jan 27, 2023

Adding string representation of the array object using __str__ and __repr__

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • If this PR is a work in progress, are you filing the PR as a draft?

dpnp/dpnp_array.py Show resolved Hide resolved
dpnp/dpnp_array.py Outdated Show resolved Hide resolved
dpnp/dpnp_array.py Outdated Show resolved Hide resolved
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Please add tests to test-suite that exercise array printing functionality.

@vtavana vtavana force-pushed the print_dpnp_array branch 2 times, most recently from 5040914 to d74d96a Compare February 2, 2023 17:03
tests/test_dparray.py Outdated Show resolved Hide resolved
result = str(dpnp.array([[1, 2], [3, 4]]))
expected = "[[1 2]\n [3 4]]"
assert(result==expected)

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably to add also a test case with ... in the string output.

@oleksandr-pavlyk
Copy link
Contributor

@vtavana Could you please install/build dpctl from sources of IntelPython/dpctl#1060 and change your

def __repr__(self):
    return dpt.usm_ndarray_repr(self._array_obj, prefix="ndarray")

Adjust the prefix value as needed.

@antonwolfy, @samaid, @npolina4 Should we choose "ndarray", "dpnp_ndarray", or "dpnp_array"?

@oleksandr-pavlyk oleksandr-pavlyk self-requested a review February 8, 2023 22:56
Copy link
Contributor

@oleksandr-pavlyk oleksandr-pavlyk left a comment

Choose a reason for hiding this comment

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

Looks good to me! Thank you @vtavana

@oleksandr-pavlyk oleksandr-pavlyk merged commit 0f7420e into master Feb 13, 2023
@oleksandr-pavlyk oleksandr-pavlyk deleted the print_dpnp_array branch February 13, 2023 16:26
@vtavana vtavana self-assigned this Apr 25, 2023
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