From 6ccce8345c9372d87806c787c49599e917840280 Mon Sep 17 00:00:00 2001 From: Yuchen Xiao Date: Mon, 20 Apr 2026 14:33:50 -0400 Subject: [PATCH 1/2] feat: support single line comment in the macro file --- news/single-line-comment.rst | 23 +++++++++++++++++++++++ src/diffpy/__init__.py | 14 -------------- src/diffpy/apps/app_runmacro.py | 3 +++ src/diffpy/apps/pdfadapter.py | 3 +-- tests/helper.py | 1 - tests/test_runmacro.py | 12 ++++++++++++ 6 files changed, 39 insertions(+), 17 deletions(-) create mode 100644 news/single-line-comment.rst delete mode 100644 src/diffpy/__init__.py 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/__init__.py b/src/diffpy/__init__.py deleted file mode 100644 index 2d7de20..0000000 --- a/src/diffpy/__init__.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2026 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.apps/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## 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( From c9cb44b56deb87588aed7c90bc54d663901a8603 Mon Sep 17 00:00:00 2001 From: Yuchen Xiao Date: Mon, 20 Apr 2026 14:37:37 -0400 Subject: [PATCH 2/2] chore: fix `tests_on_pr` --- src/diffpy/__init__.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 src/diffpy/__init__.py diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py new file mode 100644 index 0000000..2d7de20 --- /dev/null +++ b/src/diffpy/__init__.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python +############################################################################## +# +# (c) 2026 The Trustees of Columbia University in the City of New York. +# All rights reserved. +# +# File coded by: Billinge Group members and community contributors. +# +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.apps/graphs/contributors +# +# See LICENSE.rst for license information. +# +##############################################################################