Skip to content

Commit

Permalink
chore: Deduplicate code from Python standard lib (#878)
Browse files Browse the repository at this point in the history
* chore: Deduplicate code from Python standard lib

As we are supporting Python >= 3.6, we can rely on this function being
present in Python's standard library.

Co-authored-by: Johannes Sasongko <sasongko@gmail.com>
  • Loading branch information
genodeftest and sjohannes committed Jun 16, 2023
1 parent 75be6a5 commit e9a7e5c
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions plugins/equalizer/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@


import logging
import math
import os

from gi.repository import Gst
Expand All @@ -40,15 +41,6 @@
logger = logging.getLogger('equalizer')


def isclose(float_a, float_b, rel_tol=1e-09, abs_tol=0.0):
"""
copied from python 3.5, where this function was introduced to the math module
"""
return abs(float_a - float_b) <= max(
rel_tol * max(abs(float_a), abs(float_b)), abs_tol
)


# Values from <http://www.xmms.org/faq.php#General3>, adjusted to be less loud
# in general ((mean + max) / 2 = 0).
DEFAULT_PRESETS = [
Expand Down Expand Up @@ -200,7 +192,7 @@ def adjust_band(self, widget):
widget_name = Gtk.Buildable.get_name(widget)
band = widget_name[-1]
settings_value = settings.get_option("plugin/equalizer/band" + band)
if not isclose(widget.get_value(), settings_value):
if not math.isclose(widget.get_value(), settings_value):
settings.set_option("plugin/equalizer/band" + band, widget.get_value())
self.combo_presets.set_active(0)

Expand Down

0 comments on commit e9a7e5c

Please sign in to comment.