Skip to content

Commit 85d1242

Browse files
authored
Merge pull request #19 from ycexiao/single-line-comment
feat: support single line comment in the macro file
2 parents a1463c3 + c9cb44b commit 85d1242

5 files changed

Lines changed: 39 additions & 3 deletions

File tree

news/single-line-comment.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Support single line comment in the macro file.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/apps/app_runmacro.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@
4545
RawValue:
4646
/[^\s]+/
4747
;
48+
49+
50+
Comment: /#[^\n]*/;
4851
"""
4952

5053

src/diffpy/apps/pdfadapter.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@
33
from pathlib import Path
44

55
import numpy
6-
from scipy.optimize import least_squares
7-
86
from diffpy.srfit.fitbase import (
97
FitContribution,
108
FitRecipe,
@@ -14,6 +12,7 @@
1412
from diffpy.srfit.pdf import PDFGenerator, PDFParser
1513
from diffpy.srfit.structure import constrainAsSpaceGroup
1614
from diffpy.structure.parsers import getParser
15+
from scipy.optimize import least_squares
1716

1817

1918
class PDFAdapter:

tests/helper.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import numpy as np
2-
32
from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile
43
from diffpy.srfit.pdf import PDFGenerator, PDFParser
54
from diffpy.srfit.structure import constrainAsSpaceGroup

tests/test_runmacro.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,18 @@ def test_meta_model():
163163
},
164164
{},
165165
),
166+
# C10: comments. Expect no error is raised by textx
167+
(
168+
f"""
169+
# This is a comment
170+
load structure G1 from "{_STRUCTURE_PATH}"
171+
""",
172+
{
173+
"initialize_structures.structure_paths": _STRUCTURE_PATH,
174+
"initialize_structures.names": ["G1"],
175+
},
176+
{"G1": "structure"},
177+
),
166178
],
167179
)
168180
def test_command_processor(

0 commit comments

Comments
 (0)