<p dir="auto">I was trying to copy a <code class="notranslate">seaborn.matrix.ClusterGrid</code> object using copy.deepcopy(object) but got this error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
&lt;ipython-input-165-32d2d97b21c3&gt; in &lt;module&gt;
----&gt; 1 test3=copy.deepcopy(test)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--&gt; 180                     y = _reconstruct(x, memo, *rv)
    181 
    182     # If is its own copy, don't memoize.

/usr/lib/python3.6/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--&gt; 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--&gt; 150         y = copier(x, memo)
    151     else:
    152         try:

/usr/lib/python3.6/copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--&gt; 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--&gt; 180                     y = _reconstruct(x, memo, *rv)
    181 
    182     # If is its own copy, don't memoize.

/usr/lib/python3.6/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--&gt; 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--&gt; 150         y = copier(x, memo)
    151     else:
    152         try:

/usr/lib/python3.6/copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--&gt; 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    159             copier = getattr(x, &quot;__deepcopy__&quot;, None)
    160             if copier:
--&gt; 161                 y = copier(memo)
    162             else:
    163                 reductor = dispatch_table.get(cls)

/usr/local/lib/python3.6/dist-packages/matplotlib/transforms.py in __copy__(self, *args)
    120     def __copy__(self, *args):
    121         raise NotImplementedError(
--&gt; 122             &quot;TransformNode instances can not be copied. &quot;
    123             &quot;Consider using frozen() instead.&quot;)
    124     __deepcopy__ = __copy__

NotImplementedError: TransformNode instances can not be copied. Consider using frozen() instead."><pre class="notranslate"><code class="notranslate">---------------------------------------------------------------------------
NotImplementedError                       Traceback (most recent call last)
&lt;ipython-input-165-32d2d97b21c3&gt; in &lt;module&gt;
----&gt; 1 test3=copy.deepcopy(test)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--&gt; 180                     y = _reconstruct(x, memo, *rv)
    181 
    182     # If is its own copy, don't memoize.

/usr/lib/python3.6/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--&gt; 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--&gt; 150         y = copier(x, memo)
    151     else:
    152         try:

/usr/lib/python3.6/copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--&gt; 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    178                     y = x
    179                 else:
--&gt; 180                     y = _reconstruct(x, memo, *rv)
    181 
    182     # If is its own copy, don't memoize.

/usr/lib/python3.6/copy.py in _reconstruct(x, memo, func, args, state, listiter, dictiter, deepcopy)
    278     if state is not None:
    279         if deep:
--&gt; 280             state = deepcopy(state, memo)
    281         if hasattr(y, '__setstate__'):
    282             y.__setstate__(state)

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    148     copier = _deepcopy_dispatch.get(cls)
    149     if copier:
--&gt; 150         y = copier(x, memo)
    151     else:
    152         try:

/usr/lib/python3.6/copy.py in _deepcopy_dict(x, memo, deepcopy)
    238     memo[id(x)] = y
    239     for key, value in x.items():
--&gt; 240         y[deepcopy(key, memo)] = deepcopy(value, memo)
    241     return y
    242 d[dict] = _deepcopy_dict

/usr/lib/python3.6/copy.py in deepcopy(x, memo, _nil)
    159             copier = getattr(x, "__deepcopy__", None)
    160             if copier:
--&gt; 161                 y = copier(memo)
    162             else:
    163                 reductor = dispatch_table.get(cls)

/usr/local/lib/python3.6/dist-packages/matplotlib/transforms.py in __copy__(self, *args)
    120     def __copy__(self, *args):
    121         raise NotImplementedError(
--&gt; 122             "TransformNode instances can not be copied. "
    123             "Consider using frozen() instead.")
    124     __deepcopy__ = __copy__

NotImplementedError: TransformNode instances can not be copied. Consider using frozen() instead.
</code></pre></div>
<p dir="auto">Any ideas?</p>
<p dir="auto">Or is there any other way to duplicate an object without copying by reference?</p>
<p dir="auto">Thanks</p>
<p dir="auto">Hello,</p>
<p dir="auto">I use seaborn extensively for creating plots in my <a href="https://github.com/wdecoster/NanoPlot">NanoPlot</a> tool. Users have been reporting the following error:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="Traceback (most recent call last):
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplot/NanoPlot.py&quot;, line 61, in main
    make_plots(datadf, settings, args)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplot/NanoPlot.py&quot;, line 260, in make_plots
    log=settings[&quot;logBool&quot;])
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplotter/nanoplotter.py&quot;, line 250, in length_plots
    kde_kws={&quot;label&quot;: name, &quot;clip&quot;: (0, maxvalx)})
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py&quot;, line 224, in distplot
    kdeplot(a, vertical=vertical, ax=ax, color=kde_color, **kde_kws)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py&quot;, line 657, in kdeplot
    cumulative=cumulative, **kwargs)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py&quot;, line 273, in _univariate_kdeplot
    cumulative=cumulative)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py&quot;, line 345, in _statsmodels_univariate_kde
    kde.fit(kernel, bw, fft, gridsize=gridsize, cut=cut, clip=clip)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kde.py&quot;, line 146, in fit
    clip=clip, cut=cut)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kde.py&quot;, line 506, in kdensityfft
    f = revrt(zstar)
  File &quot;/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py&quot;, line 20, in revrt
    y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j
TypeError: slice indices must be integers or None or have an __index__ method"><pre class="notranslate"><code class="notranslate">Traceback (most recent call last):
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplot/NanoPlot.py", line 61, in main
    make_plots(datadf, settings, args)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplot/NanoPlot.py", line 260, in make_plots
    log=settings["logBool"])
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/nanoplotter/nanoplotter.py", line 250, in length_plots
    kde_kws={"label": name, "clip": (0, maxvalx)})
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py", line 224, in distplot
    kdeplot(a, vertical=vertical, ax=ax, color=kde_color, **kde_kws)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py", line 657, in kdeplot
    cumulative=cumulative, **kwargs)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py", line 273, in _univariate_kdeplot
    cumulative=cumulative)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/seaborn/distributions.py", line 345, in _statsmodels_univariate_kde
    kde.fit(kernel, bw, fft, gridsize=gridsize, cut=cut, clip=clip)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kde.py", line 146, in fit
    clip=clip, cut=cut)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kde.py", line 506, in kdensityfft
    f = revrt(zstar)
  File "/users/218819/scratch/apps/Anaconda3/lib/python3.5/site-packages/statsmodels/nonparametric/kdetools.py", line 20, in revrt
    y = X[:m/2+1] + np.r_[0,X[m/2+1:],0]*1j
TypeError: slice indices must be integers or None or have an __index__ method
</code></pre></div>
<p dir="auto"><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="303698582" data-permission-text="Title is private" data-url="https://github.com/wdecoster/NanoPlot/issues/52" data-hovercard-type="issue" data-hovercard-url="/wdecoster/NanoPlot/issues/52/hovercard" href="https://github.com/wdecoster/NanoPlot/issues/52">wdecoster/NanoPlot#52</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="304094211" data-permission-text="Title is private" data-url="https://github.com/wdecoster/nanopack/issues/5" data-hovercard-type="issue" data-hovercard-url="/wdecoster/nanopack/issues/5/hovercard" href="https://github.com/wdecoster/nanopack/issues/5">wdecoster/nanopack#5</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="271441178" data-permission-text="Title is private" data-url="https://github.com/wdecoster/NanoPlot/issues/23" data-hovercard-type="issue" data-hovercard-url="/wdecoster/NanoPlot/issues/23/hovercard" href="https://github.com/wdecoster/NanoPlot/issues/23">wdecoster/NanoPlot#23</a><br>
<a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="295385385" data-permission-text="Title is private" data-url="https://github.com/wdecoster/NanoPlot/issues/45" data-hovercard-type="issue" data-hovercard-url="/wdecoster/NanoPlot/issues/45/hovercard" href="https://github.com/wdecoster/NanoPlot/issues/45">wdecoster/NanoPlot#45</a></p>
<p dir="auto">See also <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="203199137" data-permission-text="Title is private" data-url="https://github.com/mwaskom/seaborn/issues/1103" data-hovercard-type="issue" data-hovercard-url="/mwaskom/seaborn/issues/1103/hovercard" href="https://github.com/mwaskom/seaborn/issues/1103">#1103</a> and <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="200843640" data-permission-text="Title is private" data-url="https://github.com/mwaskom/seaborn/issues/1092" data-hovercard-type="issue" data-hovercard-url="/mwaskom/seaborn/issues/1092/hovercard" href="https://github.com/mwaskom/seaborn/issues/1092">#1092</a> for the same problem</p>
<p dir="auto">Would it make sense to make seaborn depend on statsmodels&gt;=0.8.0 or a recent scipy version? I'd be happy to open a PR for this if you agree.</p>
<p dir="auto">Cheers,<br>
Wouter</p>