Skip to content

Commit

Permalink
Fix deprecation warnings due to bytestring()
Browse files Browse the repository at this point in the history
Also improve a few docstrings and simplify code using @sprintf.
  • Loading branch information
nalimilan committed Jun 1, 2016
1 parent fa09067 commit af52e8f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 25 deletions.
11 changes: 5 additions & 6 deletions src/abstractdataframe/show.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,19 @@
#'
#' @param df::AbstractDataFrame The AbstractDataFrame to be summarized.
#'
#' @returns res::UTF8String The summary of `df`.
#' @returns res::String The summary of `df`.
#'
#' @examples
#'
#' summary(DataFrame(A = 1:10))
function Base.summary(df::AbstractDataFrame) # -> UTF8String
function Base.summary(df::AbstractDataFrame) # -> String
nrows, ncols = size(df)
return utf8(@sprintf("%d×%d %s", nrows, ncols, typeof(df)))
return @sprintf("%d×%d %s", nrows, ncols, typeof(df))
end

#' @description
#'
#' Determine the number of UTF8 characters that would be used to
#' render a value.
#' Determine the number of characters that would be used to print a value.
#'
#' @param x::Any A value whose string width will be computed.
#'
Expand Down Expand Up @@ -139,7 +138,7 @@ end
#' @description
#'
#' Given the maximum widths required to render each column of an
#' AbstractDataFrame, this returns the total number of UTF8 characters
#' AbstractDataFrame, this returns the total number of characters
#' that would be required to render an entire row to an IO system.
#'
#' NOTE: This width includes the whitespace and special characters used to
Expand Down
30 changes: 11 additions & 19 deletions src/dataframe/io.jl
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ function bytestotype{N <: AbstractString,
return "", true, true
end

return bytestring(bytes[left:right]), true, false
return String(bytes[left:right]), true, false
end

function builddf(rows::Integer,
Expand Down Expand Up @@ -560,12 +560,9 @@ function builddf(rows::Integer,
if wasparsed
continue
else
msgio = IOBuffer()
@printf(msgio,
"Failed to parse '%s' using type '%s'",
bytestring(p.bytes[left:right]),
o.eltypes[j])
error(bytestring(msgio))
error(@sprintf("Failed to parse '%s' using type '%s'",
String(p.bytes[left:right]),
o.eltypes[j]))
end
end

Expand Down Expand Up @@ -682,7 +679,7 @@ function parsenames!(names::Vector{Symbol},
end
end

name = bytestring(bytes[left:right])
name = String(bytes[left:right])
if normalizenames
name = identifier(name)
end
Expand Down Expand Up @@ -712,17 +709,12 @@ function findcorruption(rows::Integer,
m = median(lengths)
corruptrows = find(lengths .!= m)
l = corruptrows[1]
msgio = IOBuffer()
@printf(msgio,
"Saw %d rows, %d columns and %d fields\n",
rows,
cols,
fields)
@printf(msgio,
" * Line %d has %d columns\n",
l,
lengths[l] + 1)
error(bytestring(msgio))
error(@sprintf("Saw %d rows, %d columns and %d fields\n * Line %d has %d columns\n",
rows,
cols,
fields,
l,
lengths[l] + 1))
end

function readtable!(p::ParsedCSV,
Expand Down

0 comments on commit af52e8f

Please sign in to comment.