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

Add doctest for IdDict with example #38881

Merged
merged 3 commits into from
Dec 15, 2020
Merged

Conversation

miguelraz
Copy link
Contributor

This came up from a Slack discussion and was based on a surprising Python behavior.
@haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.

This came up from a Slack discussion and was based on a surprising [Python behavior](https://twitter.com/DahlitzF/status/1338384990040682498).
@haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.
base/iddict.jl Outdated
@@ -6,7 +6,23 @@
`IdDict{K,V}()` constructs a hash table using object-id as hash and
`===` as equality with keys of type `K` and values of type `V`.

See [`Dict`](@ref) for further help.
See [`Dict`](@ref) for further help. In the example below, The `Dict`
keys all hash to the same value as they are inserted and type-promoted,
Copy link
Member

Choose a reason for hiding this comment

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

There isn't really any type promotion going on here though, the values are all isequal and hash the same.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the catch. Should be fixed.

Copy link
Member

@StefanKarpinski StefanKarpinski left a comment

Choose a reason for hiding this comment

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

Perfect 👨🏻‍🍳😽

@StefanKarpinski StefanKarpinski merged commit bd0ddf3 into JuliaLang:master Dec 15, 2020
@miguelraz miguelraz deleted the patch-4 branch December 15, 2020 16:50
ElOceanografo pushed a commit to ElOceanografo/julia that referenced this pull request May 4, 2021
This came up from a Slack discussion and was based on a surprising [Python behavior](https://twitter.com/DahlitzF/status/1338384990040682498).
@haampie provided the example and I thought the docstrings could help out another beginner to understand why a different data structure is justified.
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