Skip to content

Commit 052aec8

Browse files
committed
Fix TAP and Kokoro tests caused by NumPy v2 migration.
1. To ensure test compatibility between NumPy v1 and v2 environments, we've adjusted the comparison tolerance to 1e-4. This accommodates slight variations (around 1e-4) in floating-point outcomes between the two NumPy versions. Additionally, we've modified the expected proto float to align with NumPy v2 results. 2. For mutual_information, NumPy v2 is able to handle values > 2**53 if the min and max of the examples are the same. However, since we need to be compatible with NumPy v1 and v2, for related unit tests, we check for the NumPy version before running the associated unit tests. PiperOrigin-RevId: 681598675
1 parent bca0f85 commit 052aec8

File tree

7 files changed

+165
-189
lines changed

7 files changed

+165
-189
lines changed

.github/workflows/build.yml

Lines changed: 0 additions & 76 deletions
This file was deleted.

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,9 @@ tested at Google.
6666

6767
### 1. Install Docker
6868

69-
Please first install `docker` and `docker compose` by following the directions:
69+
Please first install `docker` and `docker-compose` by following the directions:
7070
[docker](https://docs.docker.com/install/);
71-
[docker compose](https://docs.docker.com/compose/install/).
71+
[docker-compose](https://docs.docker.com/compose/install/).
7272

7373
### 2. Clone the TFDV repository
7474

@@ -86,8 +86,8 @@ branch), pass `-b <branchname>` to the `git clone` command.
8686
Then, run the following at the project root:
8787

8888
```bash
89-
sudo docker compose build manylinux2010
90-
sudo docker compose run -e PYTHON_VERSION=${PYTHON_VERSION} manylinux2010
89+
sudo docker-compose build manylinux2010
90+
sudo docker-compose run -e PYTHON_VERSION=${PYTHON_VERSION} manylinux2010
9191
```
9292
where `PYTHON_VERSION` is one of `{39, 310, 311}`.
9393

tensorflow_data_validation/integration_tests/sequence_example_e2e_test.py

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -267,18 +267,18 @@
267267
histograms {
268268
buckets {
269269
low_value: 5.0
270-
high_value: 6.666666666666667
271-
sample_count: 10.0220751
270+
high_value: 6.6666665
271+
sample_count: 10.0220747
272272
}
273273
buckets {
274-
low_value: 6.666666666666667
275-
high_value: 8.333333333333334
274+
low_value: 6.6666665
275+
high_value: 8.333333
276276
sample_count: 0.0220751
277277
}
278278
buckets {
279-
low_value: 8.333333333333334
279+
low_value: 8.333333
280280
high_value: 10.0
281-
sample_count: 9.9558499
281+
sample_count: 9.9558363
282282
}
283283
}
284284
histograms {
@@ -340,18 +340,18 @@
340340
histograms {
341341
buckets {
342342
low_value: 1.0
343-
high_value: 1.3333333333333333
344-
sample_count: 10.0220751
343+
high_value: 1.3333334
344+
sample_count: 10.0220747
345345
}
346346
buckets {
347-
low_value: 1.3333333333333333
347+
low_value: 1.3333334
348348
high_value: 1.6666666666666665
349349
sample_count: 0.0220751
350350
}
351351
buckets {
352352
low_value: 1.6666666666666665
353353
high_value: 2.0
354-
sample_count: 9.9558499
354+
sample_count: 9.9558363
355355
}
356356
}
357357
histograms {
@@ -787,18 +787,18 @@
787787
histograms {
788788
buckets {
789789
low_value: 5.0
790-
high_value: 6.666666666666667
791-
sample_count: 10.0220751
790+
high_value: 6.6666665
791+
sample_count: 10.0220747
792792
}
793793
buckets {
794-
low_value: 6.666666666666667
795-
high_value: 8.333333333333334
794+
low_value: 6.6666665
795+
high_value: 8.333333
796796
sample_count: 0.0220751
797797
}
798798
buckets {
799-
low_value: 8.333333333333334
799+
low_value: 8.333333
800800
high_value: 10.0
801-
sample_count: 9.9558499
801+
sample_count: 9.9558363
802802
}
803803
}
804804
histograms {
@@ -826,18 +826,18 @@
826826
histograms {
827827
buckets {
828828
low_value: 5.0
829-
high_value: 6.666666666666667
830-
sample_count: 50.1658375
829+
high_value: 6.6666665
830+
sample_count: 50.1658363
831831
}
832832
buckets {
833-
low_value: 6.666666666666667
834-
high_value: 8.333333333333334
833+
low_value: 6.6666665
834+
high_value: 8.333333
835835
sample_count: 0.1658375
836836
}
837837
buckets {
838-
low_value: 8.333333333333334
838+
low_value: 8.333333
839839
high_value: 10.0
840-
sample_count: 99.668325
840+
sample_count: 99.6683884
841841
}
842842
}
843843
histograms {
@@ -905,18 +905,18 @@
905905
histograms {
906906
buckets {
907907
low_value: 1.0
908-
high_value: 1.3333333333333333
909-
sample_count: 10.0220751
908+
high_value: 1.3333334
909+
sample_count: 10.0220747
910910
}
911911
buckets {
912-
low_value: 1.3333333333333333
912+
low_value: 1.3333334
913913
high_value: 1.6666666666666665
914914
sample_count: 0.0220751
915915
}
916916
buckets {
917917
low_value: 1.6666666666666665
918918
high_value: 2.0
919-
sample_count: 9.9558499
919+
sample_count: 9.9558363
920920
}
921921
}
922922
histograms {
@@ -944,18 +944,18 @@
944944
histograms {
945945
buckets {
946946
low_value: 1.0
947-
high_value: 1.3333333333333333
948-
sample_count: 50.1658375
947+
high_value: 1.3333334
948+
sample_count: 50.1658363
949949
}
950950
buckets {
951-
low_value: 1.3333333333333333
951+
low_value: 1.3333334
952952
high_value: 1.6666666666666665
953953
sample_count: 0.1658375
954954
}
955955
buckets {
956956
low_value: 1.6666666666666665
957957
high_value: 2.0
958-
sample_count: 99.668325
958+
sample_count: 99.6683884
959959
}
960960
}
961961
histograms {

tensorflow_data_validation/statistics/generators/basic_stats_generator_test.py

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1864,18 +1864,18 @@ def test_with_multiple_features(self):
18641864
histograms {
18651865
buckets {
18661866
low_value: 1.0
1867-
high_value: 2.3333333
1867+
high_value: 2.3333335
18681868
sample_count: 3.0049751
18691869
}
18701870
buckets {
1871-
low_value: 2.3333333
1871+
low_value: 2.3333335
18721872
high_value: 3.6666667
1873-
sample_count: 1.0049751
1873+
sample_count: 1.0049746
18741874
}
18751875
buckets {
18761876
low_value: 3.6666667
18771877
high_value: 5.0
1878-
sample_count: 1.9900498
1878+
sample_count: 1.9900484
18791879
}
18801880
type: STANDARD
18811881
}
@@ -1903,7 +1903,9 @@ def test_with_multiple_features(self):
19031903
type: QUANTILES
19041904
}
19051905
}
1906-
""", statistics_pb2.FeatureNameStatistics()),
1906+
""",
1907+
statistics_pb2.FeatureNameStatistics(),
1908+
),
19071909
types.FeaturePath(['b']): text_format.Parse(
19081910
"""
19091911
path {
@@ -1938,7 +1940,9 @@ def test_with_multiple_features(self):
19381940
}
19391941
avg_length: 1.71428571
19401942
}
1941-
""", statistics_pb2.FeatureNameStatistics()),
1943+
""",
1944+
statistics_pb2.FeatureNameStatistics(),
1945+
),
19421946
types.FeaturePath(['c']): text_format.Parse(
19431947
"""
19441948
path {
@@ -2018,7 +2022,10 @@ def test_with_multiple_features(self):
20182022
type: QUANTILES
20192023
}
20202024
}
2021-
""", statistics_pb2.FeatureNameStatistics())}
2025+
""",
2026+
statistics_pb2.FeatureNameStatistics(),
2027+
),
2028+
}
20222029
generator = basic_stats_generator.BasicStatsGenerator(
20232030
num_values_histogram_buckets=3, num_histogram_buckets=3,
20242031
num_quantiles_histogram_buckets=4, epsilon=0.001)

tensorflow_data_validation/statistics/generators/mutual_information.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,9 @@ def _encode_multivalent_numeric_feature(
228228
_, histogram_bin_boundaries = np.histogram(
229229
flattened_feature_values, bins=encoding_length - 1)
230230
except IndexError as e:
231-
# np.histogram cannot handle values > 2**53 if the min and max of the
232-
# examples are the same. https://github.com/numpy/numpy/issues/8627
231+
# For NumPy version 1.x.x, np.histogram cannot handle values > 2**53 if the
232+
# min and max of the examples are the same.
233+
# https://github.com/numpy/numpy/issues/8627
233234
logging.exception("Unable to encode examples: %s with error: %s",
234235
flattened_feature_values, e)
235236
return None

0 commit comments

Comments
 (0)