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

UnitWeights don't have values to return from dataids #808

Merged
merged 4 commits into from Jun 28, 2022

Conversation

rofinn
Copy link
Member

@rofinn rofinn commented Jun 23, 2022

Current fallback can cause errors like this:

  type UnitWeights has no field values
  Stacktrace:
    [1] getproperty(x::StatsBase.UnitWeights{Int64}, f::Symbol)
      @ Base ./Base.jl:33
    [2] dataids(wv::StatsBase.UnitWeights{Int64})
      @ StatsBase ~/.julia/packages/StatsBase/n494Y/src/weights.jl:26
    [3] dataids(A::SubArray{Int64, 1, StatsBase.UnitWeights{Int64}, Tuple{Vector{Int64}}, false})
    ```

@rofinn rofinn requested a review from nalimilan June 23, 2022 22:24
@rofinn rofinn self-assigned this Jun 24, 2022
@nalimilan
Copy link
Member

Thanks! UnitWeights is indeed always special. Could you add a test?

@rofinn
Copy link
Member Author

rofinn commented Jun 26, 2022

The issue is that it’s hard to reproduce the convert path without making a bunch of assumptions about Julia’s type inference. I could add an explicit test, but that doesn’t seem very useful?

@nalimilan
Copy link
Member

A basic test is better than nothing. Anyway we shouldn't add lines that are not covered by tests, to ensure that at least they run without errors.

You could also call Base.mightalias (as I did at #793), as IIRC it calls Base.dataids.

Copy link
Member

@nalimilan nalimilan left a comment

Choose a reason for hiding this comment

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

Can you tag a new release?

@rofinn rofinn merged commit db4e40e into master Jun 28, 2022
@rofinn rofinn deleted the rf/nodataids-unitweights branch June 28, 2022 15:21
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.

None yet

2 participants