Skip to content

Commit

Permalink
removing namefix, letting user specify names
Browse files Browse the repository at this point in the history
  • Loading branch information
dysonance committed Dec 12, 2017
1 parent 3e3465d commit 95bbb42
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions src/ts.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ using Base.Dates
################################################################################
# TYPE DEFINITION ##############################################################
################################################################################
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
#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)))
#namefix(s::AbstractString)::AbstractString = s[findalphanum(s)]
#namefix(s::Symbol)::Symbol = Symbol(namefix(string(s)))

# abstract AbstractTS
#
Expand Down Expand Up @@ -53,7 +53,7 @@ mutable struct TS{V<:Real,T<:TimeType}
@assert size(values,1)==length(index) "Length of index not equal to number of value rows."
@assert size(values,2)==length(fields) "Length of fields not equal to number of columns in values."
order = sortperm(index)
return new(values[order,:], index[order], namefix.(fields))
return new(values[order,:], index[order], fields)
end
end

Expand Down

0 comments on commit 95bbb42

Please sign in to comment.