Repository: ppizarror/pygame-menu

Issue:
RangeSlider assertion error when modifying minimum range value
**Environment information**
Describe your environment information, such as:
- SO: Windows
- python version: v3.8.5
- pygame version: v2.0.1
- pygame-menu version: v4.1.0

**Describe the bug**
    `options.add.range_slider("Infection Rate", default = 2,increment=0.5, range_values=(2,10))`

This line throws an assertion error shown below. If the minimum value is set to 0, this works fine. It appears almost any minimum range value other than 0 throws an error. Commenting out the assertion in source seemed to work fine.

`Traceback (most recent call last):
  File "main.py", line 120, in <module>
    g = Game()
  File "main.py", line 25, in __init__
    self.options = optionsMenu(lambda : self._update_from_selection(3))
  File "D:\School\Python\Sickulator\src\sickulator\menus.py", line 29, in optionsMenu
    options.add.range_slider("Infection Rate", default = 2,increment=0.5, range_values=(2,10))
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\_widgetmanager.py", line 2816, in range_slider
    self._configure_widget(widget=widget, **attributes)
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\_widgetmanager.py", line 305, in _configure_widget
    widget.set_font(
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\core\widget.py", line 1711, in set_font
    self._force_render()
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\core\widget.py", line 802, in _force_render
    return self._render()
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 795, in _render
    st_x = self._range_pos[0] + self._get_pos_range(v, st)
  File "C:\Users\JBKec\anaconda3\envs\game\lib\site-packages\pygame_menu\widgets\widget\rangeslider.py", line 819, in _get_pos_range
    assert 0 <= d <= 1
AssertionError`

**To Reproduce**
Create a menu, add a range_slider with range_values of 2 to 10 (or any number other than 0 to any value).

**Expected behavior**
It should successfully produce the range slider 



Comments:

Patch:
diff --git a/pygame_menu/version.py b/pygame_menu/version.py
index ada8d44c..3cff547a 100644
--- a/pygame_menu/version.py
+++ b/pygame_menu/version.py
@@ -57,6 +57,6 @@ class Version(tuple):
     patch = property(lambda self: self[2])
 
 
-vernum = Version(4, 1, 0)
+vernum = Version(4, 1, 1)
 ver = str(vernum)
 rev = ''
diff --git a/pygame_menu/widgets/widget/rangeslider.py b/pygame_menu/widgets/widget/rangeslider.py
index f7d4d662..9d9fa4a1 100644
--- a/pygame_menu/widgets/widget/rangeslider.py
+++ b/pygame_menu/widgets/widget/rangeslider.py
@@ -816,7 +816,6 @@ class RangeSlider(Widget):
         sw = surface.get_width() / 2 if surface is not None else 0
         if len(self._range_values) == 2:
             d = float(value - self._range_values[0]) / (self._range_values[1] - self._range_values[0])
-            assert 0 <= d <= 1
             return int(d * self._range_width - sw)
 
         # Find nearest position


Test patch:
diff --git a/test/test_widget_rangeslider.py b/test/test_widget_rangeslider.py
index 4737e879..4b498bc4 100644
--- a/test/test_widget_rangeslider.py
+++ b/test/test_widget_rangeslider.py
@@ -471,6 +471,23 @@ class RangeSliderWidgetTest(BaseTest):
         r = menu.add.range_slider('', 0.5, (0, 1), 0.1)
         self.assertEqual(r.get_size(), (198, 66))
 
+    def test_invalid_range(self) -> None:
+        """
+        Test invalid ranges. #356
+        """
+        menu = MenuUtils.generic_menu()
+        r = menu.add.range_slider('Infection Rate', default=2, increment=0.5, range_values=(2, 10))
+        self.assertEqual(r.get_value(), 2)
+        self.assertTrue(r.update(PygameEventUtils.key(ctrl.KEY_RIGHT, keydown=True)))
+        self.assertEqual(r.get_value(), 2.5)
+        self.assertTrue(r.update(PygameEventUtils.key(ctrl.KEY_LEFT, keydown=True)))
+        self.assertEqual(r.get_value(), 2)
+        self.assertFalse(r.update(PygameEventUtils.key(ctrl.KEY_LEFT, keydown=True)))
+        self.assertEqual(r.get_value(), 2)
+        for _ in range(20):
+            r.update(PygameEventUtils.key(ctrl.KEY_RIGHT, keydown=True))
+        self.assertEqual(r.get_value(), 10)
+
     def test_value(self) -> None:
         """
         Test rangeslider value.