lets-plot 4.7.0rc1__cp313-cp313-manylinux2014_aarch64.manylinux_2_17_aarch64.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.

Potentially problematic release.


This version of lets-plot might be problematic. Click here for more details.

Files changed (95) hide show
  1. lets_plot/__init__.py +283 -0
  2. lets_plot/_global_settings.py +196 -0
  3. lets_plot/_kbridge.py +141 -0
  4. lets_plot/_type_utils.py +133 -0
  5. lets_plot/_version.py +6 -0
  6. lets_plot/bistro/__init__.py +16 -0
  7. lets_plot/bistro/_plot2d_common.py +100 -0
  8. lets_plot/bistro/corr.py +447 -0
  9. lets_plot/bistro/im.py +196 -0
  10. lets_plot/bistro/joint.py +192 -0
  11. lets_plot/bistro/qq.py +207 -0
  12. lets_plot/bistro/residual.py +341 -0
  13. lets_plot/bistro/waterfall.py +333 -0
  14. lets_plot/export/__init__.py +6 -0
  15. lets_plot/export/ggsave_.py +141 -0
  16. lets_plot/frontend_context/__init__.py +8 -0
  17. lets_plot/frontend_context/_configuration.py +151 -0
  18. lets_plot/frontend_context/_frontend_ctx.py +16 -0
  19. lets_plot/frontend_context/_html_contexts.py +117 -0
  20. lets_plot/frontend_context/_intellij_python_json_ctx.py +38 -0
  21. lets_plot/frontend_context/_json_contexts.py +39 -0
  22. lets_plot/frontend_context/_jupyter_notebook_ctx.py +119 -0
  23. lets_plot/frontend_context/_mime_types.py +7 -0
  24. lets_plot/frontend_context/_static_html_page_ctx.py +27 -0
  25. lets_plot/frontend_context/_static_svg_ctx.py +26 -0
  26. lets_plot/frontend_context/_webbr_html_page_ctx.py +29 -0
  27. lets_plot/frontend_context/sandbox.py +5 -0
  28. lets_plot/geo_data/__init__.py +19 -0
  29. lets_plot/geo_data/core.py +331 -0
  30. lets_plot/geo_data/geocoder.py +977 -0
  31. lets_plot/geo_data/geocodes.py +512 -0
  32. lets_plot/geo_data/gis/__init__.py +0 -0
  33. lets_plot/geo_data/gis/fluent_dict.py +201 -0
  34. lets_plot/geo_data/gis/geocoding_service.py +42 -0
  35. lets_plot/geo_data/gis/geometry.py +91 -0
  36. lets_plot/geo_data/gis/json_request.py +232 -0
  37. lets_plot/geo_data/gis/json_response.py +308 -0
  38. lets_plot/geo_data/gis/request.py +492 -0
  39. lets_plot/geo_data/gis/response.py +247 -0
  40. lets_plot/geo_data/livemap_helper.py +65 -0
  41. lets_plot/geo_data/to_geo_data_frame.py +141 -0
  42. lets_plot/geo_data/type_assertion.py +34 -0
  43. lets_plot/geo_data_internals/__init__.py +4 -0
  44. lets_plot/geo_data_internals/constants.py +13 -0
  45. lets_plot/geo_data_internals/utils.py +33 -0
  46. lets_plot/mapping.py +115 -0
  47. lets_plot/package_data/lets-plot.min.js +3 -0
  48. lets_plot/plot/__init__.py +64 -0
  49. lets_plot/plot/_global_theme.py +14 -0
  50. lets_plot/plot/annotation.py +290 -0
  51. lets_plot/plot/coord.py +242 -0
  52. lets_plot/plot/core.py +1060 -0
  53. lets_plot/plot/expand_limits_.py +78 -0
  54. lets_plot/plot/facet.py +206 -0
  55. lets_plot/plot/font_features.py +71 -0
  56. lets_plot/plot/geom.py +8839 -0
  57. lets_plot/plot/geom_extras.py +53 -0
  58. lets_plot/plot/geom_function_.py +216 -0
  59. lets_plot/plot/geom_imshow_.py +392 -0
  60. lets_plot/plot/geom_livemap_.py +310 -0
  61. lets_plot/plot/ggbunch_.py +96 -0
  62. lets_plot/plot/gggrid_.py +126 -0
  63. lets_plot/plot/ggtb_.py +55 -0
  64. lets_plot/plot/guide.py +229 -0
  65. lets_plot/plot/label.py +187 -0
  66. lets_plot/plot/marginal_layer.py +181 -0
  67. lets_plot/plot/plot.py +244 -0
  68. lets_plot/plot/pos.py +320 -0
  69. lets_plot/plot/sampling.py +338 -0
  70. lets_plot/plot/sandbox_.py +26 -0
  71. lets_plot/plot/scale.py +3577 -0
  72. lets_plot/plot/scale_colormap_mpl.py +297 -0
  73. lets_plot/plot/scale_convenience.py +155 -0
  74. lets_plot/plot/scale_identity_.py +658 -0
  75. lets_plot/plot/scale_position.py +1342 -0
  76. lets_plot/plot/series_meta.py +203 -0
  77. lets_plot/plot/stat.py +581 -0
  78. lets_plot/plot/subplots.py +322 -0
  79. lets_plot/plot/subplots_util.py +24 -0
  80. lets_plot/plot/theme_.py +772 -0
  81. lets_plot/plot/theme_set.py +393 -0
  82. lets_plot/plot/tooltip.py +486 -0
  83. lets_plot/plot/util.py +237 -0
  84. lets_plot/settings_utils.py +244 -0
  85. lets_plot/tilesets.py +429 -0
  86. lets_plot-4.7.0rc1.dist-info/METADATA +196 -0
  87. lets_plot-4.7.0rc1.dist-info/RECORD +95 -0
  88. lets_plot-4.7.0rc1.dist-info/WHEEL +6 -0
  89. lets_plot-4.7.0rc1.dist-info/licenses/LICENSE +21 -0
  90. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.FreeType +166 -0
  91. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.ImageMagick +106 -0
  92. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.expat +21 -0
  93. lets_plot-4.7.0rc1.dist-info/licenses/licenses/LICENSE.fontconfig +200 -0
  94. lets_plot-4.7.0rc1.dist-info/top_level.txt +2 -0
  95. lets_plot_kotlin_bridge.cpython-313-aarch64-linux-gnu.so +0 -0
@@ -0,0 +1,26 @@
1
+ #
2
+ # Copyright (c) 2020. JetBrains s.r.o.
3
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4
+ #
5
+ from typing import Dict
6
+
7
+ from ._frontend_ctx import FrontendContext
8
+ from .. import _kbridge as kbr
9
+ from .._version import __version__
10
+
11
+
12
+ class StaticSvgImageContext(FrontendContext):
13
+
14
+ def configure(self, verbose: bool):
15
+ if verbose:
16
+ message = '<div style="color:darkblue;">Lets-Plot v{}: static SVG output configured.</div>'.format(
17
+ __version__)
18
+ try:
19
+ from IPython.display import display_html
20
+ display_html(message, raw=True)
21
+ except ImportError:
22
+ pass
23
+ print(message)
24
+
25
+ def as_str(self, plot_spec: Dict) -> str:
26
+ return kbr._generate_svg(plot_spec)
@@ -0,0 +1,29 @@
1
+ #
2
+ # Copyright (c) 2019. JetBrains s.r.o.
3
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4
+ #
5
+ import io
6
+ import webbrowser
7
+ import tempfile
8
+ from typing import Dict
9
+
10
+ from ._frontend_ctx import FrontendContext
11
+ from .. import _kbridge as kbr
12
+
13
+
14
+ class WebBrHtmlPageContext(FrontendContext):
15
+
16
+ def __init__(self, exec: str, new: bool) -> None:
17
+ super().__init__()
18
+ self.exec = exec
19
+ self.new = new
20
+
21
+ def show(self, plot_spec: Dict) -> str:
22
+ html_page = kbr._generate_static_html_page(plot_spec, iframe=False)
23
+
24
+ path = tempfile.NamedTemporaryFile(mode='w+t', suffix=".html", delete=False)
25
+ try:
26
+ io.open(path.name, 'w+t').write(html_page)
27
+ webbrowser.get(self.exec).open('file://' + path.name, new=1 if self.new else 2)
28
+ finally:
29
+ path.close()
@@ -0,0 +1,5 @@
1
+ #
2
+ # Copyright (c) 2019. JetBrains s.r.o.
3
+ # Use of this source code is governed by the MIT license that can be found in the LICENSE file.
4
+ #
5
+
@@ -0,0 +1,19 @@
1
+ try:
2
+ import geopandas
3
+ except ImportError:
4
+ print("geopandas is required for using the geo_data package")
5
+ raise
6
+
7
+ from .core import *
8
+ from .geocoder import *
9
+ from .geocodes import *
10
+
11
+ __all__ = core.__all__
12
+
13
+ # Use geo_data package only for executing geocoding requests.
14
+ # For accessing variuous checks, contants, types etc use package geo_data_internals
15
+ # as it won't cause the OSM attribution to appear.
16
+
17
+ # print on the package import
18
+ print("The geodata is provided by © OpenStreetMap contributors"
19
+ " and is made available here under the Open Database License (ODbL).")
@@ -0,0 +1,331 @@
1
+ from typing import Any
2
+
3
+ import numpy as np
4
+
5
+ from .geocoder import Geocoder, ReverseGeocoder, NamesGeocoder
6
+
7
+ __all__ = [
8
+ 'distance',
9
+
10
+ 'geocode',
11
+ 'geocode_cities',
12
+ 'geocode_counties',
13
+ 'geocode_states',
14
+ 'geocode_countries',
15
+ 'reverse_geocode'
16
+ ]
17
+
18
+ UNITS_DICT = {
19
+ 'mi': 3959,
20
+ 'km': 6371
21
+ }
22
+
23
+ GEOFUNC_TYPES = {
24
+ 'centroids': 'centroids',
25
+ 'boundaries': 'boundaries',
26
+ 'limits': 'limits',
27
+ 'region': 'regions'
28
+ }
29
+
30
+
31
+ def geocode(level=None, names=None, countries=None, states=None, counties=None, scope=None) -> NamesGeocoder:
32
+ """
33
+ Create a `NamesGeocoder`. Allow to refine ambiguous request with `where()` method,
34
+ scope that limits area of geocoding or with parents.
35
+
36
+ Parameters
37
+ ----------
38
+ level : {'country', 'state', 'county', 'city'}
39
+ The level of administrative division. Autodetection by default.
40
+ names : list or str
41
+ Names of objects to be geocoded.
42
+ For 'state' level: 'US-48' returns continental part of United States (48 states)
43
+ in a compact form.
44
+ countries : list
45
+ Parent countries. Should have same size as names. Can contain strings or `Geocoder` objects.
46
+ states : list
47
+ Parent states. Should have same size as names. Can contain strings or `Geocoder` objects.
48
+ counties : list
49
+ Parent counties. Should have same size as names. Can contain strings or `Geocoder` objects.
50
+ scope : str or `Geocoder`
51
+ Limits area of geocoding. If parent country is set then error will be generated.
52
+ If type is a string - geoobject should have geocoded scope in parents.
53
+ If type is a `Geocoder` - geoobject should have geocoded scope in parents.
54
+ Scope should contain only one entry.
55
+
56
+ Returns
57
+ -------
58
+ `NamesGeocoder`
59
+ Geocoder object specification.
60
+
61
+ Examples
62
+ --------
63
+ .. jupyter-execute::
64
+ :linenos:
65
+ :emphasize-lines: 5
66
+
67
+ from IPython.display import display
68
+ from lets_plot import *
69
+ from lets_plot.geo_data import *
70
+ LetsPlot.setup_html()
71
+ states = geocode('state').scope('Italy').get_boundaries(6)
72
+ display(states.head())
73
+ ggplot() + geom_map(data=states)
74
+
75
+ |
76
+
77
+ .. jupyter-execute::
78
+ :linenos:
79
+ :emphasize-lines: 5, 8
80
+
81
+ from IPython.display import display
82
+ from lets_plot import *
83
+ from lets_plot.geo_data import *
84
+ LetsPlot.setup_html()
85
+ states = geocode(level='state', scope='US').get_geocodes()
86
+ display(states.head())
87
+ names = ['York'] * len(states.state)
88
+ cities = geocode(names=names, states=states.state).ignore_not_found().get_centroids()
89
+ display(cities.head())
90
+ ggplot() + \\
91
+ geom_livemap() + \\
92
+ geom_point(data=cities, tooltips=layer_tooltips().line('@{found name}'))
93
+
94
+ """
95
+ return NamesGeocoder(level, names) \
96
+ .scope(scope) \
97
+ .countries(countries) \
98
+ .states(states) \
99
+ .counties(counties)
100
+
101
+
102
+ def geocode_cities(names=None) -> NamesGeocoder:
103
+ """
104
+ Create a `NamesGeocoder` object for cities. Allow to refine ambiguous request with
105
+ `where()` method, with a scope that limits area of geocoding or with parents.
106
+
107
+ Parameters
108
+ ----------
109
+ names : str or list
110
+ Names of objects to be geocoded.
111
+
112
+ Returns
113
+ -------
114
+ `NamesGeocoder`
115
+ Geocoder object specification.
116
+
117
+ Examples
118
+ --------
119
+ .. jupyter-execute::
120
+ :linenos:
121
+ :emphasize-lines: 5
122
+
123
+ from IPython.display import display
124
+ from lets_plot import *
125
+ from lets_plot.geo_data import *
126
+ LetsPlot.setup_html()
127
+ cities = geocode_cities(['York', 'Jersey'])\\
128
+ .where(name='Jersey', scope='New Jersey').get_boundaries()
129
+ display(cities)
130
+ ggplot() + geom_map(aes(fill='found name'), data=cities, color='white')
131
+
132
+ """
133
+ return NamesGeocoder('city', names)
134
+
135
+
136
+ def geocode_counties(names=None) -> NamesGeocoder:
137
+ """
138
+ Create a `NamesGeocoder` object for counties. Allow to refine ambiguous request with
139
+ `where()` method, with a scope that limits area of geocoding or with parents.
140
+
141
+ Parameters
142
+ ----------
143
+ names : str or list
144
+ Names of objects to be geocoded.
145
+
146
+ Returns
147
+ -------
148
+ `NamesGeocoder`
149
+ Geocoder object specification.
150
+
151
+ Examples
152
+ --------
153
+ .. jupyter-execute::
154
+ :linenos:
155
+ :emphasize-lines: 5
156
+
157
+ from IPython.display import display
158
+ from lets_plot import *
159
+ from lets_plot.geo_data import *
160
+ LetsPlot.setup_html()
161
+ counties = geocode_counties().scope('NY').get_boundaries(9)
162
+ display(counties.head())
163
+ ggplot() + geom_map(data=counties) + ggtitle('New York State Counties')
164
+
165
+ """
166
+ return NamesGeocoder('county', names)
167
+
168
+
169
+ def geocode_states(names=None) -> NamesGeocoder:
170
+ """
171
+ Create a `NamesGeocoder` object for states. Allow to refine ambiguous request with
172
+ `where()` method, with a scope that limits area of geocoding or with parents.
173
+
174
+ Parameters
175
+ ----------
176
+ names : str or list
177
+ Names of objects to be geocoded.
178
+
179
+ Returns
180
+ -------
181
+ `NamesGeocoder`
182
+ Geocoder object specification.
183
+
184
+ Examples
185
+ --------
186
+ .. jupyter-execute::
187
+ :linenos:
188
+ :emphasize-lines: 5
189
+
190
+ from IPython.display import display
191
+ from lets_plot import *
192
+ from lets_plot.geo_data import *
193
+ LetsPlot.setup_html()
194
+ states = geocode_states().scope('UK').get_boundaries()
195
+ display(states)
196
+ ggplot() + \\
197
+ geom_map(aes(fill='found name'), data=states, color='white') + \\
198
+ ggtitle('UK States')
199
+
200
+ """
201
+ return NamesGeocoder('state', names)
202
+
203
+
204
+ def geocode_countries(names=None) -> NamesGeocoder:
205
+ """
206
+ Create a `NamesGeocoder` object for countries. Allow to refine ambiguous request with
207
+ `where()` method.
208
+
209
+ Parameters
210
+ ----------
211
+ names : str or list
212
+ Names of objects to be geocoded.
213
+
214
+ Returns
215
+ -------
216
+ `NamesGeocoder`
217
+ Geocoder object specification.
218
+
219
+ Examples
220
+ --------
221
+ .. jupyter-execute::
222
+ :linenos:
223
+ :emphasize-lines: 5
224
+
225
+ from IPython.display import display
226
+ from lets_plot import *
227
+ from lets_plot.geo_data import *
228
+ LetsPlot.setup_html()
229
+ countries = geocode_countries(['Germany', 'Poland']).inc_res().get_boundaries()
230
+ display(countries)
231
+ ggplot() + geom_map(aes(fill='found name'), data=countries, color='white')
232
+
233
+ """
234
+ return NamesGeocoder('country', names)
235
+
236
+
237
+ def reverse_geocode(lon, lat, level=None, scope=None) -> ReverseGeocoder:
238
+ """
239
+ Convert a location as described by geographic coordinates to a `ReverseGeocoder` object.
240
+
241
+ Parameters
242
+ ----------
243
+ lon : float
244
+ Longitude coordinate of the geoobject.
245
+ lat : float
246
+ Latitude coordinate of the geoobject.
247
+ level : {'country', 'state', 'county', 'city'}
248
+ The level of administrative division.
249
+ scope : str or `Geocoder`
250
+ Specify this for resolving conflicts for disputed territories.
251
+
252
+ Returns
253
+ -------
254
+ `ReverseGeocoder`
255
+ Geocoder object specification.
256
+
257
+ Examples
258
+ --------
259
+ .. jupyter-execute::
260
+ :linenos:
261
+ :emphasize-lines: 5
262
+
263
+ from IPython.display import display
264
+ from lets_plot import *
265
+ from lets_plot.geo_data import *
266
+ LetsPlot.setup_html()
267
+ city = reverse_geocode(-73.87, 40.68, level='city').get_boundaries()
268
+ display(city)
269
+ ggplot() + geom_map(data=city) + ggtitle(city.iloc[0]['found name'])
270
+
271
+ """
272
+ return ReverseGeocoder(lon, lat, level, scope)
273
+
274
+
275
+ def distance(lon0, lat0, lon1, lat1, units='km'):
276
+ """
277
+ Calculate the distance between two points. Return result in kilometers or miles.
278
+
279
+ Parameters
280
+ ----------
281
+ lon0 : float
282
+ Longitude coordinate of the first point.
283
+ lat0 : float
284
+ Latitude coordinate of the first point.
285
+ lon1 : float
286
+ Longitude coordinate of the second point.
287
+ lat1 : float
288
+ Latitude coordinate of the second point.
289
+ units : {'mi', 'km'}, default='km'
290
+ The units in which the result will be obtained.
291
+ There are shorthands for values: 'mi' (miles), 'km' (kilometers).
292
+
293
+ Returns
294
+ -------
295
+ float
296
+ Distance between the points.
297
+
298
+ Examples
299
+ --------
300
+ .. jupyter-execute::
301
+ :linenos:
302
+ :emphasize-lines: 3
303
+
304
+ from lets_plot.geo_data import *
305
+ cities = geocode_cities(['New York', 'Chicago']).get_centroids().geometry
306
+ distance(cities[0].x, cities[0].y, cities[1].x, cities[1].y, units='mi')
307
+
308
+ """
309
+ return _calc_distance(lon0, lat0, lon1, lat1, units)
310
+
311
+
312
+ def _calc_distance(lon0, lat0, lon1, lat1, u):
313
+ r = _prepare_units(u)
314
+
315
+ lon0, lat0, lon1, lat1 = map(np.radians, [lon0, lat0, lon1, lat1])
316
+
317
+ dlon = lon1 - lon0
318
+ dlat = lat1 - lat0
319
+
320
+ a = np.sin(dlat / 2.0) ** 2 + np.cos(lat0) * np.cos(lat1) * np.sin(dlon / 2.0) ** 2
321
+
322
+ c = 2 * np.arcsin(np.sqrt(a))
323
+ return c * r
324
+
325
+
326
+ def _prepare_units(units: Any) -> float:
327
+ try:
328
+ return UNITS_DICT[units]
329
+ except KeyError:
330
+ raise ValueError('Wrong units: {}. The units can take the following values: '
331
+ 'mi (miles), km (kilometers).'.format(units))