示例#1
0
    def ur(self, replay, cv=True) -> float:
        """
        The unstable rate of ``replay``.

        Parameters
        ----------
        replay: :class:`~circleguard.loadables.Replay`
            The replay to calculate the ur of.
        cv: bool
            Whether to return the converted or unconverted ur. The converted ur
            is returned by default.

        Returns
        -------
        float
            The ur of the replay.
        """
        self.load(replay)
        if not replay.map_info.available():
            raise ValueError("The ur of a replay that does not know what map "
                "it was set on cannot be calculated")

        beatmap = self.beatmap(replay)
        ur = Investigator.ur(replay, beatmap)
        if cv:
            ur = convert_statistic(ur, replay.mods, to="cv")

        return ur
示例#2
0
    def frametimes(self, replay, cv=True, mods_unknown="raise") \
        -> Iterable[float]:
        """
        The time (in ms) between each frame in ``replay``.

        Parameters
        ----------
        replay: :class:`~circleguard.loadables.Replay`
            The replay to calculate the time between each frame of.
        cv: bool
            Whether to return the converted or unconverted frametimes. The
            converted frametimes is returned by default.
        mods_unknown: {"raise", "dt", "nm", "ht"}
            What to do if ``replay`` does not know what mods it was played with,
            and ``cv`` is ``True``.
            |br|
            If ``raise``, a ValueError will be raised.
            |br|
            If ``dt``, the frametime swill be converted as if the replay was
            played with ``Mod.DT``.
            |br|
            If ``nm``, the frametimes will be converted as if the replay was
            played  with ``Mod.NM`` (that is, not converted at all).
            |br|
            If ``ht``, the frametimes will be converted as if the replay was
            played with ``Mod.HT``.

        Returns
        -------
        [float]
            The time (in ms) between each frame of the replay.
            |br|
            The first element of this array corresponds to the time between the
            first and second frame, the second element to the time between the
            second and third frame, etc.
        """
        self.load(replay)
        frametimes = Investigator.frametimes(replay)
        if cv:
            if replay.mods:
                mods = replay.mods
            elif mods_unknown == "dt":
                mods = Mod.DT
            elif mods_unknown == "nm":
                mods = Mod.NM
            elif mods_unknown == "ht":
                mods = Mod.HT
            else:
                raise ValueError("The frametimes of a replay that does not "
                    "know with what mods it was set with cannot be converted. "
                    "Pass a different option to frametime(..., mods_unknown=) "
                    "if you would like to provide a default mod for "
                    "conversion.")
            frametimes = convert_statistic(frametimes, mods, to="cv")
        return frametimes
示例#3
0
    def frametime(self, replay, cv=True, mods_unknown="raise") -> float:
        """
        The median frametime (in ms) of ``replay``.

        Parameters
        ----------
        replay: :class:`~circleguard.loadables.Replay`
            The replay to calculate the median frametime of.
        cv: bool
            Whether to return the converted or unconverted frametime. The
            converted frametime is returned by default.
        mods_unknown: {"raise", "dt", "nm", "ht"}
            What to do if ``replay`` does not know what mods it was played with,
            and ``cv`` is ``True``.
            |br|
            If ``raise``, a ValueError will be raised.
            |br|
            If ``dt``, the frametime will be converted as if the replay was
            played with ``Mod.DT``.
            |br|
            If ``nm``, the frametime will be converted as if the replay was
            played  with ``Mod.NM`` (that is, not converted at all).
            |br|
            If ``ht``, the frametime will be converted as if the replay was
            played with ``Mod.HT``.

        Returns
        -------
        float
            The median frametime (in ms) of the replay.
        """
        check_param(mods_unknown, ["raise", "dt", "nm", "ht"])

        self.load(replay)
        frametime = Investigator.frametime(replay)
        if cv:
            if replay.mods:
                mods = replay.mods
            elif mods_unknown == "dt":
                mods = Mod.DT
            elif mods_unknown == "nm":
                mods = Mod.NM
            elif mods_unknown == "ht":
                mods = Mod.HT
            else:
                raise ValueError("The frametime of a replay that does not know "
                    "with what mods it was set with cannot be converted. Pass "
                    "a different option to frametime(..., mods_unknown=) if "
                    "you would like to provide a default mod for conversion.")
            frametime = convert_statistic(frametime, mods, to="cv")

        return frametime
示例#4
0
    def ur(self, replay, cv=True, beatmap=None) -> float:
        """
        The unstable rate of ``replay``.

        Parameters
        ----------
        replay: :class:`~circleguard.loadables.Replay`
            The replay to calculate the ur of.
        cv: bool
            Whether to return the converted or unconverted ur. The converted ur
            is returned by default.
        beatmap: :class:`slider.beatmap.Beatmap`
            The beatmap to use to calculate ur for the ``replay``, instead of
            retrieving a beatmap from the replay itself.
            |br|
            This parameter is provided primarily as an optimization for when you
            already have the replay's beatmap, to avoid re-retrieving it in this
            method.

        Returns
        -------
        float
            The ur of the replay.
        """
        self.load(replay)

        beatmap = beatmap or self.beatmap(replay)
        if not beatmap:
            raise ValueError("The ur of a replay that does not know what map "
                "it was set on cannot be calculated")

        ur = Investigations.ur(replay, beatmap)
        if cv:
            ur = convert_statistic(ur, replay.mods, to="cv")

        return ur
示例#5
0
 def __init__(self, replay: Replay, frametime: float, frametimes: list):
     super().__init__(replay, ResultType.TIMEWARP)
     self.frametime = convert_statistic(frametime, replay.mods, to="cv")
     self.frametimes = frametimes
     self.ucv_frametime = frametime
示例#6
0
 def __init__(self, replay: Replay, ur: float):
     super().__init__(replay, ResultType.RELAX)
     self.ur = convert_statistic(ur, replay.mods, to="cv")
     self.ucv_ur = ur