<commit_before>#!/usr/bin/env python3
# coding: utf-8

from sfml import sf

from .types import *


class Movement:
	def __init__(self, vec, duration=sf.Time.ZERO):
		if duration == sf.Time.ZERO:
			self.speed = Vec(*vec)
			self.duration = sf.Time()
			self.duration.microseconds = 1
		else:
			self.speed = Vec(*vec) / duration.seconds
			self.duration = duration

	def __repr__(self):
		return '<Movement {} ending in {}>'.format(self.speed, self.duration)

	@classmethod
	def link(cls, start, dest, duration=sf.Time.ZERO):
		delta = Vec(*dest) - Vec(*start)
		return cls(delta, duration)

	def __bool__(self):
		return bool(self.speed)

	def apply(self, pos, dt):
		"""
		Time-dependent movement of the given position. Returns the remaining
		movement to achieve to finish the movement.

		:param pos: The position to move
		:param dt: The time between the current and the previous frame
		"""

		if self.duration:
			self.duration = max(self.duration - dt, sf.Time.ZERO)
			pos += self.speed * self.duration.seconds

	def terminate(self):
		"""
		Stop the movement.
		"""

		self.duration = sf.Time.ZERO
		self.speed = Vec(0, 0)

	def copy(self):<commit_msg>Add docstring for Movement class<commit_after>#!/usr/bin/env python3
# coding: utf-8

from sfml import sf

from .types import *


class Movement:
	"""
	Linear interpolation movement between two given positions.
	"""

	def __init__(self, vec, duration=sf.Time.ZERO):
		if duration == sf.Time.ZERO:
			self.speed = Vec(*vec)
			self.duration = sf.Time()
			self.duration.microseconds = 1
		else:
			self.speed = Vec(*vec) / duration.seconds
			self.duration = duration

	def __repr__(self):
		return '<Movement {} ending in {}>'.format(self.speed, self.duration)

	@classmethod
	def link(cls, start, dest, duration=sf.Time.ZERO):
		"""
		Creates a Movement object from two points.

		:param start: The starting position
		:param dest: The destination
		:param duration: The duration of the movement
		:return: A Movement object
		"""

		delta = Vec(*dest) - Vec(*start)
		return cls(delta, duration)

	def __bool__(self):
		return bool(self.speed)

	def apply(self, pos, dt):
		"""
		Time-dependent movement of the given position. Returns the remaining
		movement to achieve to finish the movement.

		:param pos: The position to move
		:param dt: The time between the current and the previous frame
		"""

		if self.duration:
			self.duration = max(self.duration - dt, sf.Time.ZERO)
			pos += self.speed * self.duration.seconds

	def terminate(self):
		"""
		Stop the movement.
		"""

		self.duration = sf.Time.ZERO
		self.speed = Vec(0, 0)

	def copy(self):
{'fraction_non_alphanumeric': 0.12371134020618557, 'fraction_numerical': 0.0038182512409316535, 'mean_word_length': 3.5565217391304347, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5652425', 'n_tokens_mistral': 934, 'n_tokens_neox': 840, 'n_words': 265}