Skip to content

Commit ff8829f

Browse files
committed
add unlog core util func
1 parent 312fed7 commit ff8829f

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

fooof/core/utils.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,25 @@
88
###################################################################################################
99
###################################################################################################
1010

11+
def unlog(arr, base=10):
12+
"""Helper function to unlog an array.
13+
14+
Parameters
15+
----------
16+
arr : ndarray
17+
Array.
18+
base : float
19+
Base of the log to undo.
20+
21+
Returns
22+
-------
23+
ndarray
24+
Unlogged array.
25+
"""
26+
27+
return np.power(base, arr)
28+
29+
1130
def group_three(vec):
1231
"""Group an array of values into threes.
1332

fooof/tests/core/test_utils.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,13 @@
1212
###################################################################################################
1313
###################################################################################################
1414

15+
def test_unlog():
16+
17+
orig = np.array([1, 2, 3, 4])
18+
logged = np.log10(orig)
19+
unlogged = unlog(logged)
20+
assert np.array_equal(orig, unlogged)
21+
1522
def test_group_three():
1623

1724
dat = [0, 1, 2, 3, 4, 5]

0 commit comments

Comments
 (0)