diff --git a/news/single-line-comment.rst b/news/single-line-comment.rst new file mode 100644 index 0000000..14c0170 --- /dev/null +++ b/news/single-line-comment.rst @@ -0,0 +1,23 @@ +**Added:** + +* Support single line comment in the macro file. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/apps/app_runmacro.py b/src/diffpy/apps/app_runmacro.py index 47330dd..4ac47a7 100644 --- a/src/diffpy/apps/app_runmacro.py +++ b/src/diffpy/apps/app_runmacro.py @@ -45,6 +45,9 @@ RawValue: /[^\s]+/ ; + + +Comment: /#[^\n]*/; """ diff --git a/src/diffpy/apps/pdfadapter.py b/src/diffpy/apps/pdfadapter.py index 5ea27ac..dc9b850 100644 --- a/src/diffpy/apps/pdfadapter.py +++ b/src/diffpy/apps/pdfadapter.py @@ -3,8 +3,6 @@ from pathlib import Path import numpy -from scipy.optimize import least_squares - from diffpy.srfit.fitbase import ( FitContribution, FitRecipe, @@ -14,6 +12,7 @@ from diffpy.srfit.pdf import PDFGenerator, PDFParser from diffpy.srfit.structure import constrainAsSpaceGroup from diffpy.structure.parsers import getParser +from scipy.optimize import least_squares class PDFAdapter: diff --git a/tests/helper.py b/tests/helper.py index b4b1a4f..f557162 100644 --- a/tests/helper.py +++ b/tests/helper.py @@ -1,5 +1,4 @@ import numpy as np - from diffpy.srfit.fitbase import FitContribution, FitRecipe, Profile from diffpy.srfit.pdf import PDFGenerator, PDFParser from diffpy.srfit.structure import constrainAsSpaceGroup diff --git a/tests/test_runmacro.py b/tests/test_runmacro.py index a2545ba..58ea2d0 100644 --- a/tests/test_runmacro.py +++ b/tests/test_runmacro.py @@ -162,6 +162,18 @@ def test_meta_model(): }, {}, ), + # C10: comments. Expect no error is raised by textx + ( + f""" +# This is a comment +load structure G1 from "{_STRUCTURE_PATH}" +""", + { + "initialize_structures.structure_paths": _STRUCTURE_PATH, + "initialize_structures.names": ["G1"], + }, + {"G1": "structure"}, + ), ], ) def test_command_processor(