Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
SystemIdentification
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Redmine
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Fredrik Bagge Carlson
SystemIdentification
Commits
c7a5d448
Commit
c7a5d448
authored
Sep 5, 2015
by
Fredrik Bagge Carlson
Browse files
Options
Downloads
Patches
Plain Diff
Added several tests
parent
6c44fba1
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
test/tests.jl
+70
-7
70 additions, 7 deletions
test/tests.jl
with
70 additions
and
7 deletions
test/tests.jl
+
70
−
7
View file @
c7a5d448
module
SystemIdentificationTests
export
run_tests
()
export
run_tests
using
SystemIdentification
macro
test
(
text
,
x
)
return
:
(
begin
global
success
=
0
global
fail
=
0
print
(
"Testing "
,
$
text
,
": "
)
try
$
x
if
fail
==
0
print_with_color
(
:
green
,
"Success:
$
success
\n
"
)
else
print_with_color
(
:
green
,
"Success:
$
success, "
)
print_with_color
(
:
red
,
"Failed:
$
fail
\n
"
)
end
catch
ex
print_with_color
(
:
red
,
"Failed: "
)
print
(
ex
,
"
\n
"
)
end
end
)
end
macro
tassert
(
x
)
return
:
(
begin
try
@assert
$
x
success
+=
1
catch
ex
if
isa
(
ex
,
AssertionError
)
print_with_color
(
:
red
,
"Error: "
)
print
(
ex
.
msg
,
" "
)
fail
+=
1
else
rethrow
(
ex
)
end
end
end
)
end
function
run_tests
()
@assert
isa
(
1
,
Polynom
)
@assert
isa
(
1.0
,
Polynom
)
@assert
isa
([
1.0
;
1.0
],
Polynom
)
@assert
isa
(
1.0
,
PolynomMatrix
)
@assert
isa
(
1
,
PolynomMatrix
)
@test
"Polynomials "
begin
@tassert
isa
(
1
,
Polynom
)
@tassert
isa
(
1.0
,
Polynom
)
@tassert
isa
([
1.0
;
1.0
],
Polynom
)
@tassert
isa
(
1.0
,
PolynomMatrix
)
@tassert
isa
(
1
,
PolynomMatrix
)
end
#ar(collect(1:5.0),1,bias=true)
@test
"AR "
begin
model
,
result
=
ar
(
collect
(
1
:
5.0
),
1
,
bias
=
true
)
fit
=
result
.
fit
@tassert
isa
(
model
,
AR
)
@tassert
isa
(
result
,
FitResult
)
@tassert
isa
(
fit
,
FitStatistics
)
@tassert
model
.
a
≈
[
1
;
1
]
@tassert
fit
.
FIT
≈
100.0
@tassert
isapprox
(
fit
.
RMS
,
0.0
,
atol
=
1e-10
)
@tassert
result
.
method
==
:
LS
end
@test
"ARX "
begin
model
,
result
=
arx
(
collect
(
1
:
5.0
),
collect
(
1
:
5.0
),
1
,
1
,
bias
=
true
)
fit
=
result
.
fit
@tassert
isa
(
model
,
ARX
)
@tassert
isa
(
result
,
FitResult
)
@tassert
isa
(
fit
,
FitStatistics
)
@tassert
model
.
a
≈
[
1
;
1
]
@tassert
fit
.
FIT
≈
100.0
@tassert
isapprox
(
fit
.
RMS
,
0.0
,
atol
=
1e-10
)
@tassert
result
.
method
==
:
LS
end
end
end
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment