Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit eb8c12a

Browse filesBrowse files
committed
Fix matplotlib#25032 for plot_types
1 parent 6378d48 commit eb8c12a
Copy full SHA for eb8c12a

File tree

Expand file treeCollapse file tree

1 file changed

+53
-15
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+53
-15
lines changed

‎doc/sphinxext/gallery_order.py

Copy file name to clipboardExpand all lines: doc/sphinxext/gallery_order.py
+53-15Lines changed: 53 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,36 @@
44
"""
55

66
from sphinx_gallery.sorting import ExplicitOrder
7+
import os
8+
9+
10+
# Utility functions
11+
def get_ordering(dir):
12+
"""Read gallery_order.txt in dir and return content of the file as a List"""
13+
file_path = os.path.join(dir, 'gallery_order.txt')
14+
f = open(file_path, "r")
15+
lines = [line.replace('\n', '') for line in f.readlines()]
16+
ordered_list = []
17+
for line in lines:
18+
if line == "unsorted":
19+
ordered_list.append(UNSORTED)
20+
else:
21+
ordered_list.append(line)
22+
23+
return ordered_list
24+
25+
26+
def list_directory(parent_dir):
27+
"""Return list of sub directories at a directory"""
28+
root, dirs, files = next(os.walk(parent_dir))
29+
return [os.path.join(root, dir) for dir in dirs]
730

831
# Gallery sections shall be displayed in the following order.
932
# Non-matching sections are inserted at the unsorted position
1033

1134
UNSORTED = "unsorted"
1235

36+
1337
examples_order = [
1438
'../galleries/examples/lines_bars_and_markers',
1539
'../galleries/examples/images_contours_and_fields',
@@ -36,17 +60,20 @@
3660
'../galleries/tutorials/provisional'
3761
]
3862

39-
plot_types_order = [
40-
'../galleries/plot_types/basic',
41-
'../galleries/plot_types/stats',
42-
'../galleries/plot_types/arrays',
43-
'../galleries/plot_types/unstructured',
44-
'../galleries/plot_types/3D',
45-
UNSORTED
46-
]
63+
# plot_types_order = [
64+
# '../galleries/plot_types/basic',
65+
# '../galleries/plot_types/stats',
66+
# '../galleries/plot_types/arrays',
67+
# '../galleries/plot_types/unstructured',
68+
# '../galleries/plot_types/3D',
69+
# UNSORTED
70+
# ]
4771

48-
folder_lists = [examples_order, tutorials_order, plot_types_order]
72+
plot_types_directory = "../galleries/plot_types/"
73+
plot_types_order = get_ordering(plot_types_directory)
4974

75+
76+
folder_lists = [examples_order, tutorials_order, plot_types_order]
5077
explicit_order_folders = [fd for folders in folder_lists
5178
for fd in folders[:folders.index(UNSORTED)]]
5279
explicit_order_folders.append(UNSORTED)
@@ -89,19 +116,30 @@ def __call__(self, item):
89116

90117
# **Plot Types
91118
# Basic
92-
"plot", "scatter_plot", "bar", "stem", "step", "fill_between",
119+
# "plot", "scatter_plot", "bar", "stem", "step", "fill_between",
93120
# Arrays
94-
"imshow", "pcolormesh", "contour", "contourf",
95-
"barbs", "quiver", "streamplot",
121+
# "imshow", "pcolormesh", "contour", "contourf",
122+
# "barbs", "quiver", "streamplot",
96123
# Stats
97-
"hist_plot", "boxplot_plot", "errorbar_plot", "violin",
98-
"eventplot", "hist2d", "hexbin", "pie",
124+
# "hist_plot", "boxplot_plot", "errorbar_plot", "violin",
125+
# "eventplot", "hist2d", "hexbin", "pie",
99126
# Unstructured
100-
"tricontour", "tricontourf", "tripcolor", "triplot",
127+
# "tricontour", "tricontourf", "tripcolor", "triplot",
101128
# Spines
102129
"spines", "spine_placement_demo", "spines_dropped",
103130
"multiple_yaxis_with_spines", "centered_spines_with_arrows",
104131
]
132+
133+
134+
for dir in list_directory(plot_types_directory):
135+
try:
136+
ordered_subdirs = get_ordering(dir)
137+
list_all.extend(ordered_subdirs)
138+
except FileNotFoundError:
139+
# Fallback to ordering already defined in list_all
140+
pass
141+
142+
105143
explicit_subsection_order = [item + ".py" for item in list_all]
106144

107145

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.