Skip to content

Commit ed1132d

Browse files
committed
🎨 limit remaining lines to 90 characters
1 parent 206deab commit ed1132d

File tree

9 files changed

+350
-216
lines changed

9 files changed

+350
-216
lines changed

src/vuegen/quarto_reportview.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -709,14 +709,20 @@ def _generate_plot_code(self, plot, output_file="") -> str:
709709
plot_code += textwrap.dedent(
710710
"""
711711
# Keep only 'data' and 'layout' sections
712-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}\n
712+
plot_json = {key: plot_json[key] for key in plot_json
713+
if key in ['data', 'layout']
714+
}
713715
# Remove 'frame' section in 'data'
714-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]\n
716+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
717+
for entry in plot_json.get('data', [])
718+
]
715719
# Convert JSON to string
716-
plot_json_str = json.dumps(plot_json)\n
720+
plot_json_str = json.dumps(plot_json)
717721
# Create the plotly plot
718722
fig_plotly = pio.from_json(plot_json_str)
719-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
723+
fig_plotly.update_layout(autosize=False, width=950, height=400,
724+
margin=dict(b=50, t=50, l=50, r=50)
725+
)
720726
"""
721727
)
722728
elif plot.plot_type == r.PlotType.ALTAIR:
@@ -726,7 +732,8 @@ def _generate_plot_code(self, plot, output_file="") -> str:
726732
plot_json_str = json.dumps(plot_json)
727733
728734
# Create the altair plot
729-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
735+
fig_altair = alt.Chart.from_json(plot_json_str
736+
).properties(width=900, height=370)
730737
"""
731738
)
732739
elif plot.plot_type == r.PlotType.INTERACTIVE_NETWORK:
@@ -742,7 +749,9 @@ def _generate_plot_code(self, plot, output_file="") -> str:
742749
plot_code = textwrap.dedent(
743750
f"""
744751
<div style="text-align: center;">
745-
<iframe src="{iframe_src}" alt="{plot.title} plot" width="800px" height="630px"></iframe>
752+
<iframe src="{iframe_src}" alt="{plot.title} plot"
753+
width="800px" height="630px">
754+
</iframe>
746755
</div>
747756
"""
748757
)

tests/report_examples/Basic_example_vuegen_demo_notebook/docx/quarto_report/quarto_report.qmd

Lines changed: 40 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
4242
plot_json = json.load(plot_file)
4343
4444
# Keep only 'data' and 'layout' sections
45-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
46-
45+
plot_json = {key: plot_json[key] for key in plot_json
46+
if key in ['data', 'layout']
47+
}
4748
# Remove 'frame' section in 'data'
48-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
49-
49+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
50+
for entry in plot_json.get('data', [])
51+
]
5052
# Convert JSON to string
5153
plot_json_str = json.dumps(plot_json)
52-
5354
# Create the plotly plot
5455
fig_plotly = pio.from_json(plot_json_str)
55-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
56+
fig_plotly.update_layout(autosize=False, width=950, height=400,
57+
margin=dict(b=50, t=50, l=50, r=50)
58+
)
5659
5760
fig_plotly.write_image("static/Top_Species_Plot_By_Biome_Plotly.png")
5861
```
@@ -72,7 +75,8 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
7275
plot_json_str = json.dumps(plot_json)
7376
7477
# Create the altair plot
75-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
78+
fig_altair = alt.Chart.from_json(plot_json_str
79+
).properties(width=900, height=370)
7680
7781
fig_altair.save("static/Multiline_Plot_Altair.png")
7882
```
@@ -89,17 +93,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
8993
plot_json = json.load(plot_file)
9094
9195
# Keep only 'data' and 'layout' sections
92-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
93-
96+
plot_json = {key: plot_json[key] for key in plot_json
97+
if key in ['data', 'layout']
98+
}
9499
# Remove 'frame' section in 'data'
95-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
96-
100+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
101+
for entry in plot_json.get('data', [])
102+
]
97103
# Convert JSON to string
98104
plot_json_str = json.dumps(plot_json)
99-
100105
# Create the plotly plot
101106
fig_plotly = pio.from_json(plot_json_str)
102-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
107+
fig_plotly.update_layout(autosize=False, width=950, height=400,
108+
margin=dict(b=50, t=50, l=50, r=50)
109+
)
103110
104111
fig_plotly.write_image("static/Pie_Plot_Countries_Plotly.png")
105112
```
@@ -116,17 +123,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
116123
plot_json = json.load(plot_file)
117124
118125
# Keep only 'data' and 'layout' sections
119-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
120-
126+
plot_json = {key: plot_json[key] for key in plot_json
127+
if key in ['data', 'layout']
128+
}
121129
# Remove 'frame' section in 'data'
122-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
123-
130+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
131+
for entry in plot_json.get('data', [])
132+
]
124133
# Convert JSON to string
125134
plot_json_str = json.dumps(plot_json)
126-
127135
# Create the plotly plot
128136
fig_plotly = pio.from_json(plot_json_str)
129-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
137+
fig_plotly.update_layout(autosize=False, width=950, height=400,
138+
margin=dict(b=50, t=50, l=50, r=50)
139+
)
130140
131141
fig_plotly.write_image("static/Pie_Plots_Biomes_Plotly.png")
132142
```
@@ -146,7 +156,8 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
146156
plot_json_str = json.dumps(plot_json)
147157
148158
# Create the altair plot
149-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
159+
fig_altair = alt.Chart.from_json(plot_json_str
160+
).properties(width=900, height=370)
150161
151162
fig_altair.save("static/Saline_Metagenomics_Samples_Map_Altair.png")
152163
```
@@ -163,17 +174,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
163174
plot_json = json.load(plot_file)
164175
165176
# Keep only 'data' and 'layout' sections
166-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
167-
177+
plot_json = {key: plot_json[key] for key in plot_json
178+
if key in ['data', 'layout']
179+
}
168180
# Remove 'frame' section in 'data'
169-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
170-
181+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
182+
for entry in plot_json.get('data', [])
183+
]
171184
# Convert JSON to string
172185
plot_json_str = json.dumps(plot_json)
173-
174186
# Create the plotly plot
175187
fig_plotly = pio.from_json(plot_json_str)
176-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
188+
fig_plotly.update_layout(autosize=False, width=950, height=400,
189+
margin=dict(b=50, t=50, l=50, r=50)
190+
)
177191
178192
fig_plotly.write_image("static/Plotly_Plot_R.png")
179193
```

tests/report_examples/Basic_example_vuegen_demo_notebook/html/quarto_report/quarto_report.qmd

Lines changed: 46 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -68,17 +68,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
6868
plot_json = json.load(plot_file)
6969
7070
# Keep only 'data' and 'layout' sections
71-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
72-
71+
plot_json = {key: plot_json[key] for key in plot_json
72+
if key in ['data', 'layout']
73+
}
7374
# Remove 'frame' section in 'data'
74-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
75-
75+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
76+
for entry in plot_json.get('data', [])
77+
]
7678
# Convert JSON to string
7779
plot_json_str = json.dumps(plot_json)
78-
7980
# Create the plotly plot
8081
fig_plotly = pio.from_json(plot_json_str)
81-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
82+
fig_plotly.update_layout(autosize=False, width=950, height=400,
83+
margin=dict(b=50, t=50, l=50, r=50)
84+
)
8285
8386
fig_plotly.show()
8487
```
@@ -96,7 +99,8 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
9699
plot_json_str = json.dumps(plot_json)
97100
98101
# Create the altair plot
99-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
102+
fig_altair = alt.Chart.from_json(plot_json_str
103+
).properties(width=900, height=370)
100104
101105
fig_altair
102106
```
@@ -111,17 +115,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
111115
plot_json = json.load(plot_file)
112116
113117
# Keep only 'data' and 'layout' sections
114-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
115-
118+
plot_json = {key: plot_json[key] for key in plot_json
119+
if key in ['data', 'layout']
120+
}
116121
# Remove 'frame' section in 'data'
117-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
118-
122+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
123+
for entry in plot_json.get('data', [])
124+
]
119125
# Convert JSON to string
120126
plot_json_str = json.dumps(plot_json)
121-
122127
# Create the plotly plot
123128
fig_plotly = pio.from_json(plot_json_str)
124-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
129+
fig_plotly.update_layout(autosize=False, width=950, height=400,
130+
margin=dict(b=50, t=50, l=50, r=50)
131+
)
125132
126133
fig_plotly.show()
127134
```
@@ -136,17 +143,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
136143
plot_json = json.load(plot_file)
137144
138145
# Keep only 'data' and 'layout' sections
139-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
140-
146+
plot_json = {key: plot_json[key] for key in plot_json
147+
if key in ['data', 'layout']
148+
}
141149
# Remove 'frame' section in 'data'
142-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
143-
150+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
151+
for entry in plot_json.get('data', [])
152+
]
144153
# Convert JSON to string
145154
plot_json_str = json.dumps(plot_json)
146-
147155
# Create the plotly plot
148156
fig_plotly = pio.from_json(plot_json_str)
149-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
157+
fig_plotly.update_layout(autosize=False, width=950, height=400,
158+
margin=dict(b=50, t=50, l=50, r=50)
159+
)
150160
151161
fig_plotly.show()
152162
```
@@ -164,7 +174,8 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
164174
plot_json_str = json.dumps(plot_json)
165175
166176
# Create the altair plot
167-
fig_altair = alt.Chart.from_json(plot_json_str).properties(width=900, height=370)
177+
fig_altair = alt.Chart.from_json(plot_json_str
178+
).properties(width=900, height=370)
168179
169180
fig_altair
170181
```
@@ -179,17 +190,20 @@ with open(report_dir /'../../../../../docs/example_data/Basic_example_vuegen_dem
179190
plot_json = json.load(plot_file)
180191
181192
# Keep only 'data' and 'layout' sections
182-
plot_json = {key: plot_json[key] for key in plot_json if key in ['data', 'layout']}
183-
193+
plot_json = {key: plot_json[key] for key in plot_json
194+
if key in ['data', 'layout']
195+
}
184196
# Remove 'frame' section in 'data'
185-
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'} for entry in plot_json.get('data', [])]
186-
197+
plot_json['data'] = [{k: v for k, v in entry.items() if k != 'frame'}
198+
for entry in plot_json.get('data', [])
199+
]
187200
# Convert JSON to string
188201
plot_json_str = json.dumps(plot_json)
189-
190202
# Create the plotly plot
191203
fig_plotly = pio.from_json(plot_json_str)
192-
fig_plotly.update_layout(autosize=False, width=950, height=400, margin=dict(b=50, t=50, l=50, r=50))
204+
fig_plotly.update_layout(autosize=False, width=950, height=400,
205+
margin=dict(b=50, t=50, l=50, r=50)
206+
)
193207
194208
fig_plotly.show()
195209
```
@@ -278,7 +292,9 @@ Optional description for subsection.
278292

279293

280294
<div style="text-align: center;">
281-
<iframe src="static/Man_Example.html" alt="Man Example plot" width="800px" height="630px"></iframe>
295+
<iframe src="static/Man_Example.html" alt="Man Example plot"
296+
width="800px" height="630px">
297+
</iframe>
282298
</div>
283299

284300
## Static Networks
@@ -301,7 +317,9 @@ Optional description for subsection.
301317

302318

303319
<div style="text-align: center;">
304-
<iframe src="../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/2_ckg_network.html" alt="Ckg Network plot" width="800px" height="630px"></iframe>
320+
<iframe src="../../../../../docs/example_data/Basic_example_vuegen_demo_notebook/4_Html/1_All_html/2_ckg_network.html" alt="Ckg Network plot"
321+
width="800px" height="630px">
322+
</iframe>
305323
</div>
306324

307325
### Multiqc Report

0 commit comments

Comments
 (0)