Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Strict mode #118

Merged
merged 6 commits into from
Jul 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -152,3 +152,4 @@ tmp.tex
tests/out.pdf

.vscode/*
tmp-*
6 changes: 0 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,3 @@ repos:
hooks:
- id: isort
args: ["--profile", "black"]

- repo: https://github.com/asottile/pyupgrade
rev: v1.25.0
hooks:
- id: pyupgrade
args: [--py36-plus]
2 changes: 1 addition & 1 deletion debug/feynman.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion debug/feynmp.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/gallery/overleaf/overleaf.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/gallery/pyfeyn/pyfeyn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.9.16"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
2 changes: 1 addition & 1 deletion docs/source/renderers/latex/tikz/tikzfeynman.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -517,7 +517,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
"version": "3.11.4"
}
},
"nbformat": 4,
Expand Down
14 changes: 7 additions & 7 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion pyfeyn2/render/latex/tikzfeynman.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@
from typing import List
from warnings import warn

from feynml.connector import Connector
from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.vertex import Vertex
from pylatex import Command
from pylatex.utils import NoEscape

from pyfeyn2.feynmandiagram import Connector, FeynmanDiagram, Leg, Vertex
from pyfeyn2.render.latex.latex import LatexRender

# converte FeynmanDiagram to tikz-feynman
Expand Down
5 changes: 4 additions & 1 deletion pyfeyn2/render/render.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import abc
from typing import List

from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex
from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.propagator import Propagator
from feynml.vertex import Vertex


class Render:
Expand Down
3 changes: 2 additions & 1 deletion pyfeyn2/render/text/ascii.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
from typing import List
from warnings import warn

from pyfeyn2.feynmandiagram import Point
from feynml.point import Point

from pyfeyn2.render.render import Render
from pyfeyn2.render.text.label import Label
from pyfeyn2.render.text.line import ASCIILine
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ mkfeyndiag = "pyfeyn2.mkfeyndiag:main"
optional = true

[tool.poetry.group.docs.dependencies]
sphinx = "*"
sphinx = "<7.0.0"
sphinx-rtd-theme = "*"
sphinxcontrib-napoleon = "*"
nbsphinx = "*"
Expand Down
3 changes: 1 addition & 2 deletions pytest.ini
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
[pytest]
minversion = 6.0
addopts = -v --cov=pyfeyn2 --cov-config=.coveragerc --cov-append --cov-report=term --cov-report=xml --doctest-modules --ignore=docs/source/conf.py
pytest_plugins = ['pytest_profiling']
addopts = -Werror -v --cov=pyfeyn2 --cov-config=.coveragerc --cov-append --cov-report=term --cov-report=xml --doctest-modules --ignore=docs/source/conf.py
5 changes: 4 additions & 1 deletion tests/test_all.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.propagator import Propagator
from feynml.vertex import Vertex
from matplotlib import pyplot as plt

from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex
from pyfeyn2.render.all import AllRender


Expand Down
6 changes: 3 additions & 3 deletions tests/test_dot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from pyfeyn2.render.latex.dot import DotRender, feynman_to_dot
from tests.test_feynman import test_gluons, test_many_gluons
from tests.test_feynman import get_test_gluons, get_test_many_gluons


def test_dot():
fd = test_gluons()
fd = get_test_gluons()

print(feynman_to_dot(fd))
dr = DotRender(fd)
Expand All @@ -12,7 +12,7 @@ def test_dot():


def test_dot2():
fd = test_many_gluons()
fd = get_test_many_gluons()

print(feynman_to_dot(fd))
dr = DotRender(fd)
Expand Down
9 changes: 6 additions & 3 deletions tests/test_feynman.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex
from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.propagator import Propagator
from feynml.vertex import Vertex


def test_gluons():
def get_test_gluons():
fd = FeynmanDiagram()
v1 = Vertex("v1").with_xy(-1, 0)
v2 = Vertex("v2").with_xy(1, 0)
Expand All @@ -18,7 +21,7 @@ def test_gluons():
return fd


def test_many_gluons():
def get_test_many_gluons():
fd = FeynmanDiagram()
v1 = Vertex("v1")
v2 = Vertex("v2")
Expand Down
22 changes: 10 additions & 12 deletions tests/test_fml.py
Original file line number Diff line number Diff line change
@@ -1,21 +1,19 @@
from pathlib import Path

# Load an FML file and check that it is the same as the original
# FeynmanDiagram object
from feynml.feynmandiagram import FeynmanDiagram
from feynml.feynml import FeynML
from feynml.head import Head
from feynml.leg import Leg
from feynml.meta import Meta
from feynml.momentum import Momentum
from feynml.propagator import Propagator
from feynml.vertex import Vertex
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig

# Load an FML file and check that it is the same as the original
# FeynmanDiagram object
from pyfeyn2.feynmandiagram import (
FeynmanDiagram,
FeynML,
Head,
Leg,
Meta,
Momentum,
Propagator,
Vertex,
)
from pyfeyn2.render.pyx.pyxrender import PyxRender


Expand Down
5 changes: 4 additions & 1 deletion tests/test_renders.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
import pytest
from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.propagator import Propagator
from feynml.vertex import Vertex

from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex
from pyfeyn2.render.all import AllRender, renders


Expand Down
6 changes: 3 additions & 3 deletions tests/test_text.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pyfeyn2.auto.position import feynman_adjust_points
from pyfeyn2.render.text.ascii import ASCIIRender
from pyfeyn2.render.text.unicode import UnicodeRender
from tests.test_feynman import test_many_gluons
from tests.test_feynman import get_test_many_gluons


def test_ascii():
fd = test_many_gluons()
fd = get_test_many_gluons()
fd = feynman_adjust_points(fd, clear_vertices=True)

tfd = ASCIIRender(fd)
Expand All @@ -14,7 +14,7 @@ def test_ascii():


def test_unicode():
fd = test_many_gluons()
fd = get_test_many_gluons()
fd = feynman_adjust_points(fd, clear_vertices=True)

tfd = UnicodeRender(fd)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tikz.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
from pyfeyn2.auto.position import feynman_adjust_points
from pyfeyn2.render.latex.tikzfeynman import TikzFeynmanRender
from tests.test_feynman import test_gluons, test_many_gluons
from tests.test_feynman import get_test_gluons, get_test_many_gluons


def test_tikz():
fd = test_gluons()
fd = get_test_gluons()

tfd = TikzFeynmanRender(fd)
print(tfd.get_src())
tfd.render("test.pdf")


def test_dot_positions():
fd = test_many_gluons()
fd = get_test_many_gluons()
fd = feynman_adjust_points(fd, clear_vertices=True)

tfd = TikzFeynmanRender(fd)
Expand Down
6 changes: 4 additions & 2 deletions tests/test_xml.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
from pathlib import Path

from feynml.feynmandiagram import FeynmanDiagram
from feynml.leg import Leg
from feynml.propagator import Propagator
from feynml.vertex import Vertex
from xsdata.formats.dataclass.parsers import XmlParser
from xsdata.formats.dataclass.serializers import XmlSerializer
from xsdata.formats.dataclass.serializers.config import SerializerConfig

from pyfeyn2.feynmandiagram import FeynmanDiagram, Leg, Propagator, Vertex


def test_print_as_xml():
fd = FeynmanDiagram()
Expand Down
Loading