You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
Cell In[10], line 1
----> 1 sktree.copy()
File ~/miniconda3/envs/dynomics/lib/python3.9/site-packages/skbio/tree/_tree.py:514, in TreeNode.copy(self)
511 result.__dict__[key] = deepcopy(node_to_copy.__dict__[key])
512 return result
--> 514 root = __copy_node(self)
515 nodes_stack = [[root, self, len(self.children)]]
517 while nodes_stack:
518 # check the top node, any children left unvisited?
File ~/miniconda3/envs/dynomics/lib/python3.9/site-packages/skbio/tree/_tree.py:511, in TreeNode.copy.<locals>.__copy_node(node_to_copy)
509 for key in node_to_copy.__dict__:
510 if key not in efc:
--> 511 result.__dict__[key] = deepcopy(node_to_copy.__dict__[key])
512 return result
File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:146, in deepcopy(x, memo, _nil)
144 copier = _deepcopy_dispatch.get(cls)
145 if copier is not None:
--> 146 y = copier(x, memo)
147 else:
148 if issubclass(cls, type):
File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:237, in _deepcopy_method(x, memo)
236 def _deepcopy_method(x, memo): # Copy instance methods
--> 237 return type(x)(x.__func__, deepcopy(x.__self__, memo))
File ~/miniconda3/envs/dynomics/lib/python3.9/copy.py:153, in deepcopy(x, memo, _nil)
151 copier = getattr(x, "__deepcopy__", None)
152 if copier is not None:
--> 153 y = copier(memo)
154 else:
155 reductor = dispatch_table.get(cls)
TypeError: copy() takes 1 positional argument but 2 were given
But running tree = skbio.TreeNode.read('16S_taxa.biom.nwk').copy() doesn't return such an error, hinting at the skbio.TreeNode conversion in this package.
Now, this does not occur in iow==1.0.3 suggesting that this is a recent error.
The text was updated successfully, but these errors were encountered:
In the bigger picture, I think that the TreeNode.copy method is not ideal, and is both confusing and surprising in its operation. I remember digging into this error when exploring this before, and I think what's going on is the wrong branch is triggered in deepcopy although the code referenced here I think has gone through some changes in recent versions of Python.
I think fixing this should be done upstream in skbio. As a work around, one possibility for a true deepcopy sans any attributes would be to serialize / deserialize:
This is a weird issue.
yields the following error
But running
tree = skbio.TreeNode.read('16S_taxa.biom.nwk').copy()
doesn't return such an error, hinting at the skbio.TreeNode conversion in this package.Now, this does not occur in iow==1.0.3 suggesting that this is a recent error.
The text was updated successfully, but these errors were encountered: