Skip to content

Commit ec2fb7d

Browse files
committed
Format code
1 parent 5721d75 commit ec2fb7d

File tree

4 files changed

+37
-23
lines changed

4 files changed

+37
-23
lines changed

src/engine.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,16 +27,16 @@ mutable struct MSession
2727
end
2828
ep = ccall(eng_open[], Ptr{Cvoid}, (Ptr{UInt8},), startcmd(flags))
2929
if ep == C_NULL
30-
@warn("Confirm MATLAB is installed and discoverable.", maxlog=1)
30+
@warn("Confirm MATLAB is installed and discoverable.", maxlog = 1)
3131
if Sys.iswindows()
3232
@warn(
3333
"Ensure `matlab -regserver` has been run in a Command Prompt as Administrator.",
34-
maxlog=1
34+
maxlog = 1
3535
)
3636
elseif Sys.islinux()
3737
@warn(
3838
"Ensure `csh` is installed; this may require running `sudo apt-get install csh`.",
39-
maxlog=1
39+
maxlog = 1
4040
)
4141
end
4242
throw(MEngineError("failed to open MATLAB engine session"))

src/mxarray.jl

+30-16
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ function mxarray(a::Array{T}) where {T<:MxRealNum}
263263
(Ptr{Cvoid}, Ptr{Cvoid}, UInt),
264264
data_ptr(mx),
265265
a,
266-
length(a)*sizeof(T),
266+
length(a) * sizeof(T),
267267
)
268268
return mx
269269
end
@@ -374,7 +374,7 @@ function _copy_sparse_mat(
374374
ir[i] = rinds[i] - 1
375375
end
376376

377-
jc = unsafe_wrap(Array, jc_p, (n+1,))
377+
jc = unsafe_wrap(Array, jc_p, (n + 1,))
378378
for i = 1:(n+1)
379379
jc[i] = colptr[i] - 1
380380
end
@@ -402,7 +402,7 @@ function _copy_sparse_mat(
402402
ir[i] = rinds[i] - 1
403403
end
404404

405-
jc = unsafe_wrap(Array, jc_p, (n+1,))
405+
jc = unsafe_wrap(Array, jc_p, (n + 1,))
406406
for i = 1:(n+1)
407407
jc[i] = colptr[i] - 1
408408
end
@@ -414,7 +414,7 @@ function mxarray(a::SparseMatrixCSC{V,I}) where {V<:Union{Float64,ComplexF64,Boo
414414
m::Int = a.m
415415
n::Int = a.n
416416
nnz = length(a.nzval)
417-
@assert nnz == a.colptr[n+1]-1
417+
@assert nnz == a.colptr[n+1] - 1
418418

419419
mx = mxsparse(V, m, n, nnz)
420420
ir_p = ccall(mx_get_ir[], Ptr{mwIndex}, (Ptr{Cvoid},), mx)
@@ -439,7 +439,7 @@ function mxarray(s::String)
439439
_dims_to_mwSize((1, length(utf16string))))
440440
mx = MxArray(pm)
441441
ccall(:memcpy, Ptr{Cvoid}, (Ptr{Cvoid}, Ptr{Cvoid}, UInt), data_ptr(mx), utf16string,
442-
length(utf16string)*sizeof(UInt16))
442+
length(utf16string) * sizeof(UInt16))
443443
return mx
444444
end
445445

@@ -453,7 +453,7 @@ end
453453
mxcellarray(dims::Integer...) = mxcellarray(dims)
454454

455455
function get_cell(mx::MxArray, i::Integer)
456-
pm = ccall(mx_get_cell[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex), mx, i-1)
456+
pm = ccall(mx_get_cell[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex), mx, i - 1)
457457
MxArray(pm, false)
458458
end
459459

@@ -505,7 +505,7 @@ function set_field(mx::MxArray, i::Integer, f::String, v::MxArray)
505505
Cvoid,
506506
(Ptr{Cvoid}, mwIndex, Ptr{UInt8}, Ptr{Cvoid}),
507507
mx,
508-
i-1,
508+
i - 1,
509509
f,
510510
v,
511511
)
@@ -515,23 +515,30 @@ end
515515
set_field(mx::MxArray, f::String, v::MxArray) = set_field(mx, 1, f, v)
516516

517517
function get_field(mx::MxArray, i::Integer, f::String)
518-
pm = ccall(mx_get_field[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex, Ptr{UInt8}), mx, i-1, f)
518+
pm = ccall(mx_get_field[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex, Ptr{UInt8}), mx, i - 1, f)
519519
pm == C_NULL && throw(ArgumentError("Failed to get field."))
520520
MxArray(pm, false)
521521
end
522522

523523
get_field(mx::MxArray, f::String) = get_field(mx, 1, f)
524524

525525
function get_field(mx::MxArray, i::Integer, fn::Integer)
526-
pm = ccall(mx_get_field_bynum[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex, Cint), mx, i-1, fn-1)
526+
pm = ccall(
527+
mx_get_field_bynum[],
528+
Ptr{Cvoid},
529+
(Ptr{Cvoid}, mwIndex, Cint),
530+
mx,
531+
i - 1,
532+
fn - 1,
533+
)
527534
pm == C_NULL && throw(ArgumentError("Failed to get field."))
528535
MxArray(pm, false)
529536
end
530537

531538
get_field(mx::MxArray, fn::Integer) = get_field(mx, 1, fn)
532539

533540
function get_fieldname(mx::MxArray, i::Integer)
534-
p = ccall(mx_get_fieldname[], Ptr{UInt8}, (Ptr{Cvoid}, Cint), mx, i-1)
541+
p = ccall(mx_get_fieldname[], Ptr{UInt8}, (Ptr{Cvoid}, Cint), mx, i - 1)
535542
unsafe_string(p)
536543
end
537544

@@ -606,7 +613,7 @@ function _jarrayx(fun::String, mx::MxArray, siz::Tuple)
606613
(Ptr{Cvoid}, Ptr{Cvoid}, UInt),
607614
a,
608615
data_ptr(mx),
609-
length(a)*sizeof(T),
616+
length(a) * sizeof(T),
610617
)
611618
end
612619
end
@@ -644,7 +651,7 @@ function jscalar(mx::MxArray)
644651
@assert !is_sparse(mx)
645652
if is_complex(mx)
646653
return unsafe_wrap(Array, real_ptr(mx), (1,))[1] +
647-
im*unsafe_wrap(Array, imag_ptr(mx), (1,))[1]
654+
im * unsafe_wrap(Array, imag_ptr(mx), (1,))[1]
648655
else
649656
return unsafe_wrap(Array, data_ptr(mx), (1,))[1]
650657
end
@@ -656,18 +663,18 @@ function _jsparse(ty::Type{T}, mx::MxArray) where {T<:MxRealNum}
656663
ir_ptr = ccall(mx_get_ir[], Ptr{mwIndex}, (Ptr{Cvoid},), mx)
657664
jc_ptr = ccall(mx_get_jc[], Ptr{mwIndex}, (Ptr{Cvoid},), mx)
658665

659-
jc_a::Vector{mwIndex} = unsafe_wrap(Array, jc_ptr, (n+1,))
666+
jc_a::Vector{mwIndex} = unsafe_wrap(Array, jc_ptr, (n + 1,))
660667
nnz = jc_a[n+1]
661668

662669
ir = Vector{Int}(undef, nnz)
663-
jc = Vector{Int}(undef, n+1)
670+
jc = Vector{Int}(undef, n + 1)
664671

665672
ir_x = unsafe_wrap(Array, ir_ptr, (nnz,))
666673
for i = 1:nnz
667674
ir[i] = ir_x[i] + 1
668675
end
669676

670-
jc_x = unsafe_wrap(Array, jc_ptr, (n+1,))
677+
jc_x = unsafe_wrap(Array, jc_ptr, (n + 1,))
671678
for i = 1:(n+1)
672679
jc[i] = jc_x[i] + 1
673680
end
@@ -713,7 +720,14 @@ function Dict(mx::MxArray)
713720
for i = 1:nf
714721
fnames[i] = get_fieldname(mx, i)
715722
pv =
716-
ccall(mx_get_field_bynum[], Ptr{Cvoid}, (Ptr{Cvoid}, mwIndex, Cint), mx, 0, i-1)
723+
ccall(
724+
mx_get_field_bynum[],
725+
Ptr{Cvoid},
726+
(Ptr{Cvoid}, mwIndex, Cint),
727+
mx,
728+
0,
729+
i - 1,
730+
)
717731
fx = MxArray(pv, false)
718732
fvals[i] = jvalue(fx)
719733
end

test/matfile.jl

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ a32 = Int32[1 2 3; 4 5 6]
88
a64 = Int64[1 2 3; 4 5 6]
99
b = [1.2, 3.4, 5.6, 7.8]
1010
c = [[0.0, 1.0], [1.0, 2.0], [1.0, 2.0, 3.0]]
11-
d = Dict("name"=>"MATLAB", "score"=>100.0)
11+
d = Dict("name" => "MATLAB", "score" => 100.0)
1212

1313
struct S
1414
x::Float64

test/mxarray.jl

+3-3
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ a2 = jvector(a_mx)
176176
@test isequal([1:5;], a2)
177177
delete(a_mx)
178178

179-
a = rand(5, 6) + rand(5, 6)*im
179+
a = rand(5, 6) + rand(5, 6) * im
180180
a_mx = mxarray(a)
181181
a2 = jarray(a_mx)
182182
@test isequal(a, a2)
@@ -290,7 +290,7 @@ a = mxstruct("abc", "efg", "xyz")
290290
@test get_fieldname(a, 3) == "xyz"
291291
delete(a)
292292

293-
s = Dict("name"=>"MATLAB", "version"=>12.0, "data"=>[1, 2, 3])
293+
s = Dict("name" => "MATLAB", "version" => 12.0, "data" => [1, 2, 3])
294294
a = mxstruct(s)
295295
@test is_struct(a)
296296
@test mxnfields(a) == 3
@@ -448,7 +448,7 @@ delete(x)
448448
@test y[2] == a[2]
449449
@test y[3] == a[3]
450450

451-
a = Dict("abc"=>10.0, "efg"=>[1, 2, 3], "xyz"=>"MATLAB")
451+
a = Dict("abc" => 10.0, "efg" => [1, 2, 3], "xyz" => "MATLAB")
452452
x = mxarray(a)
453453
y = jvalue(x)
454454
delete(x)

0 commit comments

Comments
 (0)