streamlit-nightly 1.30.1.dev20240116__py2.py3-none-any.whl → 1.30.1.dev20240118__py2.py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ import math
15
16
  from typing import TYPE_CHECKING, Optional, Union, cast
16
17
 
17
18
  from typing_extensions import TypeAlias
@@ -29,6 +30,32 @@ if TYPE_CHECKING:
29
30
  FloatOrInt: TypeAlias = Union[int, float]
30
31
 
31
32
 
33
+ def _check_float_between(value: float, low: float = 0.0, high: float = 1.0) -> bool:
34
+ """
35
+ Checks given value is 'between' the bounds of [low, high],
36
+ considering close values around bounds are acceptable input
37
+
38
+ Notes
39
+ -----
40
+ This check is required for handling values that are slightly above or below the
41
+ acceptable range, for example -0.0000000000021, 1.0000000000000013.
42
+ These values are little off the conventional 0.0 <= x <= 1.0 condition
43
+ due to floating point operations, but should still be considered acceptable input.
44
+
45
+ Parameters
46
+ ----------
47
+ value : float
48
+ low : float
49
+ high : float
50
+
51
+ """
52
+ return (
53
+ (low <= value <= high)
54
+ or math.isclose(value, low, rel_tol=1e-9, abs_tol=1e-9)
55
+ or math.isclose(value, high, rel_tol=1e-9, abs_tol=1e-9)
56
+ )
57
+
58
+
32
59
  def _get_value(value):
33
60
  if isinstance(value, int):
34
61
  if 0 <= value <= 100:
@@ -39,7 +66,7 @@ def _get_value(value):
39
66
  )
40
67
 
41
68
  elif isinstance(value, float):
42
- if 0.0 <= value <= 1.0:
69
+ if _check_float_between(value, low=0.0, high=1.0):
43
70
  return int(value * 100)
44
71
  else:
45
72
  raise StreamlitAPIException(
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "files": {
3
3
  "main.css": "./static/css/main.77d1c464.css",
4
- "main.js": "./static/js/main.673a9494.js",
4
+ "main.js": "./static/js/main.9d3093fe.js",
5
5
  "static/js/9336.2d95d840.chunk.js": "./static/js/9336.2d95d840.chunk.js",
6
6
  "static/js/9330.c0dd1723.chunk.js": "./static/js/9330.c0dd1723.chunk.js",
7
7
  "static/js/7217.d970c074.chunk.js": "./static/js/7217.d970c074.chunk.js",
@@ -149,6 +149,6 @@
149
149
  },
150
150
  "entrypoints": [
151
151
  "static/css/main.77d1c464.css",
152
- "static/js/main.673a9494.js"
152
+ "static/js/main.9d3093fe.js"
153
153
  ]
154
154
  }
@@ -1 +1 @@
1
- <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.673a9494.js"></script><link href="./static/css/main.77d1c464.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>
1
+ <!doctype html><html lang="en"><head><meta charset="UTF-8"/><meta name="viewport" content="width=device-width,initial-scale=1,shrink-to-fit=no"/><link rel="shortcut icon" href="./favicon.png"/><link rel="preload" href="./static/media/SourceSansPro-Regular.0d69e5ff5e92ac64a0c9.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-SemiBold.abed79cd0df1827e18cf.woff2" as="font" type="font/woff2" crossorigin><link rel="preload" href="./static/media/SourceSansPro-Bold.118dea98980e20a81ced.woff2" as="font" type="font/woff2" crossorigin><title>Streamlit</title><script>window.prerenderReady=!1</script><script defer="defer" src="./static/js/main.9d3093fe.js"></script><link href="./static/css/main.77d1c464.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div></body></html>