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

fix: multi thread error on matplotlib default backend #1149

Merged
merged 1 commit into from
Nov 18, 2022

Conversation

alexbarros
Copy link
Contributor

The following script consistently fails when the multi-threading option is active, entering an infinity loop triggered by matplotlib backend. The fix consists in temporarily changing the backend while creating the plots (ty @fabclmnt for the help with this one).

import pandas as pd
import numpy as np

from pandas_profiling import ProfileReport


def create_dataframes(size=1000, alt=False):
    size = size if not alt else size * 2
    time_steps = np.arange(size)

   df1 =  pd.DataFrame(
        {
            "sin": map(lambda x: round(np.sin(x * np.pi / 180), 2), time_steps),
            "gaussian": map(lambda x: round(x, 2), np.random.normal(0, 1, size)),
        }
    )

    df2 = pd.DataFrame(
        {
            "sin": map(lambda x: round(np.sin(x * np.pi / 180), 2), time_steps),
            "miss2": np.random.choice([0, 1, 2, 3, np.nan], replace=True, size=size),
         }
    )

    return df1, df2


if __name__ == '__main__':
    df1, df2 = create_dataframes()
    prof1 = ProfileReport(df1, title="p1")
    prof2 = ProfileReport(df2, title="p2")
    prof1.to_file("p1.html")
    prof2.to_file("p2.html")

@codecov-commenter
Copy link

Codecov Report

Base: 90.90% // Head: 90.90% // No change to project coverage 👍

Coverage data is based on head (02bdfc9) compared to base (36fad3c).
Patch has no changes to coverable lines.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #1149   +/-   ##
========================================
  Coverage    90.90%   90.90%           
========================================
  Files          178      178           
  Lines         5090     5090           
========================================
  Hits          4627     4627           
  Misses         463      463           
Flag Coverage Δ
py3.8-ubuntu-latest-pandas 90.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/pandas_profiling/visualisation/context.py 100.00% <ø> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report at Codecov.
📢 Do you have feedback about the report comment? Let us know in this issue.

@alexbarros alexbarros merged commit 7b73e8a into develop Nov 18, 2022
@alexbarros alexbarros deleted the fix/multithread_error_mpl branch November 18, 2022 10:32
aquemy pushed a commit that referenced this pull request Nov 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants