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

Some issue with similar #32

Closed
davidanthoff opened this issue Nov 20, 2017 · 2 comments
Closed

Some issue with similar #32

davidanthoff opened this issue Nov 20, 2017 · 2 comments
Labels

Comments

@davidanthoff
Copy link
Member

@JeffBezanson reports this over at JuliaData/Missings.jl#6 (comment):

It works pretty well, but I ran into the issue recently that similar(a::DataValueArray, Any) does not return an array that can hold any value, which prevents Base map and collect from working.

@JeffBezanson: do you have a little more info what you were trying to do?

The following seems to work:

using DataValues

x = DataValueArray([1,2,NA])

y = similar(x, Any)
y[1]="asdf"
y[2]=3.5

The type of y is DataValues.DataValueArray{Any,1}, and now that I think about it, maybe it should just be Array{Any,1}, right? But things shouldn't break, regardless of that specific choice.

@JeffBezanson
Copy link

The problem is that the eltype of similar(a::DataValueArray, Any) is not Any but DataValue{Any}, so the logic in e.g. map copies the array on every iteration thinking the type is not wide enough yet.

@davidanthoff
Copy link
Member Author

Yeah, that is just a bug. #33 changes this so that similar only returns a DataValueArray when you pass DataValue as the desired element type. That seems more sensible. I just hope I'm not introducing some method ambiguity with this new definition... They always make me nervous. If you spot some problem there, please let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants