Skip to content

Incompatibility with Numpy >= 2.0 #189

@LucasSom

Description

@LucasSom

Hi!

I'm trying to use the library using numpy==2.2.6 (latest version) and numpy==2.1.3 (latest of 2.1) and it doesn't work because, I think (reading the documentation), at lines 71 and 74 of sweetviz/graph_numeric.py there is a call to np.VisibleDeprecationWarning but since v2.0, numpy has this warning as an exception (i.e., you have to replace the lines with np.exceptions.VisibleDeprecationWarning).

Here is my code:

import sweetviz as sv

report = sv.analyze(data)
report.show_html("sweetviz_report.html")

and here the error traeback:

AttributeError                            Traceback (most recent call last)
/tmp/ipykernel_30607/2909702403.py in <module>
      2 import sweetviz as sv
      3 
----> 4 report = sv.analyze(data)
      5 report.show_html("sweetviz_report.html")

~/.../venv/lib/python3.12/site-packages/sweetviz/sv_public.py in analyze(source, target_feat, feat_cfg, pairwise_analysis)
     10             feat_cfg: FeatureConfig = None,
     11             pairwise_analysis: str = 'auto'):
---> 12     report = sweetviz.DataframeReport(source, target_feat, None,
     13                                       pairwise_analysis, feat_cfg)
     14     return report

~/.../venv/lib/python3.12/site-packages/sweetviz/dataframe_report.py in __init__(self, source, target_feature_name, compare, pairwise_analysis, fc, verbosity)
    275             # start = time.perf_counter()
    276             self.progress_bar.set_description_str(f"Feature: {f.source.name}")
--> 277             self._features[f.source.name] = sa.analyze_feature_to_dictionary(f)
    278             self.progress_bar.update(1)
    279             # print(f"DONE FEATURE------> {f.source.name}"

~/.../venv/lib/python3.12/site-packages/sweetviz/series_analyzer.py in analyze_feature_to_dictionary(to_process)
    140     # Perform full analysis on source/compare/target
    141     if returned_feature_dict["type"] == FeatureType.TYPE_NUM:
--> 142         sweetviz.series_analyzer_numeric.analyze(to_process, returned_feature_dict)
    143     elif returned_feature_dict["type"] == FeatureType.TYPE_CAT:
    144         sweetviz.series_analyzer_cat.analyze(to_process, returned_feature_dict)

~/.../venv/lib/python3.12/site-packages/sweetviz/series_analyzer_numeric.py in analyze(to_process, feature_dict)
    100     do_detail_numeric(to_process.source, to_process.source_counts, to_process.compare_counts, feature_dict)
    101 
--> 102     feature_dict["minigraph"] = GraphNumeric("mini", to_process)
    103     feature_dict["detail_graphs"] = list()
    104     for num_bins in [0, 5, 15, 30]:

~/.../venv/lib/python3.12/site-packages/sweetviz/graph_numeric.py in __init__(self, which_graph, to_process)
     69         gap_percent = config["Graphs"].getfloat("summary_graph_categorical_gap")
     70 
---> 71         warnings.filterwarnings('ignore', category=np.VisibleDeprecationWarning)
     72         self.hist_specs = axs.hist(plot_data, weights = normalizing_weights, bins=self.num_bins, \
     73                                    rwidth = (100.0 - gap_percent) / 100.0)

~/.../venv/lib/python3.12/site-packages/numpy/__init__.py in __getattr__(attr)
    412             return char.chararray
    413 
--> 414         raise AttributeError("module {!r} has no attribute "
    415                              "{!r}".format(__name__, attr))
    416 

AttributeError: module 'numpy' has no attribute 'VisibleDeprecationWarning'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions