Skip to content

Commit

Permalink
feat: bump numpy version to support numpy v.2.2
Browse files Browse the repository at this point in the history
  • Loading branch information
fabclmnt committed Sep 6, 2024
1 parent a542afe commit 5679b16
Show file tree
Hide file tree
Showing 4 changed files with 62 additions and 6 deletions.
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
62 changes: 59 additions & 3 deletions tests/unit/test_typeset_default.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
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 @@ -18,19 +20,73 @@
from ydata_profiling.model.typeset import ProfilingTypeSet
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

0 comments on commit 5679b16

Please sign in to comment.