# -*- coding: utf-8 -*-
#
# Copyright 2018 <+YOU OR YOUR COMPANY+>.
#
# This is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3, or (at your option)
# any later version.
#
# This software is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this software; see the file COPYING. If not, write to
# the Free Software Foundation, Inc., 51 Franklin Street,
# Boston, MA 02110-1301, USA.
#
from gnuradio import gr, gr_unittest
from gnuradio import blocks
from fuzzy_mod_adap_ff_ff import fuzzy_mod_adap_ff_ff
class qa_fuzzy_mod_adap_ff_ff (gr_unittest.TestCase):
def setUp (self):
self.tb = gr.top_block ()
def tearDown (self):
self.tb = None
def test_001_t (self):
src_data1 = (20, 10, 20, 10 )
src_data2 = (1, 1, 0, 0 )
expected_result1 = (40, 40)
expected_result2 = (12, 12)
src1 = blocks.vector_source_f (src_data1)
src2 = blocks.vector_source_f (src_data2)
fuzzy1 = fuzzy_mod_adap_ff_ff ()
snk1 = blocks.vector_sink_f ()
snk2 = blocks.vector_sink_f ()
self.tb.connect (src1, (fuzzy1,0))
self.tb.connect (src2, (fuzzy1,1))
self.tb.connect ((fuzzy1,0), snk1)
self.tb.connect ((fuzzy1,1), snk2)
self.tb.run ()
result1_data = snk1.data ()
result2_data = snk2.data ()
#self.assertFloatTuplesAlmostEqual (expected_result1, result1_data, 6)
#self.assertFloatTuplesAlmostEqual (expected_result2, result2_data, 6)
print(result1_data)
print(result2_data)
if __name__ == '__main__':
gr_unittest.run(qa_fuzzy_mod_adap_ff_ff, "qa_fuzzy_mod_adap_ff_ff.xml")
"""
docstring for block fuzzy_mod_adap_ff_ff
"""
def __init__(self,):
gr.sync_block.__init__(self,
name="fuzzy_mod_adap_ff_ff",
in_sig=[np.float32, np.float32],
out_sig=[np.float32, np.float32])
in0 = input_items[0]
in1 = input_items[1]
out0 = output_items[0]
out1 = output_items[1]
for i in range(0, len(in0)):
X1= in0[i]
Act_Mod= in1[i]
self.Normaliza(X1,Act_Mod)
out1[i], out0[i] = self.Fuzzy()
return len(output_items[0])
(38.653770446777344, 61.346229553222656, 38.653770446777344, 61.346229553222656)
(61.346229553222656, 38.653770446777344, 61.346229553222656, 38.653770446777344)
(38.653770446777344, 61.346229553222656, 38.653770446777344, 61.346229553222656)
(61.346229553222656, 38.653770446777344, 61.346229553222656, 38.653770446777344)
.
------------------------------
Ran 1 test in 0.021s
OK


No comments:
Post a Comment