Skip to content

Commit

Permalink
Merge pull request #348 from HERA-Team/fix-load-from-yaml-test
Browse files Browse the repository at this point in the history
test: fix path in broken test
  • Loading branch information
steven-murray authored Jan 20, 2025
2 parents 83237c5 + 87e220c commit 55c1875
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/hera_sim/cli_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,11 +133,11 @@ def write_calfits(
if isinstance(sim, Simulator):
freqs = sim.freqs * 1e9
times = sim.times
sim_x_orientation = sim.data.x_orientation
sim_x_orientation = sim.data.telescope.x_orientation
else:
freqs = np.unique(sim.freq_array)
times = np.unique(sim.time_array)
sim_x_orientation = sim.x_orientation
sim_x_orientation = sim.telescope.x_orientation
if sim_x_orientation is None:
warnings.warn(
"x_orientation not specified in simulation object."
Expand Down
4 changes: 2 additions & 2 deletions src/hera_sim/io.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ def empty_uvdata(
uvd.fix_phase()

# TODO: the following is a hack patch for pyuvsim which should be fixed there.
if "x_orientation" in kwargs and uvd.x_orientation is None:
uvd.x_orientation = kwargs["x_orientation"]
if "x_orientation" in kwargs and uvd.telescope.x_orientation is None:
uvd.telescope.x_orientation = kwargs["x_orientation"]

if conjugation is not None:
uvd.conjugate_bls(convention=conjugation)
Expand Down
10 changes: 10 additions & 0 deletions src/hera_sim/tests/conftest.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import pytest
from astropy.time import Time
from astropy.utils import iers
Expand All @@ -19,3 +21,11 @@ def setup_and_teardown_package():
yield

iers.conf.auto_max_age = 30

@pytest.fixture(scope='session')
def repodir() -> Path:
return Path(__file__).parent.parent.parent.parent

@pytest.fixture(scope='session')
def exampledir(repodir: Path) -> Path:
return repodir / 'config_examples'
7 changes: 3 additions & 4 deletions src/hera_sim/tests/test_visibilities/test_matvis.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,12 @@ def test_stokespol(uvdata_linear, sky_model):
)


def test_load_from_yaml(tmpdir):
example_dir = Path(__file__).parent.parent.parent.parent / "config_examples"
def test_load_from_yaml(exampledir: Path):

simulator = load_simulator_from_yaml(example_dir / "simulator.yaml")
simulator = load_simulator_from_yaml(exampledir / "simulator.yaml")
assert isinstance(simulator, MatVis)
assert simulator._precision==2

sim2 = MatVis.from_yaml(example_dir / "simulator.yaml")
sim2 = MatVis.from_yaml(exampledir / "simulator.yaml")

assert sim2.diffuse_ability == simulator.diffuse_ability

0 comments on commit 55c1875

Please sign in to comment.