def test_relax_map(self):
        settings = StdScoreData.Settings()
        settings.neg_hit_miss_range = 100   # ms point of early miss window
        settings.neg_hit_range      = 100   # ms point of early hit window
        settings.pos_hit_range      = 100   # ms point of late hit window
        settings.pos_hit_miss_range = 100   # ms point of late miss window

        settings.require_tap_press   = False
        settings.require_tap_hold    = False
        settings.require_tap_release = False

        beatmap = BeatmapIO.open_beatmap('unit_tests/maps/osu/test/relax_map.osu')
        map_data = StdMapData.get_map_data(beatmap)

        replay = ReplayIO.open_replay('unit_tests/replays/osu/score_test/relax_map_fc.osr')
        replay_data = StdReplayData.get_replay_data(replay)
        score_data = StdScoreData.get_score_data(replay_data, map_data, settings)

        # No misses in this play
        self.assertTrue(not any(score_data['type'] == StdScoreData.TYPE_MISS))

        beatmap = BeatmapIO.open_beatmap('unit_tests/maps/osu/test/relax_map2.osu')
        map_data = StdMapData.get_map_data(beatmap)

        replay = ReplayIO.open_replay('unit_tests/replays/osu/score_test/relax_map2_fc.osr')
        replay_data = StdReplayData.get_replay_data(replay)
        score_data = StdScoreData.get_score_data(replay_data, map_data, settings)

        # This play has 1 miss aim
        miss_count = np.count_nonzero(score_data['type'].values == StdScoreData.TYPE_MISS)
        self.assertTrue(miss_count == 1)
    def test_get_scorepoint_after(self):
        # Time: Before start
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 0)
        self.assertEqual(scorepoint_data['time'], 100)

        # Time: At first aimpoint
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 100)
        self.assertEqual(scorepoint_data['time'], 200)

        # Time: At second aimpoint
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 200)
        self.assertEqual(scorepoint_data['time'], 300)

        # Time: At slider release
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 400)
        self.assertEqual(scorepoint_data['time'], 1100)

        # Time: At 2nd hitobject
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 1100)
        self.assertEqual(scorepoint_data['time'], 1101)

        # Time: At last hitobject
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 2100)
        self.assertEqual(scorepoint_data['time'], 2101)

        # Time: After last hitobject
        scorepoint_data = StdMapData.get_scorepoint_after(self.map_data, 2200)
        self.assertEqual(scorepoint_data, None)
    def test_get_note_after(self):
        # Time: Before start
        hitobject_data = StdMapData.get_note_after(self.map_data, 0)
        self.assertEqual(hitobject_data.iloc[0]['time'], 100)

        # Time: At first aimpoint
        hitobject_data = StdMapData.get_note_after(self.map_data, 100)
        self.assertEqual(hitobject_data.iloc[0]['time'], 1100)

        # Time: At second aimpoint
        hitobject_data = StdMapData.get_note_after(self.map_data, 200)
        self.assertEqual(hitobject_data.iloc[0]['time'], 1100)

        # Time: At slider release
        hitobject_data = StdMapData.get_note_after(self.map_data, 400)
        self.assertEqual(hitobject_data.iloc[0]['time'], 1100)

        # Time: At 2nd hitobject
        hitobject_data = StdMapData.get_note_after(self.map_data, 1100)
        self.assertEqual(hitobject_data.iloc[0]['time'], 2100)

        # Time: At last hitobject
        hitobject_data = StdMapData.get_note_after(self.map_data, 2100)
        self.assertEqual(hitobject_data, None)

        # Time: After last hitobject
        hitobject_data = StdMapData.get_note_after(self.map_data, 2101)
        self.assertEqual(hitobject_data, None)
    def test_nm_map(self):
        settings = StdScoreData.Settings()
        settings.neg_hit_miss_range = 100   # ms point of early miss window
        settings.neg_hit_range      = 100   # ms point of early hit window
        settings.pos_hit_range      = 100   # ms point of late hit window
        settings.pos_hit_miss_range = 100   # ms point of late miss window

        beatmap = BeatmapIO.open_beatmap('unit_tests/maps/osu/test/score_test_basic_AR8,OD5,CS2.osu')
        map_data = StdMapData.get_map_data(beatmap)

        # The map is SS'd in this replay
        replay = ReplayIO.open_replay('unit_tests/replays/osu/score_test_new/score_test_basic_AR8,OD5,CS2_7,1,0,0,0,0,100p.osr')
        replay_data = StdReplayData.get_replay_data(replay)
        score_data = StdScoreData.get_score_data(replay_data, map_data)

        offsets = score_data['map_t'] - score_data['replay_t']

        self.assertTrue(not any(score_data['type'] == StdScoreData.TYPE_MISS))
        self.assertTrue(all(abs(offsets) <= 50))
 def test_get_releases(self):
     map_data = StdMapData.get_map_data(self.beatmap)
     presses = StdMapData.get_releases(map_data)
 def test_get_num_hitobjects(self):
     map_data = StdMapData.get_map_data(self.beatmap)
     num_hitobjects = StdMapData.get_num_hitobjects(map_data)
 def test_get_map_data(self):
     map_data = StdMapData.get_map_data(self.beatmap)
 def test_end_times(self):
     map_data = StdMapData.get_map_data(self.beatmap)
     end_times = StdMapData.end_times(map_data)
 def test_start_times(self):
     map_data = StdMapData.get_map_data(self.beatmap)
     start_times = StdMapData.start_times(map_data)
    def test_time_slice(self):
        map_data = StdMapData.get_map_data(self.beatmap)
        map_data = StdMapData.time_slice(map_data, 1000, 2000, True)

        self.assertGreaterEqual(map_data['time'].values[0], 1000)
        self.assertLessEqual(map_data['time'].values[0], 2000)
 def test_get_visible_at(self):
     for time in range(-1000, 10000, 100):
         visible = StdMapData.get_visible_at(self.map_data, time, 400)
 def setUpClass(cls):
     cls.beatmap = BeatmapIO.open_beatmap(
         'unit_tests\\maps\\osu\\test\\abraker - unknown (abraker) [250ms].osu'
     )
     cls.map_data = StdMapData.get_map_data(cls.beatmap)