Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
lib4neuro
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Container Registry
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MolDyn
lib4neuro
Commits
9b2200fa
Commit
9b2200fa
authored
7 years ago
by
Martin Mrovec
Browse files
Options
Downloads
Patches
Plain Diff
ENH: Test suite formatted using the Las Vegas convention.
parent
0a34edc4
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/connection_m.fun
+92
-58
92 additions, 58 deletions
src/connection_m.fun
with
92 additions
and
58 deletions
src/connection_m.fun
+
92
−
58
View file @
9b2200fa
!>
Unit
test
suite
for
connections
(
synapses
)
!!
in
neural
networks
.
!!
!!
@author
Martin
Beseda
!!
@author
Martin
Mrovec
!!
@date
2017
test_suite
connection_m
!
Global
variables
declaration
type
(
neuron_t
)
,
target
::
n1
type
(
neuron_t
)
,
target
::
n2
type
(
neuron_t
)
,
pointer
::
n1_p
type
(
neuron_t
)
,
pointer
::
n2_p
type
(
neuron_t
)
,
pointer
::
dummy_p
type
(
interval_connection_t
)
,
pointer
::
con
!
Setup
before
each
test
setup
write
(*
,*)
'Creating
instances
of
the
class
neuron_t
.
..
'
n1
=
neuron_t
(
21.3
)
n2
=
neuron_t
(
13.7
)
write
(*
,*)
'Assigning
instances
to
pointer
.
..
'
n1_p
=>
n1
n2_p
=>
n2
print
*
,
'Creating
an
instance
of
the
class
interval_connection_t
.
..
'
con
=>
interval_connection_t
(
n1_p
,
n2_p
,
5.25
)
nullify
(
dummy_p
)
end
setup
!
After
each
test
do
the
cleanup
teardown
write
(*
,*)
'Deallocating
everything
.
'
deallocate
(
con
)
nullify
(
dummy_p
)
end
teardown
!
Test
of
getters
and
setters
test
getters_setters
write
(*
,*)
'Test
of
getters
and
setters
.
'
!
Test
of
get_weight
assert_real_equal
(
con%get_weight
(),
5.25
e+
0
)
!
Test
of
adjust_weight
call
con%adjust_weight
(
1.0
)
assert_real_equal
(
con%get_weight
(),
6.25
e+
0
)
end
test
test
input_and_output_neurons
write
(*
,*)
'Test
of
input
and
output
neurons
.
'
!
Input
neuron
dummy_p
=>
con%get_input_neuron
()
assert_real_equal
(
dummy_p%get_state
(),
21.3
d+
0
)
!
Output
neuron
dummy_p
=>
con%get_output_neuron
()
assert_real_equal
(
dummy_p%get_state
(),
13.7
d+
0
)
end
test
test
pass_signal
write
(*
,*)
'Test
of
passing
a
signal
.
'
dummy_p
=>
con%get_output_neuron
()
call
con%pass_signal
()
assert_real_equal
(
dummy_p%get_state
(),
111.825
d+
0
)
end
test
!
Global
variables
declaration
type
(
neuron_t
)
,
target
::
n1
type
(
neuron_t
)
,
target
::
n2
type
(
neuron_t
)
,
pointer
::
n1_p
type
(
neuron_t
)
,
pointer
::
n2_p
type
(
neuron_t
)
,
pointer
::
dummy_p
type
(
interval_connection_t
)
,
pointer
::
con
!------------------------!---------------------------------------------------------------
!
Setup
before
each
test
!
!------------------------!
setup
write
(*
,*)
'
+------------------------+
'
write
(*
,*)
'
|
SETUP
BEFORE
UNIT
TEST
|
'
write
(*
,*)
'
+------------------------+
'
write
(*
,*)
'Creating
instances
of
the
class
neuron_t
.
..
'
n1
=
neuron_t
(
21.3
)
n2
=
neuron_t
(
13.7
)
write
(*
,*)
'Assigning
instances
to
pointer
.
..
'
n1_p
=>
n1
n2_p
=>
n2
write
(*
,*)
'Creating
an
instance
of
the
class
interval_connection_t
.
..
'
con
=>
connection_t
(
n1_p
,
n2_p
,
5.25
)
nullify
(
dummy_p
)
write
(*
,*)
'Ready
for
test
.
'
end
setup
!-------------------------!--------------------------------------------------------------
!
Cleanup
after
each
test
!
!-------------------------!
teardown
write
(*
,*)
'+-------------------------+'
write
(*
,*)
'
|
CLEANUP
AFTER
UNIT
TEST
|
'
write
(*
,*)
'+-------------------------+'
write
(*
,*)
'Deallocating
everything
.
'
deallocate
(
con
)
nullify
(
dummy_p
)
write
(*
,*)
'Cleaned
succesfully
.
'
end
teardown
!-------!--------------------------------------------------------------------------------
!
Tests
!
!-------!
!-----------------------------!
!
Test
of
getters
and
setters
!
!-----------------------------!
test
getters_setters
write
(*
,*)
'+++
Test
of
getters
and
setters
...
'
!
Test
of
get_weight
assert_real_equal
(
con%get_weight
(),
5.25
e+
0
)
!
Test
of
adjust_weight
call
con%adjust_weight
(
1.0
)
assert_real_equal
(
con%get_weight
(),
6.25
e+
0
)
write
(*
,*)
'
.
..
finished
+++'
end
test
!----------------------------------!
!
Test
of
input
and
output
neurons
!
!----------------------------------!
test
input_and_output_neurons
write
(*
,*)
'+++
Test
of
input
and
output
neurons
...
'
!
Input
neuron
dummy_p
=>
con%get_input_neuron
()
assert_real_equal
(
dummy_p%get_state
(),
21.3
d+
0
)
!
Output
neuron
dummy_p
=>
con%get_output_neuron
()
assert_real_equal
(
dummy_p%get_state
(),
13.7
d+
0
)
write
(*
,*)
'
.
..
finished
+++'
end
test
!--------------------------!
!
Test
of
passing
a
signal
!
!--------------------------!
test
pass_signal
write
(*
,*)
'+++
Test
of
passing
a
signal
...
'
dummy_p
=>
con%get_output_neuron
()
call
con%pass_signal
()
assert_real_equal
(
dummy_p%get_state
(),
111.825
d+
0
)
write
(*
,*)
'
.
..
finished
+++'
end
test
end
test_suite
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