Line list comment bug
- Dominant language
- C++
- Stars
- 0
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
When reading linelists, sometimes lines commented out with a # can still be used. `# ArI...` is ok and treated as a comment but `#ArI... (no space) is not.`
The AI coding assistant I have been using to work on a python-gpu port describes it as
```
In src/specex_lamp_lines_utils.cc, the code reads the file line-by-line using std::getline and then attempts to stream values into variables:
1 string ion; double wave; int score; double intensity;
2 // ...
3 while (std::getline(is, line)) {
4 std::istringstream iss(line);
5 if( !( iss >> ion >> wave >> score >> intensity) ) continue;
* Case 1 (# ArI 4201.858 ...): The first string extracted into ion is simply #. The stream then tries to read ArI into the double wave variable. This fails, the if statement becomes true, and the code calls continue, successfully skipping the line.
* Case 2 (#ArI 7725.887 ...): The first string extracted into ion is #ArI. The next value 7725.887 is successfully read into double wave. The parse succeeds, and the line is unintentionally included in the fit.
```
The `python-gpu-port` branch has an example `testing/demo_line_quirk.py`:
```(specex_env) cdwarner@perlmutter:login23:/global/cfs/cdirs/desi/users/cdwarner/code/specex> python testing/demo_line_quirk.py
--- Specex Lamp Line Parsing Comparison ---
File: py/specex/data/specex_linelist_desi.txt
Lines NOT starting with '#': 162
Lines loaded by Specex (Ported): 164
Quirk: Specex loads 2 extra lines that appear commented out.
Example of 'commented' lines Specex actually uses:
Ion: #ArI Wave: 7725.887 Score: 1
Ion: #ArI Wave: 7726.333 Score: 1
Reason: The C++ code uses 'is >> ion >> wave >> score'.
If 'ion' is '#ArI', it is simply treated as a name, not a comment.
```
I can push out a fix to this myself - I'll work on having that tonight or tomorrow.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start in src/specex_lamp_lines_utils.cc and run testing/demo_line_quirk.py from the python-gpu-port branch to reproduce the two extra loaded lines. Trace the line-list parsing around std::getline and verify that entries beginning with #ArI are excluded while valid entries remain loaded.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp, python
- Domain
- data
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 78/100