intervaltree icon indicating copy to clipboard operation
intervaltree copied to clipboard

The 'copy()' method does not work properly on subclasses of IntervalTree

Open wolkiewiczk opened this issue 8 months ago • 0 comments

As in the title. It always returns IntervalTree instance instead of the subclass instance.

In [1]: from intervaltree import IntervalTree

In [2]: class MyTree(IntervalTree):
   ...:     pass
   ...: 

In [3]: t = MyTree()

In [4]: isinstance(t.copy(), MyTree)
Out[4]: False

In [5]: type(t.copy())
Out[5]: intervaltree.intervaltree.IntervalTree

The same applies to other methods that return a new IntervalTree, like intersection, union... Also __repr__ always prints IntervalTree.

wolkiewiczk avatar Jun 10 '25 10:06 wolkiewiczk