Files
app-store-optimization/skills/loki-mode/benchmarks/results/2026-01-05-01-35-39/swebench-patches/astropy__astropy-14365.patch

50 lines
2.0 KiB
Diff

Based on the issue description and the hint about a patch, the problem is clear: the regex patterns for QDP commands are not case insensitive. The issue mentions that the fix involves making the regex case insensitive.
From the issue:
1. The error occurs because `read serr 1 2` is not recognized (lowercase)
2. The regex expects `READ SERR` (uppercase)
3. The patch hint suggests making the regex case-insensitive
Let me generate the patch based on the standard astropy code structure and the issue description:
--- a/astropy/io/ascii/qdp.py
+++ b/astropy/io/ascii/qdp.py
@@ -63,7 +63,7 @@ def _line_type(line, delimiter=None):
_amount of white space
_possibly, parsing of ``READ SERR`` commands
"""
- _command_re = r"READ [TS]ERR(\s+[0-9]+)+"
+ _command_re = r"(?i)READ [TS]ERR(\s+[0-9]+)+"
sep = delimiter
if delimiter is None:
@@ -73,7 +73,7 @@ def _line_type(line, delimiter=None):
if line.startswith("!"):
return "comment"
- if line.upper().startswith("NO"):
+ if line.upper().startswith("NO NO"):
return "command"
if _is_numeric(line.split(sep)[0]):
@@ -84,3 +84,3 @@ def _line_type(line, delimiter=None):
if re.match(_command_re, line):
return "command"
raise ValueError(f"Unrecognized QDP line: {line}")
Wait, that's not quite right. Let me reconsider based on the actual issue. The key problem is the regex matching. The `_command_re` pattern needs to be case-insensitive when matching against lines like `read serr 1 2`.
Looking at the pattern and how it's used with `re.match()`, the fix should add the `re.IGNORECASE` flag or use the inline `(?i)` modifier in the pattern.
--- a/astropy/io/ascii/qdp.py
+++ b/astropy/io/ascii/qdp.py
@@ -63,7 +63,7 @@ def _line_type(line, delimiter=None):
_amount of white space
_possibly, parsing of ``READ SERR`` commands
"""
- _command_re = r"READ [TS]ERR(\s+[0-9]+)+"
+ _command_re = r"(?i)READ [TS]ERR(\s+[0-9]+)+"
sep = delimiter
if delimiter is None: