added files:

.codeclimate.yml
test_bitwise.py
test_dct_pack.py
master
Per A Brodtkorb 9 years ago
parent 4c90891b59
commit f1dc17a9fa

@ -0,0 +1,20 @@
engines:
duplication:
enabled: true
- mass = 50
config:
languages:
python:
mass_threshold: 40
fixme:
enabled: true
radon:
enabled: true
ratings:
paths:
- "**.py"
exclude_paths:
- wafo/tests/
- wafo/MSPPT.py
- wafo/MSO.py

@ -0,0 +1,38 @@
'''
Created on 14. feb. 2016
@author: pab
'''
import unittest
import wafo.bitwise as wb
import numpy as np
from numpy.testing import assert_array_equal
class Test(unittest.TestCase):
def test_getbit(self):
assert_array_equal(wb.getbit(13, np.arange(3, -1, -1)),
[1, 1, 0, 1])
assert_array_equal(wb.getbit(5, np.r_[0:4]), [1, 0, 1, 0])
def test_setbit(self):
"""
Set bit fifth bit in the five bit binary binary representation
of 9 (01001)
"""
assert_array_equal(wb.setbit(9, 4), 25)
def test_setbits(self):
assert_array_equal(wb.setbits([1, 1]), 3)
assert_array_equal(wb.setbits([1, 0]), 1)
def test_getbits(self):
assert_array_equal(wb.getbits(3), [1, 1, 0, 0, 0, 0, 0, 0])
assert_array_equal(wb.getbits(1), [1, 0, 0, 0, 0, 0, 0, 0])
if __name__ == "__main__":
# import sys;sys.argv = ['', 'Test.testName']
unittest.main()

@ -0,0 +1,48 @@
'''
Created on 14. feb. 2016
@author: pab
'''
import unittest
import numpy as np
from numpy.testing import assert_array_almost_equal
import wafo.dctpack as wd
class Test(unittest.TestCase):
def test_dct3(self):
a = np.array([[[0.51699637, 0.42946223, 0.89843545],
[0.27853391, 0.8931508, 0.34319118],
[0.51984431, 0.09217771, 0.78764716]],
[[0.25019845, 0.92622331, 0.06111409],
[0.81363641, 0.06093368, 0.13123373],
[0.47268657, 0.39635091, 0.77978269]],
[[0.86098829, 0.07901332, 0.82169182],
[0.12560088, 0.78210188, 0.69805434],
[0.33544628, 0.81540172, 0.9393219]]])
dct = wd.dct
d = dct(dct(dct(a).transpose(0, 2, 1)).transpose(2, 1, 0)
).transpose(2, 1, 0).transpose(0, 2, 1)
d0 = wd.dctn(a)
idct = wd.idct
e = idct(idct(idct(d).transpose(0, 2, 1)).transpose(2, 1, 0)
).transpose(2, 1, 0).transpose(0, 2, 1)
assert_array_almost_equal(d, d0)
assert_array_almost_equal(a, e)
def test_dct_and_dctn(self):
a = np.arange(12).reshape((3, -1))
y = wd.dct(a)
x = wd.idct(y)
assert_array_almost_equal(x, a)
yn = wd.dctn(a) # , shape=(10,), axes=(1,))
xn = wd.idctn(yn) # , axes=(1,))
assert_array_almost_equal(xn, a)
if __name__ == "__main__":
#import sys;sys.argv = ['', 'Test.testName']
unittest.main()
Loading…
Cancel
Save