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

[REVIEW] Explicit dictionary constructor #5832

Merged
merged 5 commits into from
Aug 3, 2020

Conversation

bdice
Copy link
Contributor

@bdice bdice commented Aug 3, 2020

This PR makes the dictionary32 constructor from an int32 explicit. An implicit constructor here defeats the purpose of being a strongly typed wrapper.

This is a dependency of #5494.

The underlying issue this solves is similar to a change made in #5735, where timestamps could be constructed from a duration type's representation. Quoting from discussion with @jrhemstad:

The exact mechanism that caused this operator* problem is this:
Boiling away the cruft, the operator* definition looks like this:

template <class T, class Period, class Rep>
enable_if_t
<
    is_convertible<T, common_type_t<T, Rep>::type>::value,
    duration<common_type_t<T, Rep>::type, Period>
>
operator*(const T& s, const duration<Rep, Period>& d);

So this allows multiplication between a duration type and any type T so long as T is convertible to the common type between T and the duration's representation Rep. "common_type" is defined as "For a list of types, what type are they all implicitly convertible to?" e.g., common_type_t<int, short, char> == int
So for example, std::chrono::days::Rep == int32_t.
If T == timestamp_D, then it first checks "What is the common type between timestamp_D and int32_t?". Well, because int32_t is implicitly convertible to timestamp_D (thanks to that constructor) then common_type_t<timestamp_D, int32_t> == timestamp_D. So then we end up with is_convertible<timestamp_D, timestamp_D>, and that is true because a type is always convertible to itself.
Therefore, the type substitution for operator* passes, even though the actual instantiation of operator*(timestamp_D, duration<...>) is ill-formed.

In this case, the implicit constructor of a dictionary32 from an int32 meant that it met the criteria for the overload of operator* with a duration, which isn't desired.

Aside from the change to the constructor, this only affected one place that relied on the implicit constructor.

@bdice bdice requested a review from a team as a code owner August 3, 2020 15:07
@bdice bdice self-assigned this Aug 3, 2020
@GPUtester
Copy link
Collaborator

Please update the changelog in order to start CI tests.

View the gpuCI docs here.

@bdice bdice added the 3 - Ready for Review Ready for review by team label Aug 3, 2020
@bdice bdice changed the title Explicit dictionary constructor [REVIEW] Explicit dictionary constructor Aug 3, 2020
@codecov
Copy link

codecov bot commented Aug 3, 2020

Codecov Report

Merging #5832 into branch-0.15 will increase coverage by 0.32%.
The diff coverage is n/a.

Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.15    #5832      +/-   ##
===============================================
+ Coverage        84.08%   84.40%   +0.32%     
===============================================
  Files               80       80              
  Lines            13061    13381     +320     
===============================================
+ Hits             10982    11294     +312     
- Misses            2079     2087       +8     
Impacted Files Coverage Δ
python/cudf/cudf/io/feather.py 100.00% <0.00%> (ø)
python/cudf/cudf/comm/serialize.py 0.00% <0.00%> (ø)
python/custreamz/custreamz/_version.py 0.00% <0.00%> (ø)
python/dask_cudf/dask_cudf/_version.py 0.00% <0.00%> (ø)
python/dask_cudf/dask_cudf/io/tests/test_orc.py 100.00% <0.00%> (ø)
python/dask_cudf/dask_cudf/io/tests/test_json.py 100.00% <0.00%> (ø)
...ython/dask_cudf/dask_cudf/io/tests/test_parquet.py 100.00% <0.00%> (ø)
python/cudf/cudf/utils/applyutils.py 98.75% <0.00%> (+0.02%) ⬆️
python/cudf/cudf/core/join/join.py 92.41% <0.00%> (+0.03%) ⬆️
...ython/custreamz/custreamz/tests/test_dataframes.py 98.80% <0.00%> (+0.03%) ⬆️
... and 29 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 f252a93...9344cc4. Read the comment docs.

@bdice bdice added 5 - Ready to Merge Testing and reviews complete, ready to merge and removed 3 - Ready for Review Ready for review by team labels Aug 3, 2020
@bdice bdice merged commit bc6b1f5 into rapidsai:branch-0.15 Aug 3, 2020
@bdice bdice deleted the explicit-dictionary-constructor branch August 3, 2020 21:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
5 - Ready to Merge Testing and reviews complete, ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants