Skip to content

Commit

Permalink
Merge pull request #16 from dysonance/issue_13
Browse files Browse the repository at this point in the history
Issue 13
  • Loading branch information
dysonance authored Dec 2, 2017
2 parents b993ef4 + a91b4ff commit 9489be6
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/ts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ using Base.Dates
################################################################################
# TYPE DEFINITION ##############################################################
################################################################################
findalphanum(s::AbstractString)::Vector{Int} = union(find(isalpha,s), find(isnumber,s))
function findalphanum(s::AbstractString, drop_underscores::Bool=false)::Vector{Int}
if drop_underscores
return sort(union(find(isalpha,s), find(isnumber,s)))
else
return sort(union(union(find(isalpha,s), find(isnumber,s)), find(c->c=='_', s)))
end
end
# findalphanum(s::String)::Vector{Int} = find(isalpha.(split(s,"")).+isnumber.(split(s,"")))
namefix(s::AbstractString)::AbstractString = s[findalphanum(s)]
namefix(s::Symbol)::Symbol = Symbol(namefix(string(s)))
Expand Down
3 changes: 3 additions & 0 deletions test/basic.jl
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ using Base.Test, Base.Dates, Temporal
@test TS(X.values[:,1], X.index, "A") == X[:,1]
@test TS(X.values[1,:]', X.index[1], X.fields) == X[1]
@test size(TS()) == (0,0)
# underscores in colnames (issue 13)
u = TS(rand(N), X.index, "under_score")
@test u.fields[1] == :under_score
show(STDOUT, TS(rand(252,4)))
print("\n")
end
Expand Down

0 comments on commit 9489be6

Please sign in to comment.