Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
assert timing_points_0.offset == timedelta()
assert isclose(timing_points_0.ms_per_beat, 307.692307692308)
assert timing_points_0.meter == 4
# sample_set and sample_type omitted, see #56
assert timing_points_0.volume == 60
# inherited is not in class parameter
assert timing_points_0.kiai_mode == 0
# [Colours] (skipped)
# [HitObjects]
# test first hit_object
hit_objects_0 = beatmap.hit_objects(stacking=False)[0]
assert hit_objects_0.position == Position(x=243, y=164)
assert hit_objects_0.time == timedelta(milliseconds=1076)
# Hit object note `type` is done by subclassing HitObject
assert isinstance(hit_objects_0, slider.beatmap.Slider)
# Slider specific parameters
assert hit_objects_0.end_time == timedelta(milliseconds=1173)
assert hit_objects_0.hitsound == 0
assert isinstance(hit_objects_0.curve, slider.curve.Linear)
assert hit_objects_0.curve.points == [Position(x=243, y=164),
Position(x=301, y=175)]
assert round(hit_objects_0.curve.req_length) == 45
assert isclose(hit_objects_0.length, 45.0000017166138)
assert hit_objects_0.ticks == 2
assert hit_objects_0.num_beats == 0.3125
assert hit_objects_0.tick_rate == 1.0
assert isclose(hit_objects_0.ms_per_beat, 307.692307692308)
assert hit_objects_0.edge_sounds == [2, 0]
assert hit_objects_0.edge_additions == ['0:0', '0:0']
assert hit_objects_0.addition == "0:0:0:0:"
# test stacked hit_objects
except ValueError:
raise ValueError(f'type should be an int, got {time!r}')
try:
type_ = int(type_)
except ValueError:
raise ValueError(f'type should be an int, got {type_!r}')
try:
hitsound = int(hitsound)
except ValueError:
raise ValueError(f'hitsound should be an int, got {hitsound!r}')
if type_ & Circle.type_code:
parse = Circle._parse
elif type_ & Slider.type_code:
parse = partial(
Slider._parse,
timing_points=timing_points,
slider_multiplier=slider_multiplier,
slider_tick_rate=slider_tick_rate,
)
elif type_ & Spinner.type_code:
parse = Spinner._parse
elif type_ & HoldNote.type_code:
parse = HoldNote._parse
else:
raise ValueError(f'unknown type code {type_!r}')
return parse(Position(x, y), time, hitsound, rest)
# event is in hit window and correct location
if isinstance(obj, Circle):
_process_circle(obj, actions[i], hw, scores)
elif isinstance(obj, Slider):
# Head was hit
starti = i
while actions[i].offset <= obj.end_time:
i += 1
_process_slider(
obj, actions[starti:i + 1], True, rad, scores
)
break
i += 1
else:
# no events in the hit window were in the correct location
if isinstance(obj, Slider):
# Slider ticks might still be hit
while actions[i].offset <= obj.end_time:
i += 1
_process_slider(
obj, actions[starti:i + 1], False, rad, scores
)
else:
scores["misses"].append(obj)
i += 1
return scores
try:
type_ = int(type_)
except ValueError:
raise ValueError(f'type should be an int, got {type_!r}')
try:
hitsound = int(hitsound)
except ValueError:
raise ValueError(f'hitsound should be an int, got {hitsound!r}')
if type_ & Circle.type_code:
parse = Circle._parse
elif type_ & Slider.type_code:
parse = partial(
Slider._parse,
timing_points=timing_points,
slider_multiplier=slider_multiplier,
slider_tick_rate=slider_tick_rate,
)
elif type_ & Spinner.type_code:
parse = Spinner._parse
elif type_ & HoldNote.type_code:
parse = HoldNote._parse
else:
raise ValueError(f'unknown type code {type_!r}')
return parse(Position(x, y), time, hitsound, rest)
-------
circles : int
The count of circles.
sliders : int
The count of sliders.
spinners : int
The count of spinners.
"""
circles = 0
sliders = 0
spinners = 0
for hit_object in hit_objects:
if isinstance(hit_object, Circle):
circles += 1
elif isinstance(hit_object, Slider):
sliders += 1
else:
spinners += 1
return hit_object_count(circles, sliders, spinners)
def draw_hitobject(self, hitobj):
"""
Calls corresponding functions to draw a Hitobject.
Args:
QPainter painter: The painter.
Hitobj hitobj: A Hitobject.
"""
if isinstance(hitobj, Circle):
self.draw_hitcircle(hitobj)
self.draw_approachcircle(hitobj)
if isinstance(hitobj, Slider):
self.draw_slider(hitobj)
if isinstance(hitobj, Spinner):
self.draw_spinner(hitobj)
scores['300s'].append(obj)
continue
# we can ignore events before the hit window so iterate
# until we get past the beginning of the hit window
while actions[i].offset < obj.time - hit_50_threshold:
i += 1
starti = i
while actions[i].offset < obj.time + hit_50_threshold:
if (((actions[i].key1 and not actions[i - 1].key1)
or (actions[i].key2 and not actions[i - 1].key2))
and _within(actions[i].position, obj.position, rad)):
# key pressed that wasn't before and
# event is in hit window and correct location
if isinstance(obj, Circle):
_process_circle(obj, actions[i], hw, scores)
elif isinstance(obj, Slider):
# Head was hit
starti = i
while actions[i].offset <= obj.end_time:
i += 1
_process_slider(
obj, actions[starti:i + 1], True, rad, scores
)
break
i += 1
else:
# no events in the hit window were in the correct location
if isinstance(obj, Slider):
# Slider ticks might still be hit
while actions[i].offset <= obj.end_time:
i += 1
_process_slider(
def sliders(self):
"""Just the sliders in the beatmap.
"""
return tuple(e for e in self.hit_objects if isinstance(e, Slider))