nebius/SWE-bench-extra huggingface dataset:
Repository: mscroggs/symfem

Issue:
Bell element is incorrect
see https://github.com/mscroggs/defelement.com/issues/224

Comments:

Patch:
diff --git a/CHANGELOG_SINCE_LAST_VERSION.md b/CHANGELOG_SINCE_LAST_VERSION.md
index 1ccf031..74e4f28 100644
--- a/CHANGELOG_SINCE_LAST_VERSION.md
+++ b/CHANGELOG_SINCE_LAST_VERSION.md
@@ -4,3 +4,4 @@
 - Added Alfeld-Sorokina element
 - Corrected C1 and higher order C tests
 - Allow element creation on non-default references
+- Corrected Bell element
diff --git a/symfem/elements/bell.py b/symfem/elements/bell.py
index 11c91b9..6c4bba8 100644
--- a/symfem/elements/bell.py
+++ b/symfem/elements/bell.py
@@ -6,13 +6,11 @@ This element's definition is given in https://doi.org/10.1002/nme.1620010108 (Be
 import typing
 
 from ..finite_element import CiarletElement
-from ..functionals import (DerivativePointEvaluation, ListOfFunctionals,
-                           NormalDerivativeIntegralMoment, PointEvaluation)
+from ..functionals import DerivativePointEvaluation, ListOfFunctionals, PointEvaluation
 from ..functions import FunctionInput
-from ..moments import make_integral_moment_dofs
 from ..polynomials import polynomial_set_1d
 from ..references import Reference
-from .lagrange import Lagrange
+from ..symbols import x
 
 
 class Bell(CiarletElement):
@@ -36,14 +34,13 @@ class Bell(CiarletElement):
             dofs.append(DerivativePointEvaluation(reference, v, (2, 0), entity=(0, v_n)))
             dofs.append(DerivativePointEvaluation(reference, v, (1, 1), entity=(0, v_n)))
             dofs.append(DerivativePointEvaluation(reference, v, (0, 2), entity=(0, v_n)))
-        dofs += make_integral_moment_dofs(
-            reference,
-            edges=(NormalDerivativeIntegralMoment, Lagrange, 0, {"variant": variant}),
-        )
         self.variant = variant
 
         poly: typing.List[FunctionInput] = []
-        poly += polynomial_set_1d(reference.tdim, order)
+        poly += polynomial_set_1d(reference.tdim, 4)
+        poly.append(x[0]**5 - x[1]**5)
+        poly.append(x[0]**3*x[1]**2 - x[0]**2*x[1]**3)
+        poly.append(5*x[0]**2*x[1]**3 - x[0]**5)
 
         super().__init__(reference, order, poly, dofs, reference.tdim, 1)
 


Test patch:
diff --git a/test/test_bell.py b/test/test_bell.py
new file mode 100644
index 0000000..ced4516
--- /dev/null
+++ b/test/test_bell.py
@@ -0,0 +1,18 @@
+"""Test Bell elements."""
+
+import symfem
+from symfem.symbols import t, x
+
+
+def test_bell_polyset():
+    b = symfem.create_element("triangle", "Bell", 5)
+    for p in b.get_polynomial_basis():
+        gradp = [p.diff(x[0]), p.diff(x[1])]
+        for en in range(b.reference.sub_entity_count(1)):
+            edge = b.reference.sub_entity(1, en)
+            variables = [o + sum(a[i] * t[0] for a in edge.axes)
+                         for i, o in enumerate(edge.origin)]
+            n = edge.normal()
+            normal_deriv = gradp[0] * n[0] + gradp[1] * n[1]
+            normal_deriv = normal_deriv.subs(x, variables)
+            assert normal_deriv.diff(t[0]).diff(t[0]).diff(t[0]).diff(t[0]) == 0
Repository: mwouts/jupytext

Issue:
.md round-tripping Broken on %%python3 magic
Just noticed this in a notebook that uses `%%python3` magic to demonstrate code execution in separate cells.

If I'm editing a markdown file in Jupyter notebook UI under Jupytext, if I have a code cell:

```
%%python3
a = 1
print(a)
```

if I save the file and then reopen it, the `%%python3` block cell magic has been stripped.

Comments:

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 9508d62..2cc996b 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -28,6 +28,7 @@ Release History
 - Fixed an inconsistent round trip (code cell with ``"cat"`` being converted to a markdown cell) in the ``py:light`` format (#339)
 - ``jupytext --test textfile.ext`` now really compares the text file to its round trip (rather than the corresponding notebook) (#339)
 - Markdown cells that contain code are now preserved in a round trip through the Markdown and R Markdown formats (#361)
+- Code cells with a ``%%python3`` cell magic are now preserved in a round trip through the Markdown format (#365)
 
 
 1.2.4 (2019-09-19)
diff --git a/jupytext/cell_reader.py b/jupytext/cell_reader.py
index 307a966..b8154ae 100644
--- a/jupytext/cell_reader.py
+++ b/jupytext/cell_reader.py
@@ -262,7 +262,7 @@ class BaseCellReader(object):
 class MarkdownCellReader(BaseCellReader):
     """Read notebook cells from Markdown documents"""
     comment = ''
-    start_code_re = re.compile(r"^```({})(.*)".format('|'.join(
+    start_code_re = re.compile(r"^```({})($|\s(.*)$)".format('|'.join(
         _JUPYTER_LANGUAGES.union({str.upper(lang) for lang in _JUPYTER_LANGUAGES})).replace('+', '\\+')))
     non_jupyter_code_re = re.compile(r"^```")
     end_code_re = re.compile(r"^```\s*$")


Test patch:
diff --git a/tests/test_read_simple_markdown.py b/tests/test_read_simple_markdown.py
index 7a074b8..8e9c38e 100644
--- a/tests/test_read_simple_markdown.py
+++ b/tests/test_read_simple_markdown.py
@@ -590,3 +590,34 @@ def test_two_markdown_cell_with_no_language_code_works(nb=new_notebook(cells=[
     text = jupytext.writes(nb, 'md')
     nb2 = jupytext.reads(text, 'md')
     compare_notebooks(nb2, nb)
+
+
+def test_notebook_with_python3_magic(no_jupytext_version_number,
+                                     nb=new_notebook(metadata={
+                                         'kernelspec': {'display_name': 'Python 3', 'language': 'python',
+                                                        'name': 'python3'}},
+                                                     cells=[new_code_cell('%%python2\na = 1\nprint a'),
+                                                            new_code_cell('%%python3\nb = 2\nprint(b)')]),
+                                     text="""---
+jupyter:
+  kernelspec:
+    display_name: Python 3
+    language: python
+    name: python3
+---
+
+```python2
+a = 1
+print a
+```
+
+```python3
+b = 2
+print(b)
+```
+"""):
+    md = jupytext.writes(nb, 'md')
+    compare(md, text)
+
+    nb2 = jupytext.reads(md, 'md')
+    compare_notebooks(nb2, nb)