pyglove 0.4.5.dev202411050809__py3-none-any.whl → 0.4.5.dev202411070808__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.
@@ -0,0 +1,99 @@
1
+ # Copyright 2024 The PyGlove Authors
2
+ #
3
+ # Licensed under the Apache License, Version 2.0 (the "License");
4
+ # you may not use this file except in compliance with the License.
5
+ # You may obtain a copy of the License at
6
+ #
7
+ # http://www.apache.org/licenses/LICENSE-2.0
8
+ #
9
+ # Unless required by applicable law or agreed to in writing, software
10
+ # distributed under the License is distributed on an "AS IS" BASIS,
11
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ # See the License for the specific language governing permissions and
13
+ # limitations under the License.
14
+ import inspect
15
+ import unittest
16
+
17
+ from pyglove.core import symbolic # pylint: disable=unused-import
18
+ from pyglove.core.views.html import base
19
+ from pyglove.core.views.html.controls import tooltip as tooltip_lib
20
+
21
+
22
+ class TooltipTest(unittest.TestCase):
23
+
24
+ def assert_html_content(self, control, expected):
25
+ expected = inspect.cleandoc(expected).strip()
26
+ actual = control.to_html().content.strip()
27
+ if actual != expected:
28
+ print(actual)
29
+ self.assertEqual(actual, expected)
30
+
31
+ def test_basic(self):
32
+ tooltip = tooltip_lib.Tooltip('foo')
33
+ with self.assertRaisesRegex(
34
+ ValueError, 'CSS selector `for_element` is required'
35
+ ):
36
+ tooltip.to_html()
37
+
38
+ tooltip = tooltip_lib.Tooltip('foo', for_element='.bar')
39
+ self.assertEqual(tooltip.for_element, '.bar')
40
+ self.assert_html_content(
41
+ tooltip,
42
+ '<span class="tooltip">foo</span>'
43
+ )
44
+ self.assertIn(
45
+ inspect.cleandoc(
46
+ """
47
+ .bar:hover + .tooltip {
48
+ visibility: visible;
49
+ }
50
+ """
51
+ ),
52
+ tooltip.to_html().style_section,
53
+ )
54
+
55
+ def test_update(self):
56
+ tooltip = tooltip_lib.Tooltip('foo', for_element='.bar', interactive=True)
57
+ self.assertIn('id="control-', tooltip.to_html_str(content_only=True))
58
+ with tooltip.track_scripts() as scripts:
59
+ tooltip.update('normal text')
60
+ self.assertEqual(tooltip.content, 'normal text')
61
+ self.assertEqual(
62
+ scripts,
63
+ [
64
+ inspect.cleandoc(
65
+ f"""
66
+ elem = document.getElementById("{tooltip.element_id()}");
67
+ elem.textContent = "normal text";
68
+ """
69
+ ),
70
+ inspect.cleandoc(
71
+ f"""
72
+ elem = document.getElementById("{tooltip.element_id()}");
73
+ elem.classList.remove("html-content");
74
+ """
75
+ ),
76
+ ]
77
+ )
78
+ with tooltip.track_scripts() as scripts:
79
+ tooltip.update(base.Html('<b>bold text</b>'))
80
+ self.assertEqual(
81
+ scripts,
82
+ [
83
+ inspect.cleandoc(
84
+ f"""
85
+ elem = document.getElementById("{tooltip.element_id()}");
86
+ elem.innerHTML = "<b>bold text</b>";
87
+ """
88
+ ),
89
+ inspect.cleandoc(
90
+ f"""
91
+ elem = document.getElementById("{tooltip.element_id()}");
92
+ elem.classList.add("html-content");
93
+ """
94
+ ),
95
+ ]
96
+ )
97
+
98
+ if __name__ == '__main__':
99
+ unittest.main()
@@ -1,4 +1,4 @@
1
- # Copyright 2024 The Langfun Authors
1
+ # Copyright 2024 The PyGlove Authors
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -1,4 +1,4 @@
1
- # Copyright 2024 The Langfun Authors
1
+ # Copyright 2024 The PyGlove Authors
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -11,7 +11,6 @@
11
11
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
-
15
14
  import inspect
16
15
  from typing import Any
17
16
  import unittest
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: pyglove
3
- Version: 0.4.5.dev202411050809
3
+ Version: 0.4.5.dev202411070808
4
4
  Summary: PyGlove: A library for manipulating Python objects.
5
5
  Home-page: https://github.com/google/pyglove
6
6
  Author: PyGlove Authors
@@ -1,5 +1,5 @@
1
1
  pyglove/__init__.py,sha256=YPUWALRDu4QuI7N3TUmVaVr513hUt0qXrjY582I1q5c,1352
2
- pyglove/core/__init__.py,sha256=omnsY79mvCd39G9HKtuYHltlgwB5kTdgqKQAoXWgT-I,8992
2
+ pyglove/core/__init__.py,sha256=FDGkzVlLR0FohA8_ZBFrxhEYxQWAGKe72mjUDjE_SDY,9293
3
3
  pyglove/core/logging.py,sha256=Sr5nLyUQmc4CAEYAq8qbP3ghpjmpz2sOuhq2A0tgQ6I,2456
4
4
  pyglove/core/logging_test.py,sha256=QM59tCAFOUKm4gM6ef_9eG1AvSGEYRDLrrprUQyslcA,1956
5
5
  pyglove/core/detouring/__init__.py,sha256=ck_n2VSuU31HNVYQkbG4Zvnx90mNYtSVc2StN3rXbU8,1891
@@ -141,12 +141,22 @@ pyglove/core/typing/value_specs.py,sha256=V6m4RhCc4yi6H8X1LoptSk5gsa7ko8HgLYDSfV
141
141
  pyglove/core/typing/value_specs_test.py,sha256=kKwoEmGIXtM5JikhtbhcE4Ds-wSyYAsMTozHVa2Lpbc,122707
142
142
  pyglove/core/views/__init__.py,sha256=gll9ZBRYz4p_-LWOdzSR2a6UTWcJ8nR430trrP0yLCU,967
143
143
  pyglove/core/views/base.py,sha256=Eq94AM5lryQ1IKuQsTSb7ZzX-lp2nhuOnS4ztMnCPIM,26447
144
- pyglove/core/views/base_test.py,sha256=F6nou7reS_Kmr2H57MUgcnc1bIp9Z3BWCvHOvMqjGkQ,16642
145
- pyglove/core/views/html/__init__.py,sha256=Rkd8IU6-988A8RPcuHBqibQxcL3u2RB54NZr0qoGNUU,1086
146
- pyglove/core/views/html/base.py,sha256=FhJvcKpVZaYWxBbJ-XuXkoANfxL7_yVVTXitRlU9OP4,15083
147
- pyglove/core/views/html/base_test.py,sha256=ly9icRdzL4FddWdlFy3b2qsOe-mxT4iK6xiTgQLoqcw,22782
148
- pyglove/core/views/html/tree_view.py,sha256=TqNqGpBrEG52kVCJoLGeF_mZA52V_n6YyzzPfq2ojdw,52155
149
- pyglove/core/views/html/tree_view_test.py,sha256=vkjkxKfBU1QhyNLUZ0Gi1btJRFZC9B4EMrCQAKnBqNI,74708
144
+ pyglove/core/views/base_test.py,sha256=UKbr_1TANOAnP7V5ICGF0UEkunfSaHiJ4nXZXhA0SaU,16642
145
+ pyglove/core/views/html/__init__.py,sha256=Ff51MK1AKdzLM0kczTqLR3fRlJSJLDaFUdVyCu_7-eY,1085
146
+ pyglove/core/views/html/base.py,sha256=PyS5B9N_Y2HS4q01X0uSUf3UbODn1UerfqPX1imLPac,15083
147
+ pyglove/core/views/html/base_test.py,sha256=5RVPNm4YTamTFu6yXA1p2lJg3JHQBKNNBoL977qBZvE,22782
148
+ pyglove/core/views/html/tree_view.py,sha256=3Db0aOke-A7Inp-vgqebsDMwJ0WvaznithkwcrfGbhg,52155
149
+ pyglove/core/views/html/tree_view_test.py,sha256=whUorrw0eiDaZsEzGB2B3EN3wx0vLFuNEe2RBU03GeU,74707
150
+ pyglove/core/views/html/controls/__init__.py,sha256=61qs5pnJPCTECCGBtkbNfIV3KcCu7cxfVNBEtIg1lMo,1318
151
+ pyglove/core/views/html/controls/base.py,sha256=eTUB2iJSBtD0sbkWE_LaVT1e4Sir6Q61HJ2j5OZxAsU,6615
152
+ pyglove/core/views/html/controls/label.py,sha256=JggkrD3j6Z_zAl2B8HRACC1pExDJUeIHY5E51yKMarw,5202
153
+ pyglove/core/views/html/controls/label_test.py,sha256=3ekn3aBO1O8iG_wHpZ7487wY2YRA6wyKeDN7275iR4U,4544
154
+ pyglove/core/views/html/controls/progress_bar.py,sha256=kLdY3JQLCOv00ShldnQg3Qs8l1j_pDk148FoKfrZB64,5275
155
+ pyglove/core/views/html/controls/progress_bar_test.py,sha256=6u1A6kAV8GY_vUMD6PSl7HuuOkVMELYqU32YEVx6qz8,3500
156
+ pyglove/core/views/html/controls/tab.py,sha256=4m4pALSIQoIwVVz7hoMjQs1dgY3cOzyzJjT8ZikBNbQ,4958
157
+ pyglove/core/views/html/controls/tab_test.py,sha256=j54nyN9BJjS0sXJlxA45RQDSmPY2HDP5ttxc4sqkGpw,2121
158
+ pyglove/core/views/html/controls/tooltip.py,sha256=01BbpuM1twf3FYMUT09_Ck5JSSONe8QE9RmyA9nhCnU,3092
159
+ pyglove/core/views/html/controls/tooltip_test.py,sha256=17BY-WmZKpz9tCbySPcwG6KJyfeE_MeMyKxtfxorBQ0,3194
150
160
  pyglove/ext/__init__.py,sha256=3jp8cJvKW6PENOZlmVAbT0w-GBRn_kjhc0wDX3XjpOE,755
151
161
  pyglove/ext/early_stopping/__init__.py,sha256=_xkT3K_MycFuF3k2N74sfr9FPFcXMD3pfv5vuc4Tx5M,1116
152
162
  pyglove/ext/early_stopping/base.py,sha256=KolexwKDAXhI9iY7hoaDO1mbc3TA4gDn0UifxURwbk0,2358
@@ -186,8 +196,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
186
196
  pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
187
197
  pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
188
198
  pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
189
- pyglove-0.4.5.dev202411050809.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
190
- pyglove-0.4.5.dev202411050809.dist-info/METADATA,sha256=Awku-gpCb395dqtLTubEg0bd1j8QCrCgqedotNKk6QM,6666
191
- pyglove-0.4.5.dev202411050809.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
192
- pyglove-0.4.5.dev202411050809.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
193
- pyglove-0.4.5.dev202411050809.dist-info/RECORD,,
199
+ pyglove-0.4.5.dev202411070808.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
200
+ pyglove-0.4.5.dev202411070808.dist-info/METADATA,sha256=HCIZCRdPtyOx74IKdF6J4e3Aoy37DfLabPoEaYdQoQ0,6666
201
+ pyglove-0.4.5.dev202411070808.dist-info/WHEEL,sha256=P9jw-gEje8ByB7_hXoICnHtVCrEwMQh-630tKvQWehc,91
202
+ pyglove-0.4.5.dev202411070808.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
203
+ pyglove-0.4.5.dev202411070808.dist-info/RECORD,,