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

Handle constructing a cudf.Scalar from a cudf.Scalar #7639

Merged
merged 5 commits into from
Mar 19, 2021

Conversation

shwina
Copy link
Contributor

@shwina shwina commented Mar 18, 2021

...also fix DeviceScalar.__repr__ to print "DeviceScalar" instead of "Scalar".

@shwina shwina requested a review from a team as a code owner March 18, 2021 19:07
@github-actions github-actions bot added the Python Affects Python cuDF API. label Mar 18, 2021
python/cudf/cudf/tests/test_scalar.py Outdated Show resolved Hide resolved
assert x.value == y.value

# check that this works:
y.device_value
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we test that the synchronization state of the result is the same as the original?

x._is_host_value_current == y._is_host_value_current
x._is_device_value_current == y._is_device_value_current

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'd be -1 to testing internals like this since they are implementation details that can easily change. But it looks like we're doing it already in these tests. It's your call: I'm happy to add it on

Copy link
Contributor

Choose a reason for hiding this comment

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

One can argue that we should have tests that test only API functionality - just checking that the results of calling our methods and functions are what we expect them to be.

Then there's things that we actually want to work a certain way under the hood, that can easily do something unexpected or unwanted when subject to changes - I'd argue we want to test that too. It's just that in lieu of doing it here, I am not sure where else to put them.

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 definitely see your point, and have added the test as asked.

I think in this specific case, the only external/user-facing behaviour is performance, where ideally that would be captured in a benchmark rather than a test.

The problem with testing internals/optimizations is that when we do decide to change implementation details, we have to delete tests. At that point, there may be difficult-to-answer questions like:

  • should we replace the tests we are deleting with new tests?
  • will deleting these tests now cause some user-facing behaviour to be untested?
  • who can decide?

Copy link
Contributor

@brandon-b-miller brandon-b-miller left a comment

Choose a reason for hiding this comment

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

Changes look good. Is there any reason we should make a copy?

@shwina
Copy link
Contributor Author

shwina commented Mar 18, 2021

Changes look good. Is there any reason we should make a copy?

To be clear, are you asking if we are currently making a copy? Or if we should consider making a copy? I think the current behaviour is not making a copy of the underlying (device) value.

@brandon-b-miller
Copy link
Contributor

Changes look good. Is there any reason we should make a copy?

To be clear, are you asking if we are currently making a copy? Or if we should consider making a copy? I think the current behaviour is not making a copy of the underlying (device) value.

To clarify - the current implementation does not make a copy - I am wondering if there's any reason it should make a copy. I would rather it be as it currently is and don't see why we would want to change it. More asking if anyone can think of any reason I am not seeing.

@shwina
Copy link
Contributor Author

shwina commented Mar 18, 2021

More asking if anyone can think of any reason I am not seeing.

Got it. Yeah, good point. Given that DeviceScalar is immutable (and so are the host scalar types, I think?), we should be OK not creating a copy here.

@shwina shwina added non-breaking Non-breaking change improvement Improvement / enhancement to an existing function labels Mar 18, 2021
@codecov
Copy link

codecov bot commented Mar 18, 2021

Codecov Report

Merging #7639 (a5fe670) into branch-0.19 (7871e7a) will increase coverage by 0.60%.
The diff coverage is 93.04%.

❗ Current head a5fe670 differs from pull request most recent head 777a09b. Consider uploading reports for the commit 777a09b to get more accurate results
Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.19    #7639      +/-   ##
===============================================
+ Coverage        81.86%   82.47%   +0.60%     
===============================================
  Files              101      101              
  Lines            16884    17399     +515     
===============================================
+ Hits             13822    14349     +527     
+ Misses            3062     3050      -12     
Impacted Files Coverage Δ
python/cudf/cudf/core/index.py 93.45% <ø> (+0.59%) ⬆️
python/cudf/cudf/core/series.py 91.69% <ø> (+0.90%) ⬆️
python/cudf/cudf/core/tools/datetimes.py 84.53% <ø> (+0.08%) ⬆️
python/cudf/cudf/utils/cudautils.py 52.94% <ø> (+2.55%) ⬆️
python/cudf/cudf/utils/dtypes.py 89.88% <ø> (+0.37%) ⬆️
python/dask_cudf/dask_cudf/io/orc.py 91.04% <ø> (+0.13%) ⬆️
python/cudf/cudf/core/scalar.py 87.24% <85.71%> (+0.14%) ⬆️
python/cudf/cudf/core/column/numerical.py 94.83% <87.50%> (-0.20%) ⬇️
python/cudf/cudf/core/column/column.py 87.86% <90.00%> (+0.10%) ⬆️
python/cudf/cudf/core/column/decimal.py 92.75% <90.32%> (-2.12%) ⬇️
... and 62 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 34cccfe...777a09b. Read the comment docs.

@kkraus14
Copy link
Collaborator

@gpucibot merge

@rapids-bot rapids-bot bot merged commit c13351d into rapidsai:branch-0.19 Mar 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
improvement Improvement / enhancement to an existing function non-breaking Non-breaking change Python Affects Python cuDF API.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants