-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
33 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
*.ipynb_checkpoints | ||
*.DS_Store | ||
*.json | ||
|
||
impedance/__pycache__/ | ||
impedance/tests/__pycache__/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import numpy as np | ||
from impedance.model_io import model_export, model_import | ||
from impedance.circuits import CustomCircuit | ||
|
||
|
||
def test_model_io(): | ||
# get example data | ||
data = np.genfromtxt('./data/exampleData.csv', delimiter=',') | ||
|
||
frequencies = data[:, 0] | ||
Z = data[:, 1] + 1j*data[:, 2] | ||
|
||
randles = CustomCircuit(initial_guess=[.01, .005, .1, .005, .1, .001, 200], | ||
circuit='R_0-p(R_1,C_1)-p(R_1,C_1)-W_1/W_2') | ||
randles.fit(frequencies, Z) | ||
|
||
print(randles) | ||
|
||
model_export(randles, './test_io.json') | ||
randles2 = model_import('./test_io.json') | ||
print(randles2) | ||
|
||
assert randles == randles2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
from impedance.validation import calc_mu | ||
|
||
|
||
def test_calc_mu(): | ||
Rs = [1, 2, 3, -3, -2, -1] | ||
assert calc_mu(Rs) == 0 | ||
|
||
Rs = [-1, 2, 4, -3, 4, -1] | ||
assert calc_mu(Rs) == 0.5 |