Skip to content

Commit

Permalink
cleanup code
Browse files Browse the repository at this point in the history
  • Loading branch information
jopohl committed Jul 7, 2020
1 parent 7cdea46 commit 22f3cf6
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/urh/models/GeneratorTableModel.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import array
import time
from collections import defaultdict

from PyQt5.QtCore import Qt, QModelIndex, pyqtSlot, pyqtSignal
Expand All @@ -17,6 +16,7 @@
from urh.ui.actions.DeleteBitsAndPauses import DeleteBitsAndPauses
from urh.ui.actions.InsertBitsAndPauses import InsertBitsAndPauses
from urh.util import util
from urh.cythonext import util as c_util


class GeneratorTableModel(TableModel):
Expand Down Expand Up @@ -147,7 +147,7 @@ def generate_de_bruijn(self, row_index: int, start: int, end: int):
f = 1 if self.proto_view == 0 else 4 if self.proto_view == 1 else 8
start, end = f * start, f * end

de_bruijn_seq = util.de_bruijn(end-start)
de_bruijn_seq = c_util.de_bruijn(end-start)

tmp_protocol = ProtocolAnalyzer(None)
tmp_protocol.messages = []
Expand Down
5 changes: 0 additions & 5 deletions src/urh/util/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import time
from xml.dom import minidom
from xml.etree import ElementTree as ET
import urh.cythonext.util as c_util

import numpy as np
from PyQt5.QtCore import Qt
Expand Down Expand Up @@ -473,7 +472,3 @@ def calc_x_y_scale(rect, parent):
scale_y = view_rect.height() / parent_height

return scale_x, scale_y


def de_bruijn(n: int) -> array.array:
return c_util.de_bruijn(n)
5 changes: 3 additions & 2 deletions tests/test_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
from urh.signalprocessing.Signal import Signal
from urh.util import util
from urh.util.Logger import logger
from urh.cythonext import util as c_util


class TestUtil(QtTestCase):
Expand Down Expand Up @@ -71,8 +72,8 @@ def test_write_pcap(self):
pcap.write_packets(proto_analyzer.messages, os.path.join(tempfile.gettempdir(), "test.pcap"), 1e6)

def test_de_bruijn_fuzzing(self):
self.assertEqual(util.de_bruijn(3), array.array("B", [0, 0, 0, 1, 0, 1, 1, 1]))
self.assertEqual(util.de_bruijn(4), array.array("B", [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]))
self.assertEqual(c_util.de_bruijn(3), array.array("B", [0, 0, 0, 1, 0, 1, 1, 1]))
self.assertEqual(c_util.de_bruijn(4), array.array("B", [0, 0, 0, 0, 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1]))

def test_native_backends_installed(self):
from urh.util import util
Expand Down

0 comments on commit 22f3cf6

Please sign in to comment.