Skip to content

Commit

Permalink
clean up tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Taoning Wang committed Oct 26, 2023
1 parent d7bf1c5 commit 08bc9b7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 34 deletions.
11 changes: 5 additions & 6 deletions test/test_eplus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,17 @@
from pyenergyplus.dataset import ref_models
import pytest

test_dir = Path(__file__).resolve().parent
resource_dir = test_dir / "Resources"

idf_path = resource_dir / "RefBldgMediumOfficeNew2004_southzone.idf"
glazing_path = resource_dir / "igsdb_product_7406.json"

@pytest.fixture
def medium_office():
return load_energyplus_model(ref_models["medium_office"])

@pytest.fixture
def glazing_path(resources_dir):
return resources_dir / "igsdb_product_7406.json"


def test_add_glazingsystem(medium_office):
def test_add_glazingsystem(medium_office, glazing_path):
gs = create_glazing_system(
name="test",
layers=[glazing_path],
Expand Down
46 changes: 26 additions & 20 deletions test/test_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,29 +2,35 @@
from frads import geom, matrix
import pyradiance as pr
import numpy as np
import pytest

window_polygon = [
geom.Polygon([np.array((0, 0, 0)),
np.array((0, 0, 3)),
np.array((2, 0, 3)),
np.array((2, 0, 0)),
]),
geom.Polygon([np.array((3, 0, 0)),
np.array((3, 0, 3)),
np.array((5, 0, 3)),
np.array((5, 0, 0)),
])
]
window_primitives = [
pr.Primitive("void", "polygon", "window1", ("0"), window_polygon[0].coordinates),
pr.Primitive("void", "polygon", "window2", ("0"), window_polygon[1].coordinates)
]
@pytest.fixture
def window_polygon():
return [
geom.Polygon([np.array((0, 0, 0)),
np.array((0, 0, 3)),
np.array((2, 0, 3)),
np.array((2, 0, 0)),
]),
geom.Polygon([np.array((3, 0, 0)),
np.array((3, 0, 3)),
np.array((5, 0, 3)),
np.array((5, 0, 0)),
])
]

def test_surface_as_sender():
@pytest.fixture
def window_primitives(window_polygon):
return [
pr.Primitive("void", "polygon", "window1", ("0"), window_polygon[0].coordinates),
pr.Primitive("void", "polygon", "window2", ("0"), window_polygon[1].coordinates)
]

def test_surface_as_sender(window_primitives):
basis = "kf"
sender = matrix.SurfaceSender(
window_primitives,
basis,
window_primitives,
basis,
)
assert sender.basis == "kf"
assert sender.content is not None
Expand All @@ -48,7 +54,7 @@ def test_point_as_sender():
sender = matrix.SensorSender(pts_list, ray_cnt)
assert sender.yres == len(pts_list)

def test_surface_as_receiver():
def test_surface_as_receiver(window_primitives):
basis = "kf"
out = None
offset = 0.1
Expand Down
10 changes: 2 additions & 8 deletions test/test_methods.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
from frads.window import create_glazing_system, Gap, Gas
from frads.ep2rad import epmodel_to_radmodel
from frads.eplus import load_energyplus_model
import frads as fr
import numpy as np
import pytest
from pyenergyplus.dataset import ref_models, weather_files
import pyradiance as pr
Expand Down Expand Up @@ -72,17 +70,14 @@ def test_two_phase(cfg):
assert res.shape == (195, 1)


def test_three_phase(cfg, resources_dir, objects_dir):
def test_three_phase(cfg, resources_dir):
time = datetime(2023, 1, 1, 12)
dni = 800
dhi = 100
config = WorkflowConfig.from_dict(cfg)
lower_glass = objects_dir / "lower_glass.rad"
upper_glass = objects_dir / "upper_glass.rad"
blind_prim = pr.Primitive(
"void", "aBSDF", "blinds30", [str(resources_dir/"blinds30.xml"), "0", "0", "1", "."], [])
config.model.windows["lower_glass"].glazing_material = {"blinds30": blind_prim}
config.model.windows["upper_glass"].glazing_material = {"blinds30": blind_prim}
config.model.materials.glazing_materials = {"blinds30": blind_prim}
with ThreePhaseMethod(config) as workflow:
workflow.generate_matrices(view_matrices=False)
workflow.calculate_sensor(
Expand All @@ -109,7 +104,6 @@ def test_eprad_threephase(resources_dir):
view_path = resources_dir / "view1.vf"
clear_glass_path = resources_dir / "CLEAR_3.DAT"
product_7406_path = resources_dir / "igsdb_product_7406.json"
shade_path = resources_dir / "ec60.rad"
shade_bsdf_path = resources_dir / "ec60.xml"

epmodel = load_energyplus_model(ref_models["medium_office"])
Expand Down

0 comments on commit 08bc9b7

Please sign in to comment.