Skip to content

Commit 6ccce83

Browse files
committed
feat: support single line comment in the macro file
1 parent c932300 commit 6ccce83

6 files changed

Lines changed: 39 additions & 17 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/__init__.py

Lines changed: 0 additions & 14 deletions
This file was deleted.

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
@@ -162,6 +162,18 @@ def test_meta_model():
162162
},
163163
{},
164164
),
165+
# C10: comments. Expect no error is raised by textx
166+
(
167+
f"""
168+
# This is a comment
169+
load structure G1 from "{_STRUCTURE_PATH}"
170+
""",
171+
{
172+
"initialize_structures.structure_paths": _STRUCTURE_PATH,
173+
"initialize_structures.names": ["G1"],
174+
},
175+
{"G1": "structure"},
176+
),
165177
],
166178
)
167179
def test_command_processor(

0 commit comments

Comments
 (0)