Skip to content

Commit

Permalink
More julia 0.7 cleanup. Restore functionality of Unitful.DefaultSymbols.
Browse files Browse the repository at this point in the history
  • Loading branch information
ajkeller34 committed Jul 2, 2018
1 parent ca1140b commit 12c5690
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 37 deletions.
12 changes: 6 additions & 6 deletions src/pkgdefaults.jl
Original file line number Diff line number Diff line change
Expand Up @@ -243,19 +243,19 @@ baremodule DefaultSymbols
import Unitful

for u in (:𝐋,:𝐌,:𝐓,:𝐈,:𝚯,:𝐉,:𝐍)
eval(DefaultSymbols, Expr(:import, :Unitful, u))
eval(DefaultSymbols, Expr(:export, u))
Core.eval(DefaultSymbols, Expr(:import, Expr(:(.), :Unitful, u)))
Core.eval(DefaultSymbols, Expr(:export, u))
end

for p in Unitful.si_prefixes
for u in Unitful.si_no_prefix
eval(DefaultSymbols, Expr(:import, :Unitful, Symbol(p,u)))
eval(DefaultSymbols, Expr(:export, Symbol(p,u)))
Core.eval(DefaultSymbols, Expr(:import, Expr(:(.), :Unitful, Symbol(p,u))))
Core.eval(DefaultSymbols, Expr(:export, Symbol(p,u)))
end
end

eval(DefaultSymbols, Expr(:import, :Unitful, ))
eval(DefaultSymbols, Expr(:export, ))
Core.eval(DefaultSymbols, Expr(:import, Expr(:(.), :Unitful, )))
Core.eval(DefaultSymbols, Expr(:export, ))
end

#########
Expand Down
44 changes: 13 additions & 31 deletions src/units.jl
Original file line number Diff line number Diff line change
Expand Up @@ -22,39 +22,21 @@
# Collect powers of a given unit into `c`
c = Vector{Unit}()
if !isempty(linunits)
@static if VERSION >= v"0.7.0-DEV.5124"
next = iterate(linunits)
p = 0//1
oldvalue = next[1]
while next !== nothing
(value, state) = next
if tens(value) == tens(oldvalue) && name(value) == name(oldvalue)
p += power(value)
else
if p != 0
push!(c, Unit{name(oldvalue), dimtype(oldvalue)}(tens(oldvalue), p))
end
p = power(value)
next = iterate(linunits)
p = 0//1
oldvalue = next[1]
while next !== nothing
(value, state) = next
if tens(value) == tens(oldvalue) && name(value) == name(oldvalue)
p += power(value)
else
if p != 0
push!(c, Unit{name(oldvalue), dimtype(oldvalue)}(tens(oldvalue), p))
end
oldvalue = value
next = iterate(linunits, state)
end
else
state = start(linunits)
oldvalue = linunits[state]
p = 0//1
while !done(linunits, state)
(value, state) = next(linunits, state)
if tens(value) == tens(oldvalue) && name(value) == name(oldvalue)
p += power(value)
else
if p != 0
push!(c, Unit{name(oldvalue),dimtype(oldvalue)}(tens(oldvalue), p))
end
p = power(value)
end
oldvalue = value
p = power(value)
end
oldvalue = value
next = iterate(linunits, state)
end
if p != 0
push!(c, Unit{name(oldvalue),dimtype(oldvalue)}(tens(oldvalue), p))
Expand Down

0 comments on commit 12c5690

Please sign in to comment.