Skip to content

Commit

Permalink
remove things named "test_" that are not, in fact, tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
weaverba137 committed Jan 29, 2025
1 parent 14081fb commit 9fff1a3
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 41 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ jobs:
- name: Compile the package
run: CC=g++ CXX=g++ CFLAGS="-fPIC" LDSHARED="g++ -shared" python setup.py build_ext --inplace
- name: Run Tests
run: pytest --ignore=py/fiberassign/test/simulate.py
run: pytest

docs:
name: Doc test
Expand Down
4 changes: 2 additions & 2 deletions py/fiberassign/test/simulate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
TARGET_TYPE_SUPPSKY,
TARGET_TYPE_SUPPSKY, TARGET_TYPE_STANDARD)

test_assign_date = "2020-01-01T00:00:00+00:00"
sim_assign_date = "2020-01-01T00:00:00+00:00"

def sim_data_dir():
dir = "test_fiberassign_output"
Expand All @@ -33,7 +33,7 @@ def sim_data_dir():
return dir


def test_subdir_create(name):
def sim_data_subdir_create(name):
test_dir = os.path.join(sim_data_dir(), name)
if os.path.isdir(test_dir):
shutil.rmtree(test_dir)
Expand Down
26 changes: 13 additions & 13 deletions py/fiberassign/test/test_assign.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@
from fiberassign.scripts.qa_plot import parse_plot_qa, run_plot_qa


from .simulate import (test_subdir_create, sim_tiles, sim_targets,
sim_focalplane, petal_rotation, test_assign_date,
from .simulate import (sim_data_subdir_create, sim_tiles, sim_targets,
sim_focalplane, petal_rotation, sim_assign_date,
sim_stuck_sky)


Expand All @@ -73,7 +73,7 @@ def tearDown(self):

def test_io(self):
np.random.seed(123456789)
test_dir = test_subdir_create("assign_test_io")
test_dir = sim_data_subdir_create("assign_test_io")
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
input_sky = os.path.join(test_dir, "sky.fits")
Expand Down Expand Up @@ -115,10 +115,10 @@ def test_io(self):
load_target_file(tgs, tagalong, input_suppsky)

# Compute the targets available to each fiber for each tile.
fp, exclude, state = sim_focalplane(rundate=test_assign_date)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date)
hw = load_hardware(
focalplane=(fp, exclude, state),
rundate=test_assign_date
rundate=sim_assign_date
)
tfile = os.path.join(test_dir, "footprint.fits")
sim_tiles(tfile)
Expand Down Expand Up @@ -285,7 +285,7 @@ def test_stucksky(self):
return self.test_full(do_stucksky=True)

def test_full(self, do_stucksky=False):
test_dir = test_subdir_create("assign_test_full")
test_dir = sim_data_subdir_create("assign_test_full")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -328,8 +328,8 @@ def test_full(self, do_stucksky=False):
load_target_file(tgs, tagalong, input_suppsky)

# Read hardware properties
fp, exclude, state = sim_focalplane(rundate=test_assign_date)
hw = load_hardware(focalplane=(fp, exclude, state), rundate=test_assign_date)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date)
hw = load_hardware(focalplane=(fp, exclude, state), rundate=sim_assign_date)
tfile = os.path.join(test_dir, "footprint.fits")
sim_tiles(tfile)
tiles = load_tiles(tiles_file=tfile)
Expand Down Expand Up @@ -394,7 +394,7 @@ def test_full(self, do_stucksky=False):
return

def test_cli(self):
test_dir = test_subdir_create("assign_test_cli")
test_dir = sim_data_subdir_create("assign_test_cli")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -439,7 +439,7 @@ def test_cli(self):
"standards_per_petal": 10,
"sky_per_petal": 40,
"overwrite": True,
"rundate": test_assign_date
"rundate": sim_assign_date
}
optlist = option_list(opts)
args = parse_assign(optlist)
Expand Down Expand Up @@ -482,7 +482,7 @@ def test_cli(self):
return

def test_fieldrot(self):
test_dir = test_subdir_create("assign_test_fieldrot")
test_dir = sim_data_subdir_create("assign_test_fieldrot")
np.random.seed(123456789)
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
Expand Down Expand Up @@ -544,12 +544,12 @@ def test_fieldrot(self):
tile_ids = list(tiles.id)

# Simulate a fake focalplane
fp, exclude, state = sim_focalplane(rundate=test_assign_date, fakepos=True)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date, fakepos=True)

# Load the focalplane
hw = load_hardware(
focalplane=(fp, exclude, state),
rundate=test_assign_date
rundate=sim_assign_date
)

# Precompute target positions
Expand Down
14 changes: 7 additions & 7 deletions py/fiberassign/test/test_hardware.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

from fiberassign.hardware import load_hardware

from .simulate import test_assign_date
from .simulate import sim_assign_date


class TestHardware(unittest.TestCase):
Expand All @@ -26,7 +26,7 @@ def tearDown(self):
pass

def test_read(self):
hw = load_hardware(rundate=test_assign_date)
hw = load_hardware(rundate=sim_assign_date)
print(hw)
locs = hw.locations
cs5 = hw.loc_pos_cs5_mm
Expand All @@ -38,7 +38,7 @@ def test_read(self):
return

def test_collision_xy(self):
hw = load_hardware(rundate=test_assign_date)
hw = load_hardware(rundate=sim_assign_date)
center_mm = hw.loc_pos_curved_mm
locs = hw.locations
nrot = 100
Expand All @@ -57,7 +57,7 @@ def test_collision_xy(self):
return

def test_collision_thetaphi(self):
hw = load_hardware(rundate=test_assign_date)
hw = load_hardware(rundate=sim_assign_date)
locs = hw.locations
ntheta = 10
nphi = 10
Expand Down Expand Up @@ -137,7 +137,7 @@ def check_reachable(hrdw, radius, increments, log_fail=True):
return n_failed

# Test nominal focalplane
hw = load_hardware(rundate=test_assign_date)
hw = load_hardware(rundate=sim_assign_date)
failed = check_reachable(hw, 3.0, 100)
if (failed > 0):
print(
Expand All @@ -150,7 +150,7 @@ def check_reachable(hrdw, radius, increments, log_fail=True):

# Now we are going to artificially restrict the phi angle range and test that
# we cannot access the outer areas of the patrol radius.
runtime = datetime.strptime(test_assign_date, "%Y-%m-%dT%H:%M:%S%z")
runtime = datetime.strptime(sim_assign_date, "%Y-%m-%dT%H:%M:%S%z")
fp, exclude, state, tmstr = dmio.load_focalplane(runtime)

# make a copy so that we aren't modifying the desimodel cache
Expand Down Expand Up @@ -278,7 +278,7 @@ def check_positioner(hrdw, radius, increments, log_fail=True):
return n_failed

# Test nominal focalplane
hw = load_hardware(rundate=test_assign_date)
hw = load_hardware(rundate=sim_assign_date)
failed = check_positioner(hw, 3.0, 100)
if (failed > 0):
print(
Expand Down
4 changes: 2 additions & 2 deletions py/fiberassign/test/test_qa.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@


from .simulate import (test_subdir_create, sim_tiles, sim_targets,
sim_focalplane, petal_rotation, test_assign_date)
sim_focalplane, petal_rotation, sim_assign_date)


class TestQA(unittest.TestCase):
Expand Down Expand Up @@ -122,7 +122,7 @@ def test_science(self):
load_target_file(tgs, tagalong, input_mtl)

# Read hardware properties
fp, exclude, state = sim_focalplane(rundate=test_assign_date)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date)
hw = load_hardware(focalplane=(fp, exclude, state))
tfile = os.path.join(test_dir, "footprint.fits")
sim_tiles(tfile)
Expand Down
4 changes: 2 additions & 2 deletions py/fiberassign/test/test_targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
Targets, TargetsAvailable,
LocationsAvailable, targets_in_tiles, create_tagalong)

from .simulate import (test_subdir_create, sim_tiles, sim_targets, test_assign_date)
from .simulate import sim_data_subdir_create, sim_tiles, sim_targets


class TestTargets(unittest.TestCase):
Expand All @@ -38,7 +38,7 @@ def tearDown(self):
pass

def test_available(self):
test_dir = test_subdir_create("targets_test_available")
test_dir = sim_data_subdir_create("targets_test_available")
input_mtl = os.path.join(test_dir, "mtl.fits")
input_std = os.path.join(test_dir, "standards.fits")
input_sky = os.path.join(test_dir, "sky.fits")
Expand Down
8 changes: 2 additions & 6 deletions py/fiberassign/test/test_tiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,7 @@

from fiberassign.tiles import load_tiles

from .simulate import (
test_subdir_create,
sim_tiles,
test_assign_date
)
from .simulate import sim_data_subdir_create, sim_tiles

from astropy.table import Table
from astropy.time import Time
Expand All @@ -29,7 +25,7 @@ def tearDown(self):
pass

def test_read(self):
test_dir = test_subdir_create("tiles_test_read")
test_dir = sim_data_subdir_create("tiles_test_read")
print('test_dir', test_dir)
hw = load_hardware()
tfile = os.path.join(test_dir, "footprint.fits")
Expand Down
16 changes: 8 additions & 8 deletions py/fiberassign/test/test_vis.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
set_matplotlib_pdf_backend
)

from .simulate import test_subdir_create, sim_focalplane, test_assign_date
from .simulate import sim_data_subdir_create, sim_focalplane, sim_assign_date

set_matplotlib_pdf_backend()
import matplotlib.pyplot as plt
Expand Down Expand Up @@ -145,8 +145,8 @@ def _load_and_plotpos(self, time, dir, suffix, simple=False):
plt.close()

def test_plotpos(self):
test_dir = test_subdir_create("vis_test_plotpos")
time = test_assign_date
test_dir = sim_data_subdir_create("vis_test_plotpos")
time = sim_assign_date
suffix = "{}_simple".format(time)
self._load_and_plotpos(time, test_dir, suffix, simple=True)
suffix = "{}".format(time)
Expand Down Expand Up @@ -221,8 +221,8 @@ def _load_and_plotfp(self, hw, dir, suffix, simple=False):
plt.close()

def test_plotfp(self):
test_dir = test_subdir_create("vis_test_plotfp")
time = test_assign_date
test_dir = sim_data_subdir_create("vis_test_plotfp")
time = sim_assign_date
hw = load_hardware(rundate=time)
suffix = "{}_simple".format(time)
self._load_and_plotfp(hw, test_dir, suffix, simple=True)
Expand All @@ -237,11 +237,11 @@ def test_plotfp(self):
return

def test_plot_fakefp(self):
test_dir = test_subdir_create("vis_test_fakefp")
time = test_assign_date
test_dir = sim_data_subdir_create("vis_test_fakefp")
time = sim_assign_date

# Simulate a fake focalplane
fp, exclude, state = sim_focalplane(rundate=test_assign_date, fakepos=True)
fp, exclude, state = sim_focalplane(rundate=sim_assign_date, fakepos=True)

# Load the focalplane
hw = load_hardware(focalplane=(fp, exclude, state))
Expand Down

0 comments on commit 9fff1a3

Please sign in to comment.