# Path: py/fiberassign/test/simulate.py
# def sim_data_dir():
# def test_subdir_create(name):
# def sim_science_fractions():
# def sim_focalplane(rundate=None, fakepos=False):
# def sim_stuck_sky(dirnm, hw, tiles):
#     def radec2xyz(r, d):
# def sim_tiles(path, selectfile=None):
# def sim_targets(path, tgtype, tgoffset, density=5000.0, science_frac=None):
# def petal_rotation(npos, reverse=False):
#         J = np.flatnonzero(r2 < maxr2)


import unittest
import numpy as np
import desimodel.io as dmio
from datetime import datetime
from fiberassign.utils import Timer
from fiberassign.hardware import load_hardware
from .simulate import test_assign_date
        print(hw)
        locs = hw.locations
        cs5 = hw.loc_pos_cs5_mm
        curved = hw.loc_pos_curved_mm
        # for p in locs:
        #     print("{}: curved = [{}, {}] cs5 = [{}, {}]".format(
        #         p, curved[p][0], curved[p][1], cs5[p][0], cs5[p][1]
        #     ))
        return

    def test_collision_xy(self):
        hw = load_hardware(rundate=test_assign_date)
        center_mm = hw.loc_pos_curved_mm
        locs = hw.locations
        nrot = 100
        rotrad = 0.5
        rotincr = 2 * np.pi / nrot
        tm = Timer()
        tm.start()
        for rot in range(nrot):
            xoff = rotrad * np.cos(rot * rotincr)
            yoff = rotrad * np.sin(rot * rotincr)
            xy = [(center_mm[p][0] + xoff, center_mm[p][1] + yoff)
                  for p in locs]
            result = hw.check_collisions_xy(locs, xy, 0)
        tm.stop()
        tm.report("check_collisions_xy 100 configurations")
        return

    def test_collision_thetaphi(self):

# Path: py/fiberassign/test/simulate.py
# def sim_data_dir():
# def test_subdir_create(name):
# def sim_science_fractions():
# def sim_focalplane(rundate=None, fakepos=False):
# def sim_stuck_sky(dirnm, hw, tiles):
#     def radec2xyz(r, d):
# def sim_tiles(path, selectfile=None):
# def sim_targets(path, tgtype, tgoffset, density=5000.0, science_frac=None):
# def petal_rotation(npos, reverse=False):
#         J = np.flatnonzero(r2 < maxr2)


# Path: py/fiberassign/test/test_hardware.py
import unittest
import numpy as np
import desimodel.io as dmio
from datetime import datetime
from fiberassign.utils import Timer
from fiberassign.hardware import load_hardware
from .simulate import test_assign_date

        print(hw)
        locs = hw.locations
        cs5 = hw.loc_pos_cs5_mm
        curved = hw.loc_pos_curved_mm
        # for p in locs:
        #     print("{}: curved = [{}, {}] cs5 = [{}, {}]".format(
        #         p, curved[p][0], curved[p][1], cs5[p][0], cs5[p][1]
        #     ))
        return

    def test_collision_xy(self):
        hw = load_hardware(rundate=test_assign_date)
        center_mm = hw.loc_pos_curved_mm
        locs = hw.locations
        nrot = 100
        rotrad = 0.5
        rotincr = 2 * np.pi / nrot
        tm = Timer()
        tm.start()
        for rot in range(nrot):
            xoff = rotrad * np.cos(rot * rotincr)
            yoff = rotrad * np.sin(rot * rotincr)
            xy = [(center_mm[p][0] + xoff, center_mm[p][1] + yoff)
                  for p in locs]
            result = hw.check_collisions_xy(locs, xy, 0)
        tm.stop()
        tm.report("check_collisions_xy 100 configurations")
        return

    def test_collision_thetaphi(self):

        hw = load_hardware(rundate=test_assign_date)