Skip to content

Commit

Permalink
test: Fix white spice offset for macOS
Browse files Browse the repository at this point in the history
  • Loading branch information
Robert W committed Oct 24, 2024
1 parent 3beda7b commit a783f94
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 31 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tomlproject.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,4 @@ jobs:
- name: Run Tests
run: |
pytest --cov=pvcircuit
continue-on-error: true
# continue-on-error: true
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ ignore = [
[tool.pytest.ini_options]
# Specify directories to ignore during testing
norecursedirs = ["Share", "notebooks", "images", "data"]
addopts = "--cov=pvcircuit --cov-report=html" # run coverage automatically with pytest
addopts = "--cov=pvcircuit --cov-report=html --cov-report=term" # run coverage automatically with pytest

[tool.coverage.run]
branch = true
Expand Down
15 changes: 8 additions & 7 deletions tests/test_iv3t.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import re
from pathlib import Path

import matplotlib.pyplot as plt
Expand Down Expand Up @@ -35,7 +36,7 @@ def test_iv3t_str(iv3t):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_iv3t_setter(dev3T, iv3t):
Expand All @@ -54,7 +55,7 @@ def test_iv3t_setter(dev3T, iv3t):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_dev2load(dev3T,iv3t):
Expand All @@ -81,7 +82,7 @@ def test_line(iv3t):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_box(iv3t):
Expand All @@ -96,7 +97,7 @@ def test_box(iv3t):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_nanpnt(iv3t):
Expand Down Expand Up @@ -124,7 +125,7 @@ def test_mpp(iv3t, dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_resize(iv3t, dev3T):
Expand All @@ -144,7 +145,7 @@ def test_resize(iv3t, dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_calc(iv3t,dev3T):
Expand Down Expand Up @@ -182,7 +183,7 @@ def test_calc(iv3t,dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))

if __name__ == "__main__":
iv3t = IV3T()
Expand Down
9 changes: 5 additions & 4 deletions tests/test_oldpvc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import re
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -92,7 +93,7 @@ def test_Tandem3T_MPP(tandem3T):
with open(Path().cwd().joinpath("tests", "test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, tandem3T.MPP().__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",tandem3T.MPP().__str__()))

def test_Tandem3T_CM(tandem3T):

Expand All @@ -111,15 +112,15 @@ def test_Tandem3T_VM21(tandem3T):
with open(Path().cwd().joinpath("tests", "test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, tandem3T.VM(2, 1).__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",tandem3T.VM(2, 1).__str__()))

def test_Tandem3T_VM32(tandem3T):

test_file = "oldpvc_Tandem3T_VM32.txt"
with open(Path().cwd().joinpath("tests", "test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, tandem3T.VM(3, 2).__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",tandem3T.VM(3, 2).__str__()))


def test_Tandem3T_VM32_set(tandem3T):
Expand All @@ -131,7 +132,7 @@ def test_Tandem3T_VM32_set(tandem3T):
with open(Path().cwd().joinpath("tests", "test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, tandem3T.VM(3, 2).__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",tandem3T.VM(3, 2).__str__()))

dev2T = Multi2T.from_3T(tandem3T)

Expand Down
37 changes: 19 additions & 18 deletions tests/test_tandem3T.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import itertools
import re
from pathlib import Path

import numpy as np
Expand Down Expand Up @@ -39,7 +40,7 @@ def test_tandem3T_str(dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, dev3T.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",test_str))


def test_tandem3T_maxsetters(dev3T):
Expand Down Expand Up @@ -76,9 +77,9 @@ def test_V3T(dev3T, iv3t):

# read fixed test case for s-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_s = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_s, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))

dev3T.bot.set(Jext=20e-3, pn=-1)
dev3T.V3T(iv3t)
Expand All @@ -90,9 +91,9 @@ def test_V3T(dev3T, iv3t):

# read fixed test case for r-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_r = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_r, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_J3Tabs(dev3T, iv3t):
Expand All @@ -108,9 +109,9 @@ def test_J3Tabs(dev3T, iv3t):

# read fixed test case for s-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_s = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_s, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))

dev3T.bot.set(pn=-1)
dev3T.J3Tabs(iv3t)
Expand All @@ -122,9 +123,9 @@ def test_J3Tabs(dev3T, iv3t):

# read fixed test case for r-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_r = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_r, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_I3Trel(dev3T, iv3t):
Expand All @@ -140,9 +141,9 @@ def test_I3Trel(dev3T, iv3t):

# read fixed test case for s-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_s = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_s, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))

dev3T.bot.set(pn=-1)
dev3T.I3Trel(iv3t)
Expand All @@ -154,9 +155,9 @@ def test_I3Trel(dev3T, iv3t):

# read fixed test case for r-type
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_r = fin.read()
test_str = fin.read()

np.testing.assert_string_equal(test_r, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_VM(dev3T):
Expand All @@ -179,8 +180,8 @@ def test_VM(dev3T):
with open(Path().cwd().joinpath("tests","test_files", vmpp_fname), "r", encoding="utf8") as fin:
test_vmpp = fin.read()

np.testing.assert_string_equal(test_vm, iv3t_vm.__str__())
np.testing.assert_string_equal(test_vmpp, iv3t_vmpp.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_vm), re.sub(r"\s+"," ",iv3t_vm.__str__()))
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_vmpp), re.sub(r"\s+"," ",iv3t_vmpp.__str__()))


def test_CM(dev3T):
Expand Down Expand Up @@ -238,7 +239,7 @@ def test_VI0(dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))


def test_VIpoints(dev3T):
Expand All @@ -265,7 +266,7 @@ def test_VIpoints(dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, iv3t.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",iv3t.__str__()))

# iv3t_vals = np.concatenate([getattr(iv3t,k) for k in iv3t.arraykeys])
# if all(~np.isnan(iv3t_vals)):
Expand All @@ -288,7 +289,7 @@ def test_specialpoints(dev3T):
with open(Path().cwd().joinpath("tests","test_files", test_file), "r", encoding="utf8") as fin:
test_str = fin.read()

np.testing.assert_string_equal(test_str, special_points.__str__())
np.testing.assert_string_equal(re.sub(r"\s+"," ",test_str), re.sub(r"\s+"," ",special_points.__str__()))


if __name__ == "__main__":
Expand Down

0 comments on commit a783f94

Please sign in to comment.