itables 2.1.2__tar.gz → 2.1.4__tar.gz

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.
Files changed (118) hide show
  1. {itables-2.1.2 → itables-2.1.4}/PKG-INFO +1 -1
  2. {itables-2.1.2 → itables-2.1.4}/docs/changelog.md +15 -1
  3. {itables-2.1.2 → itables-2.1.4}/src/itables/datatables_format.py +16 -5
  4. {itables-2.1.2 → itables-2.1.4}/src/itables/sample_dfs.py +3 -3
  5. {itables-2.1.2 → itables-2.1.4}/src/itables/version.py +1 -1
  6. {itables-2.1.2 → itables-2.1.4}/tests/test_datatables_format.py +16 -0
  7. {itables-2.1.2 → itables-2.1.4}/tests/test_polars.py +17 -0
  8. {itables-2.1.2 → itables-2.1.4}/.github/codecov.yml +0 -0
  9. {itables-2.1.2 → itables-2.1.4}/.github/workflows/comment-pr.yml +0 -0
  10. {itables-2.1.2 → itables-2.1.4}/.github/workflows/continuous-integration.yml +0 -0
  11. {itables-2.1.2 → itables-2.1.4}/.github/workflows/publish-book.yml +0 -0
  12. {itables-2.1.2 → itables-2.1.4}/.github/workflows/publish.yml +0 -0
  13. {itables-2.1.2 → itables-2.1.4}/.gitignore +0 -0
  14. {itables-2.1.2 → itables-2.1.4}/.pre-commit-config.yaml +0 -0
  15. {itables-2.1.2 → itables-2.1.4}/.pylintrc +0 -0
  16. {itables-2.1.2 → itables-2.1.4}/LICENSE +0 -0
  17. {itables-2.1.2 → itables-2.1.4}/README.md +0 -0
  18. {itables-2.1.2 → itables-2.1.4}/binder/labconfig/default_setting_overrides.json +0 -0
  19. {itables-2.1.2 → itables-2.1.4}/binder/postBuild +0 -0
  20. {itables-2.1.2 → itables-2.1.4}/binder/requirements.txt +0 -0
  21. {itables-2.1.2 → itables-2.1.4}/docs/_config.yml +0 -0
  22. {itables-2.1.2 → itables-2.1.4}/docs/_toc.yml +0 -0
  23. {itables-2.1.2 → itables-2.1.4}/docs/advanced_parameters.md +0 -0
  24. {itables-2.1.2 → itables-2.1.4}/docs/contributing.md +0 -0
  25. {itables-2.1.2 → itables-2.1.4}/docs/custom_css.md +0 -0
  26. {itables-2.1.2 → itables-2.1.4}/docs/custom_extensions.md +0 -0
  27. {itables-2.1.2 → itables-2.1.4}/docs/dash.md +0 -0
  28. {itables-2.1.2 → itables-2.1.4}/docs/developing.md +0 -0
  29. {itables-2.1.2 → itables-2.1.4}/docs/df_example.png +0 -0
  30. {itables-2.1.2 → itables-2.1.4}/docs/downsampling.md +0 -0
  31. {itables-2.1.2 → itables-2.1.4}/docs/extensions.md +0 -0
  32. {itables-2.1.2 → itables-2.1.4}/docs/formatting.md +0 -0
  33. {itables-2.1.2 → itables-2.1.4}/docs/html_export.md +0 -0
  34. {itables-2.1.2 → itables-2.1.4}/docs/images/code.png +0 -0
  35. {itables-2.1.2 → itables-2.1.4}/docs/images/colab.png +0 -0
  36. {itables-2.1.2 → itables-2.1.4}/docs/images/html.png +0 -0
  37. {itables-2.1.2 → itables-2.1.4}/docs/images/lab.png +0 -0
  38. {itables-2.1.2 → itables-2.1.4}/docs/images/notebook.png +0 -0
  39. {itables-2.1.2 → itables-2.1.4}/docs/images/pycharm.png +0 -0
  40. {itables-2.1.2 → itables-2.1.4}/docs/ipywidgets.md +0 -0
  41. {itables-2.1.2 → itables-2.1.4}/docs/pandas_style.md +0 -0
  42. {itables-2.1.2 → itables-2.1.4}/docs/polars_dataframes.md +0 -0
  43. {itables-2.1.2 → itables-2.1.4}/docs/quarto/quarto_html.qmd +0 -0
  44. {itables-2.1.2 → itables-2.1.4}/docs/quarto/quarto_revealjs.qmd +0 -0
  45. {itables-2.1.2 → itables-2.1.4}/docs/quarto.md +0 -0
  46. {itables-2.1.2 → itables-2.1.4}/docs/quick_start.md +0 -0
  47. {itables-2.1.2 → itables-2.1.4}/docs/references.md +0 -0
  48. {itables-2.1.2 → itables-2.1.4}/docs/sample_dataframes.md +0 -0
  49. {itables-2.1.2 → itables-2.1.4}/docs/shiny.md +0 -0
  50. {itables-2.1.2 → itables-2.1.4}/docs/show_df.png +0 -0
  51. {itables-2.1.2 → itables-2.1.4}/docs/streamlit.md +0 -0
  52. {itables-2.1.2 → itables-2.1.4}/docs/supported_editors.md +0 -0
  53. {itables-2.1.2 → itables-2.1.4}/docs/troubleshooting.md +0 -0
  54. {itables-2.1.2 → itables-2.1.4}/environment.yml +0 -0
  55. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/CHANGELOG.md +0 -0
  56. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/LICENSE +0 -0
  57. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/README.md +0 -0
  58. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/package-lock.json +0 -0
  59. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/package.json +0 -0
  60. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/src/index.css +0 -0
  61. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/src/index.d.ts +0 -0
  62. {itables-2.1.2 → itables-2.1.4}/packages/dt_for_itables/src/index.js +0 -0
  63. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/README.md +0 -0
  64. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/package-lock.json +0 -0
  65. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/package.json +0 -0
  66. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/public/index.html +0 -0
  67. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/src/index.tsx +0 -0
  68. {itables-2.1.2 → itables-2.1.4}/packages/itables_for_streamlit/tsconfig.json +0 -0
  69. {itables-2.1.2 → itables-2.1.4}/packages/package-lock.json +0 -0
  70. {itables-2.1.2 → itables-2.1.4}/packages/package.json +0 -0
  71. {itables-2.1.2 → itables-2.1.4}/pyproject.toml +0 -0
  72. {itables-2.1.2 → itables-2.1.4}/src/itables/__init__.py +0 -0
  73. {itables-2.1.2 → itables-2.1.4}/src/itables/downsample.py +0 -0
  74. {itables-2.1.2 → itables-2.1.4}/src/itables/html/column_filters/initComplete.js +0 -0
  75. {itables-2.1.2 → itables-2.1.4}/src/itables/html/column_filters/pre_dt_code.js +0 -0
  76. {itables-2.1.2 → itables-2.1.4}/src/itables/html/datatables_template.html +0 -0
  77. {itables-2.1.2 → itables-2.1.4}/src/itables/html/dt_bundle.css +0 -0
  78. {itables-2.1.2 → itables-2.1.4}/src/itables/html/dt_bundle.js +0 -0
  79. {itables-2.1.2 → itables-2.1.4}/src/itables/html/init_datatables.html +0 -0
  80. {itables-2.1.2 → itables-2.1.4}/src/itables/interactive.py +0 -0
  81. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/asset-manifest.json +0 -0
  82. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/index.html +0 -0
  83. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/static/css/main.8eddd46d.css +0 -0
  84. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/static/css/main.8eddd46d.css.map +0 -0
  85. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/static/js/main.ffa367f6.js +0 -0
  86. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/static/js/main.ffa367f6.js.LICENSE.txt +0 -0
  87. {itables-2.1.2 → itables-2.1.4}/src/itables/itables_for_streamlit/static/js/main.ffa367f6.js.map +0 -0
  88. {itables-2.1.2 → itables-2.1.4}/src/itables/javascript.py +0 -0
  89. {itables-2.1.2 → itables-2.1.4}/src/itables/logo/loading.svg +0 -0
  90. {itables-2.1.2 → itables-2.1.4}/src/itables/logo/logo.svg +0 -0
  91. {itables-2.1.2 → itables-2.1.4}/src/itables/logo/text.svg +0 -0
  92. {itables-2.1.2 → itables-2.1.4}/src/itables/logo/wide.svg +0 -0
  93. {itables-2.1.2 → itables-2.1.4}/src/itables/logo/with_text.svg +0 -0
  94. {itables-2.1.2 → itables-2.1.4}/src/itables/options.py +0 -0
  95. {itables-2.1.2 → itables-2.1.4}/src/itables/samples/countries.csv +0 -0
  96. {itables-2.1.2 → itables-2.1.4}/src/itables/samples/indicators.csv +0 -0
  97. {itables-2.1.2 → itables-2.1.4}/src/itables/samples/population.csv +0 -0
  98. {itables-2.1.2 → itables-2.1.4}/src/itables/shiny.py +0 -0
  99. {itables-2.1.2 → itables-2.1.4}/src/itables/streamlit.py +0 -0
  100. {itables-2.1.2 → itables-2.1.4}/src/itables/utils.py +0 -0
  101. {itables-2.1.2 → itables-2.1.4}/tests/__init__.py +0 -0
  102. {itables-2.1.2 → itables-2.1.4}/tests/conftest.py +0 -0
  103. {itables-2.1.2 → itables-2.1.4}/tests/sample_python_apps/itables_in_a_shiny_app.py +0 -0
  104. {itables-2.1.2 → itables-2.1.4}/tests/sample_python_apps/itables_in_a_shiny_app_with_tabs.py +0 -0
  105. {itables-2.1.2 → itables-2.1.4}/tests/test_changelog.py +0 -0
  106. {itables-2.1.2 → itables-2.1.4}/tests/test_connected_notebook_is_small.py +0 -0
  107. {itables-2.1.2 → itables-2.1.4}/tests/test_documentation_notebooks_run.py +0 -0
  108. {itables-2.1.2 → itables-2.1.4}/tests/test_downsample.py +0 -0
  109. {itables-2.1.2 → itables-2.1.4}/tests/test_extension_arguments.py +0 -0
  110. {itables-2.1.2 → itables-2.1.4}/tests/test_html_in_table_header.py +0 -0
  111. {itables-2.1.2 → itables-2.1.4}/tests/test_init.py +0 -0
  112. {itables-2.1.2 → itables-2.1.4}/tests/test_javascript.py +0 -0
  113. {itables-2.1.2 → itables-2.1.4}/tests/test_json_dumps.py +0 -0
  114. {itables-2.1.2 → itables-2.1.4}/tests/test_notebook.ipynb +0 -0
  115. {itables-2.1.2 → itables-2.1.4}/tests/test_pandas_style.py +0 -0
  116. {itables-2.1.2 → itables-2.1.4}/tests/test_sample_dfs.py +0 -0
  117. {itables-2.1.2 → itables-2.1.4}/tests/test_sample_python_apps.py +0 -0
  118. {itables-2.1.2 → itables-2.1.4}/tests/test_update_samples.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: itables
3
- Version: 2.1.2
3
+ Version: 2.1.4
4
4
  Summary: Pandas and Polar DataFrames as interactive DataTables
5
5
  Project-URL: Homepage, https://mwouts.github.io/itables/
6
6
  Project-URL: Documentation, https://mwouts.github.io/itables
@@ -1,6 +1,20 @@
1
1
  ITables ChangeLog
2
2
  =================
3
3
 
4
+ 2.1.4 (2024-07-03)
5
+ ------------------
6
+
7
+ **Fixed**
8
+ - We have fixed an OverflowError (_can't convert negative int to unsigned_) when displaying Polars DataFrames that contain unsigned integers ([#299](https://github.com/mwouts/itables/issues/299))
9
+
10
+
11
+ 2.1.3 (2024-06-22)
12
+ ------------------
13
+
14
+ **Fixed**
15
+ - We have improved the detection of large integers in the context of Polars DataFrames ([#291](https://github.com/mwouts/itables/issues/291))
16
+
17
+
4
18
  2.1.2 (2024-06-19)
5
19
  ------------------
6
20
 
@@ -9,7 +23,7 @@ ITables ChangeLog
9
23
  an automatic horizontal scrolling in Jupyter, Jupyter Book and also Streamlit if the table is too wide ([#282](https://github.com/mwouts/itables/pull/282)).
10
24
 
11
25
  **Fixed**
12
- - The dependencies of the streamlit components have been updated to fix a vulnerability in `ws` ([Alert #1](https://github.com/mwouts/itables/security/dependabot/1))
26
+ - The dependencies of the streamlit components have been updated to fix a vulnerability in `ws` ([Alert 1](https://github.com/mwouts/itables/security/dependabot/1))
13
27
 
14
28
 
15
29
  2.1.1 (2024-06-08)
@@ -114,8 +114,11 @@ def datatables_rows(df, count=None, warn_on_unexpected_types=False, pure_json=Fa
114
114
  import polars as pl
115
115
 
116
116
  has_bigints = any(
117
- x.dtype in [pl.Int64, pl.UInt64]
118
- and ((x > JS_MAX_SAFE_INTEGER).any() or (x < JS_MIN_SAFE_INTEGER).any())
117
+ (
118
+ x.dtype == pl.Int64
119
+ and ((x > JS_MAX_SAFE_INTEGER).any() or (x < JS_MIN_SAFE_INTEGER).any())
120
+ )
121
+ or (x.dtype == pl.UInt64 and (x > JS_MAX_SAFE_INTEGER).any())
119
122
  for x in (df[col] for col in df.columns)
120
123
  )
121
124
  js = json.dumps(data, cls=generate_encoder(False), allow_nan=not pure_json)
@@ -129,7 +132,15 @@ def datatables_rows(df, count=None, warn_on_unexpected_types=False, pure_json=Fa
129
132
  def n_suffix_for_bigints(js, pure_json=False):
130
133
  def n_suffix(matchobj):
131
134
  if pure_json:
132
- return '"' + matchobj.group(1) + '"' + matchobj.group(2)
133
- return 'BigInt("' + matchobj.group(1) + '")' + matchobj.group(2)
135
+ return matchobj.group(1) + '"' + matchobj.group(2) + '"' + matchobj.group(3)
136
+ return (
137
+ matchobj.group(1)
138
+ + 'BigInt("'
139
+ + matchobj.group(2)
140
+ + '")'
141
+ + matchobj.group(3)
142
+ )
134
143
 
135
- return re.sub(r"(-?\d{16,})(,|])", n_suffix, js)
144
+ big_int_re = re.compile(r"^([\[\s]+)(-?\d{16,})(\]*)$")
145
+ parts = js.split(",")
146
+ return ",".join(re.sub(big_int_re, n_suffix, part) for part in parts)
@@ -301,9 +301,9 @@ def get_dict_of_test_series(polars=False):
301
301
 
302
302
  # Add a Polar table with unsigned integers
303
303
  # https://github.com/mwouts/itables/issues/192
304
- polars_series["u32"] = (
305
- pl.DataFrame({"foo": [1, 1, 3, 1]}).groupby("foo").count()
306
- )
304
+ # https://github.com/mwouts/itables/issues/299
305
+ polars_series["u32"] = pl.Series([1, 2, 5]).cast(pl.UInt32)
306
+ polars_series["u64"] = pl.Series([1, 2, 2**40]).cast(pl.UInt64)
307
307
 
308
308
  return polars_series
309
309
 
@@ -1,3 +1,3 @@
1
1
  """ITables' version number"""
2
2
 
3
- __version__ = "2.1.2"
3
+ __version__ = "2.1.4"
@@ -154,3 +154,19 @@ def test_encode_max_int(large):
154
154
  def test_encode_not_max_int(large):
155
155
  large //= 10
156
156
  assert n_suffix_for_bigints(json.dumps([large])) == "[{}]".format(large)
157
+
158
+
159
+ def test_encode_mixed_contents():
160
+ # Make sure that the bigint escape works for mixed content # 291
161
+ df = pd.DataFrame(
162
+ {
163
+ "bigint": [1666767918216000000],
164
+ "int": [1699300000000],
165
+ "float": [0.9510565400123596],
166
+ "neg": [-0.30901700258255005],
167
+ }
168
+ )
169
+ assert (
170
+ datatables_rows(df)
171
+ == '[[BigInt("1666767918216000000"), 1699300000000, 0.951057, -0.309017]]'
172
+ )
@@ -1,6 +1,7 @@
1
1
  import pytest
2
2
 
3
3
  from itables import to_html_datatable
4
+ from itables.javascript import datatables_rows
4
5
  from itables.sample_dfs import get_dict_of_test_dfs, get_dict_of_test_series
5
6
 
6
7
  try:
@@ -21,3 +22,19 @@ def test_show_polars_series(name, x, use_to_html):
21
22
  )
22
23
  def test_show_polars_df(name, df, use_to_html):
23
24
  to_html_datatable(df, use_to_html)
25
+
26
+
27
+ def test_encode_mixed_contents():
28
+ # Make sure that the bigint escape works for mixed content # 291
29
+ df = polars.DataFrame(
30
+ {
31
+ "bigint": [1666767918216000000],
32
+ "int": [1699300000000],
33
+ "float": [0.9510565400123596],
34
+ "neg": [-0.30901700258255005],
35
+ }
36
+ )
37
+ assert (
38
+ datatables_rows(df)
39
+ == '[[BigInt("1666767918216000000"), 1699300000000, 0.9510565400123596, -0.30901700258255005]]'
40
+ )
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes