Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: bump numpy version to support numpy v.2 #1646

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pydantic>=2
PyYAML>=5.0.0, <6.1
jinja2>=2.11.1, <3.2
visions[type_image_path]>=0.7.5, <0.7.7
numpy>=1.16.0, <2
numpy>=1.16.0, <2.2
# Could be optional
# Related to HTML report
htmlmin==0.1.12
Expand Down
2 changes: 1 addition & 1 deletion tests/issues/test_issue397.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ def test_issue397():
# Note: warnings are expected with np.inf values
df = pd.DataFrame.from_dict(
{
"float-inf": pd.Series([np.inf, 3.0, 4.0, np.NINF], dtype="float"),
"float-inf": pd.Series([np.inf, 3.0, 4.0, -np.inf], dtype="float"),
"integer": pd.Series([3, 4, 5, 6], dtype="int"),
"float": pd.Series([3.0, 4.0, np.nan, 6], dtype="float"),
"integer-inf": pd.Series([3, np.inf, 5, 7]),
Expand Down
2 changes: 1 addition & 1 deletion tests/issues/test_issue664.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

def test_issue664():
n = 10000
df = pd.DataFrame({"a": [np.NaN] * n, "b": ["b"] * n, "c": [pd.NaT] * n})
df = pd.DataFrame({"a": [np.nan] * n, "b": ["b"] * n, "c": [pd.NaT] * n})
df = df.fillna(value=np.nan)

profile = ProfileReport(
Expand Down
63 changes: 60 additions & 3 deletions tests/unit/test_typeset_default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
from typing import Dict
from typing import Dict, Sequence
from urllib.parse import urlparse

import numpy as np
import pandas as pd
Expand All @@ -19,18 +20,74 @@
from ydata_profiling.profile_report import ProfileReport


def get_sequences() -> Dict[str, Sequence]:
sequences = {
"complex_series_float": [
complex(0, 0),
complex(1, 0),
complex(3, 0),
complex(-1, 0),
],
"url_nan_series": [
urlparse("http://www.cwi.nl:80/%7Eguido/Python.html"),
urlparse("https://github.com/dylan-profiling/hurricane"),
np.nan,
],
"mixed": [True, False, np.nan],
"float_nan_series": [1.0, 2.5, np.nan],
"float_series5": [np.nan, 1.2],
"float_with_inf": [np.inf, -np.inf, 1000000.0, 5.5],
"inf_series": [np.inf, -np.inf],
"int_nan_series": [1, 2, np.nan],
"nan_series": [np.nan],
"nan_series_2": [np.nan, np.nan, np.nan, np.nan],
"string_num_nan": ["1.0", "2.0", np.nan],
"string_with_sep_num_nan": ["1,000.0", "2.1", np.nan],
"string_flt_nan": ["1.0", "45.67", np.nan],
"string_str_nan": [
"I was only robbing the register,",
"I hope you understand",
"One of us had better call up the cops",
"In the hot New Jersey night",
np.nan,
],
"float_series3": np.array([1.2, 2, 3, 4], dtype=np.float64),
"np_uint32": np.array([1, 2, 3, 4], dtype=np.uint32),
"string_np_unicode_series": np.array(["upper", "hall"], dtype=np.str_),
"complex_series": [
complex(0, 0),
complex(1, 2),
complex(3, -1),
],
"bool_series3": np.array([1, 0, 0, 1], dtype=np.bool_),
"complex_series_nan": [complex(0, 0), complex(1, 2), complex(3, -1), None],
"complex_series_nan_2": [
complex(0, 0),
complex(1, 2),
complex(3, -1),
np.nan,
],
"complex_series_py_nan": [
complex(0, 0),
complex(1, 2),
complex(3, -1),
np.nan,
],
}
return sequences


def get_series() -> Dict[str, pd.Series]:
"""
Taken from Vision to remove the `complex_series_nan` that causes an exception due to a bug
in pandas 2 and numpy with the value `np.nan * 0j` and `complex(np.nan, np.nan)`.
See: https://github.com/numpy/numpy/issues/12919
"""
from visions.backends.numpy.sequences import get_sequences as get_numpy_sequences
from visions.backends.pandas.sequences import get_sequences as get_pandas_sequences
from visions.backends.python.sequences import get_sequences as get_builtin_sequences

sequences = get_builtin_sequences()
sequences.update(get_numpy_sequences())
sequences.update(get_sequences())

del sequences["complex_series_nan"]

Expand Down
Loading