()
| 10029 | reason="https://github.com/python/cpython/issues/124538", |
| 10030 | ) |
| 10031 | def test_axes_clear_reference_cycle(): |
| 10032 | def assert_not_in_reference_cycle(start): |
| 10033 | # Breadth first search. Return True if we encounter the starting node |
| 10034 | to_visit = deque([start]) |
| 10035 | explored = set() |
| 10036 | while len(to_visit) > 0: |
| 10037 | parent = to_visit.popleft() |
| 10038 | for child in gc.get_referents(parent): |
| 10039 | if id(child) in explored: |
| 10040 | continue |
| 10041 | assert child is not start |
| 10042 | explored.add(id(child)) |
| 10043 | to_visit.append(child) |
| 10044 | |
| 10045 | fig = Figure() |
| 10046 | ax = fig.add_subplot() |
| 10047 | points = np.random.rand(1000) |
| 10048 | ax.plot(points, points) |
| 10049 | ax.scatter(points, points) |
| 10050 | ax_children = ax.get_children() |
| 10051 | fig.clear() # This should break the reference cycle |
| 10052 | |
| 10053 | # Care most about the objects that scale with number of points |
| 10054 | big_artists = [ |
| 10055 | a for a in ax_children |
| 10056 | if isinstance(a, (Line2D, PathCollection)) |
| 10057 | ] |
| 10058 | assert len(big_artists) > 0 |
| 10059 | for big_artist in big_artists: |
| 10060 | assert_not_in_reference_cycle(big_artist) |
| 10061 | assert len(ax_children) > 0 |
| 10062 | for child in ax_children: |
| 10063 | # Make sure this doesn't raise because the child is already removed. |
| 10064 | try: |
| 10065 | child.remove() |
| 10066 | except NotImplementedError: |
| 10067 | pass # not implemented is expected for some artists |
| 10068 | |
| 10069 | |
| 10070 | def test_boxplot_tick_labels(): |
nothing calls this directly
no test coverage detected
searching dependent graphs…