A malformed noise_model line is reported as "noise_model is not a valid configuration key", and every config parse error reports the line before the right one

Đang mở Phù hợp với người mới
#1,033 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
python
Lĩnh vực
backend

Hướng nghiên cứu

Bắt đầu từ pybnf/parse.py: kiểm tra vòng lặp phân tích cấu hình quanh dòng 876 và các nhánh gợi ý định dạng quanh dòng 1359, sau đó tìm các bài kiểm tra parser bao quát những giá trị cấu hình sai định dạng. Tái hiện lỗi bằng examples/tutorial/36_estimate_noise/estimated_sigma.conf với dòng noise_model sai định dạng trong issue. Công việc hoàn tất khi lỗi xác định đúng số dòng bắt đầu từ 1, phân biệt khóa không xác định với giá trị không hợp lệ của khóa đã biết, và các bài kiểm tra bao quát những trường hợp đó.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

bug minor

Writing a fixed noise level as a bare number is an easy mistake:

noise_model = normal, sigma = 4

The correct form is sigma = fix_at 4. PyBNF reports the mistake as

Error: Parsing configuration key 'noise_model' on line 42.
noise_model is not a valid configuration key.

Both parts of the message are wrong.

  1. noise_model is a valid key. The value is what failed to parse. In pybnf/parse.py, after a line fails the grammar, a chain of elif key == ... branches picks a format hint for the key. A key with no branch falls through to fmt == '' and gets "is not a valid configuration key". The comment on the data branch (around line 1359) describes this same problem for data and fixes it for that one key only. noise_model has no branch, and neither does any other real key not in the chain.

  2. The line number is off by one. With the reproduction below, the noise_model line is line 43 of the file (grep -n agrees), and the message says 42. The number is the index i from for i, line in enumerate(ls) (around line 876), which counts from 0. Every message built from it, including the Misconfigured config key ... at line: {i} text, points at the line before the one at fault.

Reproduction: in examples/tutorial/36_estimate_noise/estimated_sigma.conf, replace the noise_model line with noise_model = normal, sigma = 4, delete the loguniform_var = noise_level ... line, and run pybnf -c on it.

Suggested fix: report a line number counted from 1. When the key is a real configuration key but its value does not parse, say so and give the accepted forms, as the data branch does. Use "is not a valid configuration key" only for a key PyBNF does not know. A test that runs every known key with a malformed value through the parser would keep the next new key from falling through.

Ngôn ngữ chính
Python
Star
25
Fork
25
Merge trung bình
4 giờ 5 phút
Pull request đã merge (30 ngày)
10

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của lanl/PyBNF

Tất cả issue của lanl/PyBNF

Issue tương tự

Thêm issue về Python

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.