Skip to content

Commit 94e99d3

Browse files
Merge branch 'master' into sk/strings
2 parents f57d831 + a8054ed commit 94e99d3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

72 files changed

+3430
-1411
lines changed

.travis.yml

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ matrix:
1111
sources:
1212
- ubuntu-toolchain-r-test
1313
packages:
14+
- ccache
1415
- libssl1.0.0
1516
- bar
1617
- time
@@ -31,6 +32,7 @@ matrix:
3132
sources:
3233
- ubuntu-toolchain-r-test
3334
packages:
35+
- ccache
3436
- libssl1.0.0
3537
- bar
3638
- time
@@ -39,11 +41,7 @@ matrix:
3941
- os: osx
4042
env: ARCH="x86_64"
4143
osx_image: xcode8
42-
cache:
43-
directories:
44-
- $TRAVIS_BUILD_DIR/deps/srccache
45-
- $TRAVIS_BUILD_DIR/deps/scratch
46-
- $TRAVIS_BUILD_DIR/deps/usr-staging
44+
cache: ccache
4745
branches:
4846
only:
4947
- master
@@ -72,22 +70,23 @@ before_install:
7270
ln -s /usr/bin/g++-5 $HOME/bin/x86_64-linux-gnu-g++;
7371
gcc --version;
7472
BAR="bar -i 30";
75-
BUILDOPTS="-j5 VERBOSE=1 FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1";
73+
BUILDOPTS="-j5 VERBOSE=1 FORCE_ASSERTIONS=1 LLVM_ASSERTIONS=1 USECCACHE=1";
7674
echo "override ARCH=$ARCH" >> Make.user;
7775
sudo sh -c "echo 0 > /proc/sys/net/ipv6/conf/lo/disable_ipv6";
7876
export JULIA_CPU_CORES=4;
7977
export JULIA_TEST_MAXRSS_MB=1200;
8078
TESTSTORUN="all";
8179
elif [ `uname` = "Darwin" ]; then
8280
brew update;
83-
brew install -v jq pv;
81+
brew install -v jq pv ccache;
82+
export PATH="$(brew --prefix ccache)/libexec:$PATH";
8483
BAR="pv -i 30";
8584
contrib/travis_fastfail.sh || exit 1;
8685
brew tap staticfloat/julia;
8786
brew rm --force $(brew deps --HEAD julia);
8887
brew install -v --only-dependencies --HEAD julia;
8988
brew install -v staticfloat/juliadeps/libgfortran llvm39-julia;
90-
BUILDOPTS="-j3 USECLANG=1 LLVM_CONFIG=$(brew --prefix llvm39-julia)/bin/llvm-config LLVM_SIZE=$(brew --prefix llvm39-julia)/bin/llvm-size";
89+
BUILDOPTS="-j3 USECLANG=1 USECCACHE=1 LLVM_CONFIG=$(brew --prefix llvm39-julia)/bin/llvm-config LLVM_SIZE=$(brew --prefix llvm39-julia)/bin/llvm-size";
9190
BUILDOPTS="$BUILDOPTS VERBOSE=1 USE_BLAS64=0 SUITESPARSE_INC=-I$(brew --prefix suite-sparse-julia)/include FORCE_ASSERTIONS=1";
9291
BUILDOPTS="$BUILDOPTS LIBBLAS=-lopenblas LIBBLASNAME=libopenblas LIBLAPACK=-lopenblas LIBLAPACKNAME=libopenblas";
9392
for lib in LLVM SUITESPARSE ARPACK BLAS LAPACK GMP MPFR PCRE LIBUNWIND; do

base/client.jl

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,7 @@ function repl_cmd(cmd, out)
129129
else
130130
shell_escape_cmd = "($(shell_escape_posixly(cmd))) && true"
131131
end
132-
cmd = `$shell`
133-
isa(STDIN, TTY) && (cmd = `$cmd -i`)
134-
cmd = `$cmd -c $shell_escape_cmd`
132+
cmd = `$shell -c $shell_escape_cmd`
135133
end
136134
run(ignorestatus(cmd))
137135
end

base/deprecated.jl

Lines changed: 790 additions & 4 deletions
Large diffs are not rendered by default.

base/io.jl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -718,6 +718,18 @@ end
718718
719719
Read the entirety of `x` as a string and remove a single trailing newline
720720
if there is one. Equivalent to `chomp(read(x, String))`.
721+
722+
# Examples
723+
```jldoctest
724+
julia> open("my_file.txt", "w") do io
725+
write(io, "JuliaLang is a GitHub organization.\\nIt has many members.\\n");
726+
end;
727+
728+
julia> readchomp("my_file.txt")
729+
"JuliaLang is a GitHub organization.\\nIt has many members."
730+
731+
julia> rm("my_file.txt");
732+
```
721733
"""
722734
readchomp(x) = chomp(read(x, String))
723735

@@ -776,15 +788,29 @@ mutable struct EachLine
776788
end
777789

778790
"""
779-
eachline(stream::IO=STDIN; chomp::Bool=true)
791+
eachline(io::IO=STDIN; chomp::Bool=true)
780792
eachline(filename::AbstractString; chomp::Bool=true)
781793
782794
Create an iterable `EachLine` object that will yield each line from an I/O stream
783-
or a file. Iteration calls `readline` on the stream argument repeatedly with
795+
or a file. Iteration calls [`readline`](@ref) on the stream argument repeatedly with
784796
`chomp` passed through, determining whether trailing end-of-line characters are
785797
removed. When called with a file name, the file is opened once at the beginning of
786798
iteration and closed at the end. If iteration is interrupted, the file will be
787799
closed when the `EachLine` object is garbage collected.
800+
801+
# Examples
802+
```jldoctest
803+
julia> open("my_file.txt", "w") do io
804+
write(io, "JuliaLang is a GitHub organization.\\n It has many members.\\n");
805+
end;
806+
807+
julia> for line in eachline("my_file.txt")
808+
print(line)
809+
end
810+
JuliaLang is a GitHub organization. It has many members.
811+
812+
julia> rm("my_file.txt");
813+
```
788814
"""
789815
eachline(stream::IO=STDIN; chomp::Bool=true) = EachLine(stream, chomp=chomp)::EachLine
790816

base/linalg/adjtrans.jl

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
# This file is a part of Julia. License is MIT: https://julialang.org/license
2+
3+
using Base: @pure, @propagate_inbounds, _return_type, _default_type, _isleaftype, @_inline_meta
4+
import Base: length, size, indices, IndexStyle, getindex, setindex!, parent, vec, convert, similar
5+
6+
### basic definitions (types, aliases, constructors, abstractarray interface, sundry similar)
7+
8+
# note that Adjoint and Transpose must be able to wrap not only vectors and matrices
9+
# but also factorizations, rotations, and other linear algebra objects, including
10+
# user-defined such objects. so do not restrict the wrapped type.
11+
struct Adjoint{T,S} <: AbstractMatrix{T}
12+
parent::S
13+
function Adjoint{T,S}(A::S) where {T,S}
14+
checkeltype(Adjoint, T, eltype(A))
15+
new(A)
16+
end
17+
end
18+
struct Transpose{T,S} <: AbstractMatrix{T}
19+
parent::S
20+
function Transpose{T,S}(A::S) where {T,S}
21+
checkeltype(Transpose, T, eltype(A))
22+
new(A)
23+
end
24+
end
25+
26+
@pure function checkeltype(::Type{Transform}, ::Type{ResultEltype}, ::Type{ParentEltype}) where {Transform, ResultEltype, ParentEltype}
27+
if ResultEltype !== transformtype(Transform, ParentEltype)
28+
error(string("Element type mismatch. Tried to create an `$Transform{$ResultEltype}` ",
29+
"from an object with eltype `$ParentEltype`, but the element type of the ",
30+
"`$Transform` of an object with eltype `$ParentEltype` must be ",
31+
"`$(transformtype(Transform, ParentEltype))`"))
32+
end
33+
return nothing
34+
end
35+
function transformtype(::Type{O}, ::Type{S}) where {O,S}
36+
# similar to promote_op(::Any, ::Type)
37+
@_inline_meta
38+
T = _return_type(O, Tuple{_default_type(S)})
39+
_isleaftype(S) && return _isleaftype(T) ? T : Any
40+
return typejoin(S, T)
41+
end
42+
43+
# basic outer constructors
44+
Adjoint(A) = Adjoint{transformtype(Adjoint,eltype(A)),typeof(A)}(A)
45+
Transpose(A) = Transpose{transformtype(Transpose,eltype(A)),typeof(A)}(A)
46+
47+
# numbers are the end of the line
48+
Adjoint(x::Number) = adjoint(x)
49+
Transpose(x::Number) = transpose(x)
50+
51+
# unwrapping constructors
52+
# perhaps slightly odd, but necessary (at least till adjoint and transpose names are free)
53+
Adjoint(A::Adjoint) = A.parent
54+
Transpose(A::Transpose) = A.parent
55+
56+
# some aliases for internal convenience use
57+
const AdjOrTrans{T,S} = Union{Adjoint{T,S},Transpose{T,S}} where {T,S}
58+
const AdjOrTransAbsVec{T} = AdjOrTrans{T,<:AbstractVector}
59+
const AdjOrTransAbsMat{T} = AdjOrTrans{T,<:AbstractMatrix}
60+
61+
# for internal use below
62+
wrappertype(A::Adjoint) = Adjoint
63+
wrappertype(A::Transpose) = Transpose
64+
wrappertype(::Type{<:Adjoint}) = Adjoint
65+
wrappertype(::Type{<:Transpose}) = Transpose
66+
67+
# AbstractArray interface, basic definitions
68+
length(A::AdjOrTrans) = length(A.parent)
69+
size(v::AdjOrTransAbsVec) = (1, length(v.parent))
70+
size(A::AdjOrTransAbsMat) = reverse(size(A.parent))
71+
indices(v::AdjOrTransAbsVec) = (Base.OneTo(1), indices(v.parent)...)
72+
indices(A::AdjOrTransAbsMat) = reverse(indices(A.parent))
73+
IndexStyle(::Type{<:AdjOrTransAbsVec}) = IndexLinear()
74+
IndexStyle(::Type{<:AdjOrTransAbsMat}) = IndexCartesian()
75+
@propagate_inbounds getindex(v::AdjOrTransAbsVec, i::Int) = wrappertype(v)(v.parent[i])
76+
@propagate_inbounds getindex(A::AdjOrTransAbsMat, i::Int, j::Int) = wrappertype(A)(A.parent[j, i])
77+
@propagate_inbounds setindex!(v::AdjOrTransAbsVec, x, i::Int) = (setindex!(v.parent, wrappertype(v)(x), i); v)
78+
@propagate_inbounds setindex!(A::AdjOrTransAbsMat, x, i::Int, j::Int) = (setindex!(A.parent, wrappertype(A)(x), j, i); A)
79+
# AbstractArray interface, additional definitions to retain wrapper over vectors where appropriate
80+
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, is::AbstractArray{Int}) = wrappertype(v)(v.parent[is])
81+
@propagate_inbounds getindex(v::AdjOrTransAbsVec, ::Colon, ::Colon) = wrappertype(v)(v.parent[:])
82+
83+
# conversion of underlying storage
84+
convert(::Type{Adjoint{T,S}}, A::Adjoint) where {T,S} = Adjoint{T,S}(convert(S, A.parent))
85+
convert(::Type{Transpose{T,S}}, A::Transpose) where {T,S} = Transpose{T,S}(convert(S, A.parent))
86+
87+
# for vectors, the semantics of the wrapped and unwrapped types differ
88+
# so attempt to maintain both the parent and wrapper type insofar as possible
89+
similar(A::AdjOrTransAbsVec) = wrappertype(A)(similar(A.parent))
90+
similar(A::AdjOrTransAbsVec, ::Type{T}) where {T} = wrappertype(A)(similar(A.parent, transformtype(wrappertype(A), T)))
91+
# for matrices, the semantics of the wrapped and unwrapped types are generally the same
92+
# and as you are allocating with similar anyway, you might as well get something unwrapped
93+
similar(A::AdjOrTrans) = similar(A.parent, eltype(A), size(A))
94+
similar(A::AdjOrTrans, ::Type{T}) where {T} = similar(A.parent, T, size(A))
95+
similar(A::AdjOrTrans, ::Type{T}, dims::Dims{N}) where {T,N} = similar(A.parent, T, dims)
96+
97+
# sundry basic definitions
98+
parent(A::AdjOrTrans) = A.parent
99+
vec(v::AdjOrTransAbsVec) = v.parent
100+
101+
102+
### linear algebra
103+
104+
# definitions necessary for test/linalg/rowvector.jl to pass
105+
# should be cleaned up / revised as necessary in the future
106+
/(A::Transpose{<:Any,<:Vector}, B::Matrix) = /(transpose(A.parent), B)
107+
/(A::Transpose{<:Any,<:Vector}, B::Transpose{<:Any,<:Matrix}) = /(transpose(A.parent), B)
108+
*(A::Adjoint{<:Any,<:Matrix}, B::Adjoint{<:Any,<:Vector}) = *(adjoint(A.parent), adjoint(B.parent))
109+
110+
111+
# dismabiguation methods
112+
*(A::Transpose{<:Any,<:AbstractVector}, B::Adjoint{<:Any,<:AbstractVector}) = transpose(A.parent) * B
113+
*(A::Transpose{<:Any,<:AbstractVector}, B::Adjoint{<:Any,<:AbstractMatrix}) = transpose(A.parent) * B
114+
*(A::Transpose{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = A * adjoint(B.parent)
115+
*(A::Transpose{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractMatrix}) = transpose(A.parent) * B
116+
*(A::Adjoint{<:Any,<:AbstractVector}, B::Transpose{<:Any,<:AbstractVector}) = adjoint(A.parent) * B
117+
*(A::Adjoint{<:Any,<:AbstractVector}, B::Transpose{<:Any,<:AbstractMatrix}) = adjoint(A.parent) * B
118+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Adjoint{<:Any,<:AbstractVector}) = A * adjoint(B.parent)
119+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractVector}) = A * transpose(B.parent)
120+
*(A::Adjoint{<:Any,<:AbstractMatrix}, B::Transpose{<:Any,<:AbstractMatrix}) = adjoint(A.parent) * B

0 commit comments

Comments
 (0)