Skip to content

Commit 8be7663

Browse files
authored
Update example gallery (#315)
* Add coment * Add wikipedia like examples Closes: #85 * Add feynmf examples * Update gallery * Fix serializer config indent
1 parent 04b08b5 commit 8be7663

File tree

17 files changed

+3258
-34
lines changed

17 files changed

+3258
-34
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,3 +153,4 @@ tests/out.pdf
153153

154154
.vscode/*
155155
tmp-*
156+
pyfeyn2/version.py
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
.. _label-side:
2+
3+
label-side
4+
=========
5+
| Valid on: :ref:`leg`, :ref:`propagator`
6+
| Format: String
7+
| Values: left, right
8+
| Default: left
9+
10+
Put the label to the left in the direction of the line or right.
11+
12+
.. include:: ../../../shared/style/label-side.rst

docs/source/gallery/all/all.ipynb

Lines changed: 2122 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/gallery/feynman/feynman.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,7 @@
2727
"cell_type": "code",
2828
"execution_count": 2,
2929
"id": "ee2b54da",
30-
"metadata": {
31-
"scrolled": false
32-
},
30+
"metadata": {},
3331
"outputs": [
3432
{
3533
"name": "stdout",
@@ -218,7 +216,7 @@
218216
"name": "python",
219217
"nbconvert_exporter": "python",
220218
"pygments_lexer": "ipython3",
221-
"version": "3.9.16"
219+
"version": "3.12.9"
222220
}
223221
},
224222
"nbformat": 4,

docs/source/gallery/feynmf/feynmf.ipynb

Lines changed: 607 additions & 0 deletions
Large diffs are not rendered by default.

docs/source/gallery/overleaf/overleaf.ipynb

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@
2626
"cell_type": "code",
2727
"execution_count": 3,
2828
"id": "0a179236",
29-
"metadata": {
30-
"scrolled": false
31-
},
29+
"metadata": {},
3230
"outputs": [
3331
{
3432
"name": "stdout",
@@ -250,9 +248,7 @@
250248
"cell_type": "code",
251249
"execution_count": 4,
252250
"id": "6446cf50",
253-
"metadata": {
254-
"scrolled": false
255-
},
251+
"metadata": {},
256252
"outputs": [
257253
{
258254
"name": "stdout",
@@ -474,9 +470,7 @@
474470
"cell_type": "code",
475471
"execution_count": 5,
476472
"id": "ede56f63",
477-
"metadata": {
478-
"scrolled": false
479-
},
473+
"metadata": {},
480474
"outputs": [
481475
{
482476
"name": "stdout",
@@ -769,7 +763,7 @@
769763
"name": "python",
770764
"nbconvert_exporter": "python",
771765
"pygments_lexer": "ipython3",
772-
"version": "3.11.4"
766+
"version": "3.13.2"
773767
}
774768
},
775769
"nbformat": 4,

docs/source/gallery/pyfeyn/pyfeyn.ipynb

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@
2929
"cell_type": "code",
3030
"execution_count": 2,
3131
"id": "d4b571dd",
32-
"metadata": {
33-
"scrolled": false
34-
},
32+
"metadata": {},
3533
"outputs": [
3634
{
3735
"name": "stdout",
@@ -507,7 +505,7 @@
507505
"name": "python",
508506
"nbconvert_exporter": "python",
509507
"pygments_lexer": "ipython3",
510-
"version": "3.11.4"
508+
"version": "3.13.2"
511509
}
512510
},
513511
"nbformat": 4,

docs/source/gallery/wikipedia/wikipedia.ipynb

Lines changed: 425 additions & 0 deletions
Large diffs are not rendered by default.

pyfeyn2/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""PyFeyn2: A Python package for drawing Feynman diagrams."""
2-
from importlib.metadata import version
2+
# Convenient access to the version number
3+
from .version import version as __version__ # noqa: F401
34

45
package = "pyfeyn2"
5-
6-
__version__ = version(package)

pyfeyn2/auto/__init__.py

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import numpy as np
2+
3+
from pyfeyn2.auto.bend import auto_bend
4+
from pyfeyn2.auto.debug import auto_debug
5+
from pyfeyn2.auto.label import auto_label
6+
from pyfeyn2.auto.position import (
7+
auto_align_legs,
8+
auto_remove_intersections_by_permuting_legs,
9+
auto_vdw,
10+
)
11+
12+
13+
def auto_default(
14+
fd,
15+
auto_position=True,
16+
auto_position_legs=True,
17+
debug=False,
18+
):
19+
if auto_position:
20+
# remove all unpositioned vertices
21+
if auto_position_legs:
22+
fd = auto_align_legs(
23+
fd,
24+
incoming=[(0, i) for i in np.linspace(0, 10, len(fd.get_incoming()))],
25+
outgoing=[(10, i) for i in np.linspace(0, 10, len(fd.get_outgoing()))],
26+
)
27+
p = [v for v in fd.vertices if v.x is None or v.y is None]
28+
if len(p) > 0:
29+
fd = auto_vdw(fd, points=p)
30+
if auto_position_legs:
31+
auto_remove_intersections_by_permuting_legs(fd, adjust_points=True)
32+
if len(p) > 0:
33+
fd = auto_vdw(fd, points=p)
34+
auto_label([*fd.propagators, *fd.legs])
35+
fd = auto_bend(fd)
36+
# Last step enable debug
37+
if debug:
38+
auto_debug(fd)
39+
return fd

0 commit comments

Comments
 (0)