Skip to content

Commit 05b8721

Browse files
fredrikekrejrevels
authored andcommitted
fixes for Julia v0.7
1 parent df96c3c commit 05b8721

File tree

5 files changed

+28
-27
lines changed

5 files changed

+28
-27
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ os:
44
- linux
55
- osx
66
julia:
7-
- 0.6
7+
- 0.7
88
- nightly
99
matrix:
1010
allow_failures:
@@ -14,4 +14,4 @@ notifications:
1414
git:
1515
depth: 99999999
1616
after_success:
17-
- julia -e 'cd(Pkg.dir("DiffTests")); Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'
17+
- julia -e 'Pkg.add("Coverage"); using Coverage; Coveralls.submit(Coveralls.process_folder())'

REQUIRE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
julia 0.6
1+
julia 0.7-beta2

appveyor.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,14 @@
11
environment:
22
matrix:
3-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.6/julia-0.6-latest-win32.exe"
4-
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.6/julia-0.6-latest-win64.exe"
3+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x86/0.7/julia-0.7-latest-win32.exe"
4+
- JULIA_URL: "https://julialang-s3.julialang.org/bin/winnt/x64/0.7/julia-0.7-latest-win64.exe"
55
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
66
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
77

8-
## uncomment the following lines to allow failures on nightly julia
9-
## (tests will run but not make your overall status red)
10-
#matrix:
11-
# allow_failures:
12-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
13-
# - JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
8+
matrix:
9+
allow_failures:
10+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x86/julia-latest-win32.exe"
11+
- JULIA_URL: "https://julialangnightlies-s3.julialang.org/bin/winnt/x64/julia-latest-win64.exe"
1412

1513
branches:
1614
only:

src/DiffTests.jl

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
module DiffTests
22

3+
using LinearAlgebra: det, norm, dot, tr
4+
using Statistics: mean
5+
36
#=
47
These functions are organized in sets based on input/output type. They are unary and not
58
in-place unless otherwised specified. These functions have been written with the following
@@ -44,9 +47,9 @@ end
4447

4548
const NUMBER_TO_ARRAY_FUNCS = (num2arr_1,)
4649

47-
#################################
48-
# f!(y::Array, x::Number)::Void #
49-
#################################
50+
####################################
51+
# f!(y::Array, x::Number)::Nothing #
52+
####################################
5053

5154
function num2arr_1!(y, x)
5255
fill!(y, zero(x))
@@ -64,7 +67,7 @@ const INPLACE_NUMBER_TO_ARRAY_FUNCS = (num2arr_1!,)
6467

6568
vec2num_1(x) = (exp(x[1]) + log(x[3]) * x[4]) / x[5]
6669
vec2num_2(x) = x[1]*x[2] + sin(x[1])
67-
vec2num_3(x) = vecnorm(x' .* x)
70+
vec2num_3(x) = norm(x' .* x)
6871
vec2num_4(x) = ((sum(x) + prod(x)); 1)
6972
vec2num_5(x) = sum((-x).^3)
7073
vec2num_6(x) = sum([ifelse(i > 0, i, 0) for i in x])
@@ -124,7 +127,7 @@ mat2num_1(x) = det(first(x) * inv(x * x) + x)
124127
function mat2num_2(x)
125128
a = reshape(x, length(x), 1)
126129
b = reshape(copy(x), 1, length(x))
127-
return trace(log.((1 .+ (a * b)) .+ a .- b))
130+
return tr(log.((1 .+ (a * b)) .+ a .- b))
128131
end
129132

130133
function mat2num_3(x)
@@ -134,9 +137,9 @@ function mat2num_3(x)
134137
return sum(map(n -> sqrt(abs(n) + n^2) * 0.5, A))
135138
end
136139

137-
mat2num_4(x) = mean(sum(sin.(x) * x, 2))
140+
mat2num_4(x) = mean(sum(sin.(x) * x, dims=2))
138141

139-
softmax(x) = sum(exp.(x) ./ sum(exp.(x), 2))
142+
softmax(x) = sum(exp.(x) ./ sum(exp.(x), dims=2))
140143

141144
const MATRIX_TO_NUMBER_FUNCS = (det, mat2num_1, mat2num_2, mat2num_3, mat2num_4, softmax)
142145

@@ -157,8 +160,8 @@ const BINARY_BROADCAST_OPS = ((a, b) -> broadcast(+, a, b),
157160

158161
const BINARY_MATRIX_TO_MATRIX_FUNCS = (+, -, *, /, \,
159162
BINARY_BROADCAST_OPS...,
160-
A_mul_Bt, At_mul_B, At_mul_Bt,
161-
A_mul_Bc, Ac_mul_B, Ac_mul_Bc)
163+
(a, b) -> a * transpose(b), (a, b) -> transpose(a) * b, (a, b) -> transpose(a) * transpose(b),
164+
(a, b) -> a * adjoint(b), (a, b) -> adjoint(a) * b, (a, b) -> adjoint(a) * adjoint(b))
162165

163166
###########################################
164167
# f(::Matrix, ::Matrix, ::Matrix)::Number #
@@ -170,9 +173,9 @@ neural_step(x1, w1, w2) = sigmoid(dot(w2[1:size(w1, 2)], relu(w1 * x1[1:size(w1,
170173

171174
const TERNARY_MATRIX_TO_NUMBER_FUNCS = (neural_step,)
172175

173-
################################
174-
# f!(y::Array, x::Array)::Void #
175-
################################
176+
###################################
177+
# f!(y::Array, x::Array)::Nothing #
178+
###################################
176179
# Credit for `chebyquad!`, `brown_almost_linear!`, and `trigonometric!` goes to
177180
# Kristoffer Carlsson (@KristofferC).
178181

test/runtests.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using DiffTests
2-
using Base.Test
2+
using Test
33

44
n = rand()
55
x, y = rand(5, 5), rand(26)
@@ -42,12 +42,12 @@ for f in DiffTests.BINARY_MATRIX_TO_MATRIX_FUNCS
4242
@test isa(f(A, B), Array)
4343
end
4444

45-
# f! returns Void
45+
# f! returns Nothing
4646

4747
for f! in DiffTests.INPLACE_ARRAY_TO_ARRAY_FUNCS
48-
@test isa(f!(y, x), Void)
48+
@test isa(f!(y, x), Nothing)
4949
end
5050

5151
for f! in DiffTests.INPLACE_NUMBER_TO_ARRAY_FUNCS
52-
@test isa(f!(y, n), Void)
52+
@test isa(f!(y, n), Nothing)
5353
end

0 commit comments

Comments
 (0)