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

port to Julia 0.7 #182

Merged
merged 12 commits into from
Sep 24, 2018
Merged
Prev Previous commit
Next Next commit
fix warnings from using IndexedTables
  • Loading branch information
joshday committed Aug 23, 2018
commit f9bd8393e15420dff576a25137a131dfb93a465a
8 changes: 3 additions & 5 deletions src/ndsparse.jl
Original file line number Diff line number Diff line change
@@ -261,14 +261,14 @@ julia> pkeynames(x)

```
"""
pkeynames(t::NDSparse) = (dimlabels(t)...)
pkeynames(t::NDSparse) = (dimlabels(t)...,)

# For an NDSparse, valuenames is either a tuple of fieldnames or a
# single name for scalar values
function valuenames(t::NDSparse)
if isa(values(t), Columns)
T = eltype(values(t))
((ndims(t) + (1:fieldcount(eltype(values(t)))))...)
((ndims(t) + (1:fieldcount(eltype(values(t)))))...,)
else
ndims(t) + 1
end
@@ -400,8 +400,6 @@ function show(io::IO, t::NDSparse{T,D}) where {T,D}
cnames=cnames, divider=length(columns(keys(t))))
end

import Base: @md_str

function showmeta(io, t::NDSparse, cnames)
nc = length(columns(t))
nidx = length(columns(keys(t)))
@@ -513,7 +511,7 @@ end

# NDSparse uses lex order, Base arrays use colex order, so we need to
# reorder the data. transpose and permutedims are used for this.
convert(::Type{NDSparse}, m::SparseMatrixCSC) = NDSparse(findnz(m.')[[2,1,3]]..., presorted=true)
convert(::Type{NDSparse}, m::SparseMatrixCSC) = NDSparse(findnz(transpose(m))[[2,1,3]]..., presorted=true)

# special method to allow selection on
# ndsparse with repeating names in keys and values
6 changes: 3 additions & 3 deletions src/selection.jl
Original file line number Diff line number Diff line change
@@ -271,7 +271,7 @@ function map(f, t::Dataset; select=nothing, copy=false, kwargs...)
isa(x, Columns) ? table(x; copy=false, kwargs...) : x
end

function _nonna(t::Union{Columns, NextTable}, by=(colnames(t)...))
function _nonna(t::Union{Columns, NextTable}, by=(colnames(t)...,))
indxs = [1:length(t);]
if !isa(by, Tuple)
by = (by,)
@@ -340,8 +340,8 @@ julia> typeof(column(dropna(t,:x), :x))
Array{Int64,1}
```
"""
function dropna(t::Dataset, by=(colnames(t)...))
subtable(_nonna(t, by)...)
function dropna(t::Dataset, by=(colnames(t)...,))
subtable(_nonna(t, by)...,)
end

filt_by_col!(f, col, indxs) = filter!(i->f(col[i]), indxs)
14 changes: 7 additions & 7 deletions src/table.jl
Original file line number Diff line number Diff line change
@@ -198,7 +198,7 @@ function table(::Val{:serial}, cols::Tup;
end

if !presorted && !isempty(pkey)
pkeys = rows(cs, (pkey...))
pkeys = rows(cs, (pkey...,))
if !issorted(pkeys)
perm = sortperm(pkeys)
if copy
@@ -372,7 +372,7 @@ function primaryperm(t::NextTable)
Perm(t.pkey, Base.OneTo(length(t)))
end

permcache(t::NextTable) = [primaryperm(t), t.perms;]
permcache(t::NextTable) = vcat(primaryperm(t), t.perms)
cacheperm!(t::NextTable, p) = push!(t.perms, p)

"""
@@ -405,14 +405,14 @@ julia> pkeys(t)
"""
function pkeynames(t::AbstractIndexedTable)
if eltype(t) <: NamedTuple
(colnames(t)[t.pkey]...)
(colnames(t)[t.pkey]...,)
else
(t.pkey...)
(t.pkey...,)
end
end

# for a table, selecting the "value" means selecting all fields
valuenames(t::AbstractIndexedTable) = (colnames(t)...)
valuenames(t::AbstractIndexedTable) = (colnames(t)...,)

"""
pkeys(itr::Table)
@@ -560,7 +560,7 @@ function excludecols(t, cols)
mask[i] = false
end
end
((1:length(ns))[mask]...)
((1:length(ns))[mask]...,)
end

"""
@@ -588,7 +588,7 @@ end
convert(T::Type{NextTable}, c::Columns{<:Pair}; kwargs...) = convert(T, c.columns.first, c.columns.second; kwargs...)
# showing

import Base.Markdown.with_output_format
# import Base.Markdown.with_output_format

global show_compact_when_wide = true
function set_show_compact!(flag=true)