Skip to main content

osu! difficulty and pp calculation for all modes

Project description

akatsuki-pp-py

Difficulty and performance calculation for all osu! modes.

This is a python binding to the Rust library rosu-pp which was bootstrapped through PyO3. Since all the heavy lifting is done by Rust, rosu-pp-py comes with a very fast performance. Check out rosu-pp's README for more info.

Exposed types

The library exposes the following classes:

  • Calculator: Contains various parameters to calculate strains or map, difficulty, or performance attributes
  • Beatmap: Contains a parsed beatmap
  • BeatmapAttributes: Contains various attributes about the map itself
  • DifficultyAttributes: Contains various attributes about the difficulty based on the mode
  • PerformanceAttributes: Contains various attributes about the performance and difficulty based on the mode
  • Strains: Contains strain values for each skill based on the mode

Additionally, the following error types are exposed:

  • ParseError: Failed to parse a beatmap
  • KwargsError: Invalid kwargs were provided

How to use akatsuki-pp-py

  1. The first step is to create a new Beatmap instance by providing appropriate kwargs. Either of the kwargs path, content, or bytes must be given. The kwargs ar, cs, hp, and od are optional. With the setters set_ar, set_cs, set_hp, and set_od you can specify custom attributes.
map = Beatmap(path = "/path/to/file.osu", ar = 9.87)
map.set_od(1.23)

with open("/path/to/file.osu", "rb") as file:
    map = Beatmap(bytes = file.read())

with open("/path/to/file.osu") as file:
    map = Beatmap(content = file.read())
  1. Next, you need to create an instance of Calculator by providing the appropriate kwargs again. Any of the following kwargs are allowed: mode, mods, acc, n_geki, n_katu, n300, n100, n50, n_misses, combo, passed_objects, clock_rate, and difficulty. Each of these also have a setter method e.g. set_n_misses.
calc = Calculator(mode = 2, acc = 98.76)
calc.set_mods(8 + 64) # HDDT
  1. The last step is to call any of the methods map_attributes, difficulty, performance, or strains on the calculator and provide them a Beatmap.

Example

from akatsuki_pp_py import Beatmap, Calculator

map = Beatmap(path = "./maps/100.osu")
calc = Calculator(mods = 8)

# Calculate an SS on HD
max_perf = calc.performance(map)

# The mods are still set to HD
calc.set_acc(99.11)
calc.set_n_misses(1)
calc.set_combo(200)

# A good way to speed up the calculation is to provide
# the difficulty attributes of a previous calculation
# so that they don't need to be recalculated.
# **Note** that this should only be done if neither
# the map, mode, mods, nor passed objects amount changed.
calc.set_difficulty(max_perf.difficulty)

curr_perf = calc.performance(map)
print(f'PP: {curr_perf.pp}/{max_perf.pp} | Stars: {max_perf.difficulty.stars}')

map_attrs = calc.map_attributes(map)
print(f'BPM: {map_attrs.bpm}')

strains = calc.strains(map)
print(f'Maximum aim strain: {max(strains.aim)}')

Installing rosu-pp-py

Installing rosu-pp-py requires a supported version of Python and Rust.

Once Python and Rust and ready to go, you can install the project with pip:

$ pip install akatsuki-pp-py

or

$ pip install git+https://github.com/osuAkatsuki/akatsuki-pp-py

Learn More

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

akatsuki_pp_py-1.0.1.tar.gz (17.9 kB view hashes)

Uploaded Source

Built Distributions

akatsuki_pp_py-1.0.1-cp311-none-win_amd64.whl (357.7 kB view hashes)

Uploaded CPython 3.11 Windows x86-64

akatsuki_pp_py-1.0.1-cp311-none-win32.whl (344.0 kB view hashes)

Uploaded CPython 3.11 Windows x86

akatsuki_pp_py-1.0.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (470.4 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ x86-64

akatsuki_pp_py-1.0.1-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.5 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.17+ ARM64

akatsuki_pp_py-1.0.1-cp311-cp311-manylinux_2_5_i686.manylinux1_i686.whl (478.7 kB view hashes)

Uploaded CPython 3.11 manylinux: glibc 2.5+ i686

akatsuki_pp_py-1.0.1-cp311-cp311-macosx_10_12_x86_64.whl (435.1 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ x86-64

akatsuki_pp_py-1.0.1-cp311-cp311-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (838.5 kB view hashes)

Uploaded CPython 3.11 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

akatsuki_pp_py-1.0.1-cp310-none-win_amd64.whl (357.7 kB view hashes)

Uploaded CPython 3.10 Windows x86-64

akatsuki_pp_py-1.0.1-cp310-none-win32.whl (344.0 kB view hashes)

Uploaded CPython 3.10 Windows x86

akatsuki_pp_py-1.0.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (470.4 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ x86-64

akatsuki_pp_py-1.0.1-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.5 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.17+ ARM64

akatsuki_pp_py-1.0.1-cp310-cp310-manylinux_2_5_i686.manylinux1_i686.whl (478.7 kB view hashes)

Uploaded CPython 3.10 manylinux: glibc 2.5+ i686

akatsuki_pp_py-1.0.1-cp310-cp310-macosx_10_12_x86_64.whl (435.1 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ x86-64

akatsuki_pp_py-1.0.1-cp310-cp310-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (838.5 kB view hashes)

Uploaded CPython 3.10 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

akatsuki_pp_py-1.0.1-cp39-none-win_amd64.whl (357.8 kB view hashes)

Uploaded CPython 3.9 Windows x86-64

akatsuki_pp_py-1.0.1-cp39-none-win32.whl (344.0 kB view hashes)

Uploaded CPython 3.9 Windows x86

akatsuki_pp_py-1.0.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (470.4 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ x86-64

akatsuki_pp_py-1.0.1-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.5 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.17+ ARM64

akatsuki_pp_py-1.0.1-cp39-cp39-manylinux_2_5_i686.manylinux1_i686.whl (478.7 kB view hashes)

Uploaded CPython 3.9 manylinux: glibc 2.5+ i686

akatsuki_pp_py-1.0.1-cp39-cp39-macosx_10_12_x86_64.whl (435.1 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ x86-64

akatsuki_pp_py-1.0.1-cp39-cp39-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (838.5 kB view hashes)

Uploaded CPython 3.9 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

akatsuki_pp_py-1.0.1-cp38-none-win_amd64.whl (358.0 kB view hashes)

Uploaded CPython 3.8 Windows x86-64

akatsuki_pp_py-1.0.1-cp38-none-win32.whl (344.2 kB view hashes)

Uploaded CPython 3.8 Windows x86

akatsuki_pp_py-1.0.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (470.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ x86-64

akatsuki_pp_py-1.0.1-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (454.7 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.17+ ARM64

akatsuki_pp_py-1.0.1-cp38-cp38-manylinux_2_5_i686.manylinux1_i686.whl (479.3 kB view hashes)

Uploaded CPython 3.8 manylinux: glibc 2.5+ i686

akatsuki_pp_py-1.0.1-cp38-cp38-macosx_10_12_x86_64.whl (435.4 kB view hashes)

Uploaded CPython 3.8 macOS 10.12+ x86-64

akatsuki_pp_py-1.0.1-cp38-cp38-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (839.1 kB view hashes)

Uploaded CPython 3.8 macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

akatsuki_pp_py-1.0.1-cp37-none-win_amd64.whl (358.1 kB view hashes)

Uploaded CPython 3.7 Windows x86-64

akatsuki_pp_py-1.0.1-cp37-none-win32.whl (344.6 kB view hashes)

Uploaded CPython 3.7 Windows x86

akatsuki_pp_py-1.0.1-cp37-cp37m-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (471.1 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ x86-64

akatsuki_pp_py-1.0.1-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (455.2 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.17+ ARM64

akatsuki_pp_py-1.0.1-cp37-cp37m-manylinux_2_5_i686.manylinux1_i686.whl (479.6 kB view hashes)

Uploaded CPython 3.7m manylinux: glibc 2.5+ i686

akatsuki_pp_py-1.0.1-cp37-cp37m-macosx_10_12_x86_64.whl (435.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.12+ x86-64

akatsuki_pp_py-1.0.1-cp37-cp37m-macosx_10_12_x86_64.macosx_11_0_arm64.macosx_10_12_universal2.whl (839.6 kB view hashes)

Uploaded CPython 3.7m macOS 10.12+ universal2 (ARM64, x86-64) macOS 10.12+ x86-64 macOS 11.0+ ARM64

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page