Skip to content
This repository has been archived by the owner on May 4, 2019. It is now read-only.

Fixes for 0.6 #235

Merged
merged 14 commits into from
Feb 17, 2017
Merged

Fixes for 0.6 #235

merged 14 commits into from
Feb 17, 2017

Conversation

andreasnoack
Copy link
Member

The main parts are the fixes for the broadcasting and indexing which both were broken on Julia master. There are many fixes of deprecated syntax and I've changed some uses of the old ngenerate in favor of generated functions. I've decided to remove support for Julia version prior to 0.6 to make the source as simple as possible. The package has been undermaintained for a while so I think we should focus on making maintenance as easy as possible. Prior version fo Julia can just use old versions of this package.

@mbauman It would be appreciated if you could take a look at the indexing code. In particular, if it is really necessary with @generated in methods like https://github.com/JuliaStats/DataArrays.jl/blob/anj/06/src/indexing.jl#L164-L172 that used to be @ngenerated.

@simonster You wrote most of the code touched here so any comments from you would also be appreciated.

Rewrite broadcast as generated function to avoid world age problems.
Use some of the broadcast functionality in Base.

Update getindex and setindex to Base changes. Use generated functions
instead of @nsplat. Use some of the Base machinery for getindex

Fix many syntax deprecations
@andreasnoack
Copy link
Member Author

Oh, and I can see that my build of Julia has become obsolete while finishing the PR.

@@ -1,14 +1,14 @@
__precompile__()
__precompile__(false)
Copy link
Member

Choose a reason for hiding this comment

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

What's keeping from being able to precompile?

src/broadcast.jl Outdated
$(Symbol("pool_$(k)")) = $(Symbol("A_$(k)")).pool
end : nothing
for k = 1:narrays]...))
Base.map!{F}(f::F, B::Union{DataArray, PooledDataArray}, A0::AbstractArray, As::AbstractArray...) =
Copy link
Member

Choose a reason for hiding this comment

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

Is the typevar necessary here?

Copy link
Member

Choose a reason for hiding this comment

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

yes, otherwise it won't specialize on the function

Copy link
Member

Choose a reason for hiding this comment

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

Are you sure? I thought that was changed in Base a while back.

Copy link
Member

@simonster simonster Feb 12, 2017

Choose a reason for hiding this comment

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

It's always possible I'm wrong 😃. But this is the situation described in JuliaLang/julia#19137, and there's no indication the behavior has changed there.

Copy link
Member

Choose a reason for hiding this comment

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

Ah, hmm. My bad then.

Copy link
Member

Choose a reason for hiding this comment

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

AFAIK, without the ::F, specialization will only happen if you call the function.

src/indexing.jl Outdated
else
return pda.pool[getindex(pda.refs, I...)]

@generated function Base.getindex(pda::PooledDataArray, I::Integer...)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would just @inline this and the following.

:(Base.lgamma),
:(Base.digamma),
:(Base.erf),
:(Base.erfc)]
Copy link
Member

Choose a reason for hiding this comment

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

No longer in Base (same with erf and digamma)

Add SpecialFunctions as dependency

Use new type keywords
@andreasnoack
Copy link
Member Author

Thanks for the comments. I've updated the code accordingly. The latest changes on master haven't made it into the Julia binary yet so we'll have to restart the tests when new binaries have been uploaded.

src/indexing.jl Outdated
@@ -114,6 +114,8 @@ Base.getindex(t::AbstractDataArray, i::Real) =

## getindex: DataArray

Base.linearindexing(x::Union{DataArray,PooledDataArray}) = Base.LinearFast()
Copy link
Contributor

Choose a reason for hiding this comment

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

This should be defined on the ::Type{<:Union{DataArray,PooledDataArray}}, IIRC.

@ararslan
Copy link
Member

All of the remaining depwarns are from other packages. Does anything else need to happen here before this can be merged? LGTM.

@andreasnoack
Copy link
Member Author

I think it is ready.

@ararslan
Copy link
Member

Awesome. Unless there are further comments, I say we should merge this soon.

@@ -1,14 +1,14 @@
__precompile__()

module DataArrays
using Base: promote_op
using Base.Cartesian, Compat, Reexport
Copy link
Member

Choose a reason for hiding this comment

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

Since Compat was removed from REQUIRE, it should be removed here too. (Not sure how this didn't cause CI to fail...)

Copy link
Member Author

Choose a reason for hiding this comment

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

True. I think it is installed by the dependencies.

Copy link
Member

Choose a reason for hiding this comment

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

Ah yeah, probably installed by StatsBase.

using Base.Cartesian, Compat, Reexport
import Compat.String
@reexport using StatsBase
Copy link
Member

Choose a reason for hiding this comment

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

This is tangential to the current changes, but it would make sense to me to stop reexporting StatsBase from this package. I'm not sure why we do it currently. If we do stop doing that, we could also drop the dependency on Reexport (not that it's a huge or problematic dependency, just saying).

@@ -20,7 +20,7 @@ rb = 1:5
@test broadcast!(+, DataArray(Int, 2, 2), [1, 0], [1 4]) == [2 5; 1 4]
@test broadcast!(+, DataArray(Int, 2), [1, 0], [1, 4]) == [2, 4]
@test broadcast!(+, DataArray(Int, 2), [1, 0], 2) == [3, 2]
@test broadcast!(abs, @data([-1, -2])) == @data([1, 2])
# @test broadcast!(abs, @data([-1, -2])) == @data([1, 2])
Copy link
Member

Choose a reason for hiding this comment

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

Why is this commented out? Should it be removed altogether?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. It should be removed. The in-place broadcast! is deprecated in Base.

@andreasnoack
Copy link
Member Author

I've added Compat back. We need it for the @nsplat and @ngenerate macros. Eventually, we should just use @generated but I'll prefer to make that change in a separate PR.

Tests are failing because of a problem with the Julia binaries. I suggest that we just wait and see if tomorrow's binaries are more up to date.

@@ -109,7 +109,7 @@ macro test_da_approx_eq(da1, da2)
v2 = $(esc(da2))
na = isna(v1)
@test na == isna(v2)
defined = !na
defined = (!).(na)
Copy link
Member

Choose a reason for hiding this comment

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

.!na should work here as you've written it elsewhere, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope. Apparently, this form is required in macros. I tried the other version first.

Copy link
Member

Choose a reason for hiding this comment

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

That's... bizarre. Maybe file a Base issue?

@@ -14,24 +14,28 @@
##
##############################################################################

type NAtype
struct NAtype
Copy link
Member

Choose a reason for hiding this comment

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

ERROR: LoadError: LoadError: syntax: extra token "NAtype" after end of expression
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:539
 [2] include(::String) at ./sysimg.jl:14
 [3] include_from_node1(::String) at ./loading.jl:539
 [4] include(::String) at ./sysimg.jl:14
 [5] anonymous at ./<missing>:2
while loading /home/travis/.julia/v0.6/DataArrays/src/natype.jl, in expression starting on line 17

??????

Copy link
Member Author

Choose a reason for hiding this comment

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

For some reason, the nightly build used an older commit than the previous one and therefore it doesn't include the struct changes. We can restart again when new binaries are up.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like this is still happening with the nightly binaries. 😕

Copy link
Member Author

Choose a reason for hiding this comment

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

See https://status.julialang.org/. They are old. There is a problem on master that prevents the buildbot from making new ones.

src/broadcast.jl Outdated
$(Expr(:block, [
:(@inbounds $(Symbol("v_$(k)")) = @nref $nd $(Symbol("A_$(k)")) d->$(Symbol("j_$(k)_d")))
for k = find(t -> !(t <: DataArray || t <: PooledDataArray), As)]...))
As[k] <: AbstractArray && !(As[k] <: Union{DataArray, PooledDataArray}) ? quote
Copy link
Member

Choose a reason for hiding this comment

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

I think you could do AbstractDataArray instead of the Union there.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good point

@andreasnoack
Copy link
Member Author

I'll suggest that I test this one locally against latest Julia master and merge if the tests pass since we don't know when we'll have new nightlies for Travis testing.

@ararslan
Copy link
Member

Sounds like a good plan to me!

@andreasnoack andreasnoack merged commit 2a83487 into master Feb 17, 2017
@andreasnoack andreasnoack deleted the anj/06 branch February 17, 2017 22:31
@ararslan
Copy link
Member

Thanks so much for your hard work here, Andreas!

@nalimilan
Copy link
Member

The use of struct makes the tests fail. Better use the old type declaration syntax for now.

@ararslan
Copy link
Member

It makes the tests fail because for some reason the nightly binaries are stuck at a commit before the Base change due to issues with the buildbots. Hopefully that should be fixed soon.

@nalimilan
Copy link
Member

OK. But I guess it won't fix the tests on Julia 0.5, will it?

@ararslan
Copy link
Member

Andreas bumped the minimum requirement for the package to 0.6-, so it won't work on 0.5 anyway.

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

Successfully merging this pull request may close these issues.

5 participants