Skip to content

Commit

Permalink
Merge pull request #103 from ajkeller34/logunits
Browse files Browse the repository at this point in the history
Implement logarithmic quantities
  • Loading branch information
ajkeller34 authored Oct 23, 2017
2 parents dac5a44 + bc142d2 commit 3a86b33
Show file tree
Hide file tree
Showing 23 changed files with 2,690 additions and 1,083 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
language: julia
os:
- linux
- osx
# - osx # locally test on my MacBook Pro; OS X tests take too long on Travis CI
julia:
- 0.6
- nightly
Expand All @@ -19,6 +19,6 @@ after_success:
# push coverage results to Coveralls
- julia -e 'cd(Pkg.dir("Unitful")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
# push coverage results to Codecov
- julia -e 'cd(Pkg.dir("Unitful")); Pkg.add("Coverage"); using Coverage; Codecov.submit(process_folder())'
- julia -e 'cd(Pkg.dir("Unitful")); using Coverage; Codecov.submit(process_folder())'
- julia -e 'Pkg.add("Documenter")'
- julia -e 'cd(Pkg.dir("Unitful")); include(joinpath("docs", "make.jl"))'
11 changes: 11 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
- v0.4.0
- Introduce logarithmic quantities.
- Update syntax for Julia 0.6 and reorganize code for clarity.
- Redefine `ustrip(x::Quantity) = ustrip(x.val)`. In most cases, this is unlikely to
affect user code. The generic fallback `ustrip(x::Number)` remains unchanged.
- `isapprox(1.0u"m",5)` returns `false` instead of throwing a `DimensionError`,
in keeping with the behavior of an equality check (`==`).
- Deprecated `dimension(x::AbstractArray{T}) where T<:Number`, use broadcasting instead.
- Deprecated `dimension(x::AbstractArray{T}) where T<:Units`, use broadcasting instead.
- Deprecated `ustrip(A::AbstractArray{T}) where T<:Number`, use broadcasting instead.
- Deprecated `ustrip(A::AbstractArray{T}) where T<:Quantity`, use broadcasting instead.
- v0.3.0
- Require Julia 0.6
- Adds overloads for `rand` and `ones` [#96](https://github.com/ajkeller34/Unitful.jl/issues/96).
Expand Down
2 changes: 1 addition & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ makedocs()

deploydocs(
deps = Deps.pip("mkdocs", "mkdocs-material", "python-markdown-math"),
julia = "nightly",
julia = "0.6",
osname = "linux",
repo = "github.com/ajkeller34/Unitful.jl.git"
)
5 changes: 3 additions & 2 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
site_name: Unitful.jl
repo_url: https://github.com/ajkeller34/Unitful.jl
site_description: Package for units.
site_author: Andrew Keller
site_description: Performant and expressive calculations with arbitrary units.
site_author: Andrew J. Keller

theme: material
extra:
Expand Down Expand Up @@ -33,6 +33,7 @@ pages:
- Conversion / promotion: conversion.md
- Manipulating units: manipulations.md
- How units are displayed: display.md
- Logarithmic scales: logarithm.md
- Extending Unitful: extending.md
- Troubleshooting: trouble.md
- License: LICENSE.md
29 changes: 18 additions & 11 deletions docs/src/highlights.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,21 +9,21 @@ end
Consider the following toy example, converting from voltage or power ratios to decibels:

```jldoctest
julia> dB(num::Unitful.Voltage, den::Unitful.Voltage) = 20*log10(num/den)
dB (generic function with 1 method)
julia> whatsit(x::Unitful.Voltage) = "voltage!"
whatsit (generic function with 1 method)
julia> dB(num::Unitful.Power, den::Unitful.Power) = 10*log10(num/den)
dB (generic function with 2 methods)
julia> whatsit(x::Unitful.Length) = "length!"
whatsit (generic function with 2 methods)
julia> dB(1u"mV", 1u"V")
-60.0
julia> whatsit(1u"mm")
"length!"
julia> dB(1u"mW", 1u"W")
-30.0
```
julia> whatsit(1u"kV")
"voltage!"
We don't currently implement dB as a unit because the log scale would require
special treatment, but it is under consideration.
julia> whatsit(1u"A" * 2.5u"Ω")
"voltage!"
```

### Dimensions in a type definition

Expand Down Expand Up @@ -79,6 +79,13 @@ julia> Diagonal([-1.0u"c^2", 1.0, 1.0, 1.0])
⋅ ⋅ ⋅ 1.0
```

## Logarithmic units

```jldoctest
julia> uconvert(u"mW*s", 20u"dBm/Hz")
100.0 s mW
```

## Units with rational exponents

```jldoctest
Expand Down
12 changes: 2 additions & 10 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,11 @@ We want to support not only SI units but also any other unit system. We also
want to minimize or in some cases eliminate the run-time penalty of units.
There should be facilities for dimensional analysis. All of this should
integrate easily with the usual mathematical operations and collections
that are found in Julia base.

!!! note
If you have been previously using Unitful 0.0.4 or earlier, the defaults
mechanism has been completely rewritten. This means you will now need to
define new units in your `.juliarc.jl` file or in a new module. See
[Defining new units](@ref) and [Extending Unitful](@ref) for details.
Additionally, to specify custom rules for promotion, see
[Basic promotion mechanisms](@ref) and [Advanced promotion mechanisms](@ref).
that are defined in Julia.

## Quick start

- This package requires Julia 0.5. Older versions will not be supported.
- This package requires Julia 0.6. Older versions will not be supported.
- `Pkg.add("Unitful")`
- `using Unitful`

Expand Down
Loading

0 comments on commit 3a86b33

Please sign in to comment.