BUG: Convert Hexagonal Grid Data to Square Grid Data rejects an .ang file with an uppercase extension
Maintainer thường phản hồi trong vòng 3 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
- 85/100
Hướng nghiên cứu
Bắt đầu từ ConvertHexGridToSquareGridFilter.cpp, nơi bước kiểm tra sơ bộ so sánh inputPath.extension() với các chuỗi .ctf và .ang bằng toán tử phân biệt chữ hoa chữ thường, và từ Algorithms/ConvertHexGridToSquareGrid.cpp, Converter::operator(), nơi có cùng kiểm tra đó. Chuyển phần mở rộng sang chữ thường bằng StringUtilities::toLower ở cả hai nơi. Chạy kiểm thử HoldRepro902 trong ConvertHexGridToSquareGridTest.cpp: tệp .ANG phải vượt qua kiểm tra sơ bộ và thực thi, còn tệp .CTF viết hoa phải trả về -44601.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
Problem
Convert Hexagonal Grid Data to Square Grid Data (TSL - .ang) (ConvertHexGridToSquareGridFilter) rejects a valid .ang file when the extension is not all lower case. A file named scan.ANG or scan.Ang fails preflight with error -44602, "The file extension '.ANG' was not detected correctly". The same file renamed to scan.ang converts correctly.
- Expected: the filter accepts the extension regardless of case, as the other EBSD readers do.
- Actual: preflight and execute fail with -44602.
- Occurs on develop b51d6c353.
Legacy DREAM3D issue BlueQuartzSoftware/DREAM3D#902 asked for case-insensitive extension checks in every filter that reads files. This filter still has the case-sensitive check.
Steps to Reproduce
- Copy a valid hexagonal-grid
.angfile (for examplesingle/hex_grid.angfromconvert_hex_grid_to_square_grid_test.tar.gz) toprobe.ANG. - Add Convert Hexagonal Grid Data to Square Grid Data (TSL - .ang) to a pipeline.
- Turn off Convert Multiple Files, set Input File to
probe.ANG, set an Output Directory, set Output Prefix toSqr_and set Spacing to 0.05, 0.0403. - Preflight shows error -44602.
- Rename the file to
probe.angand preflight again. It passes, and execute writesSqr_probe.ang.
Cause
Preflight compares std::filesystem::path::extension() with ".ang" and ".ctf" using == and !=, so the comparison is case-sensitive:
ConvertHexGridToSquareGridFilter.cpp#L143-L150
if(inputPath.extension() == ("." + ebsdlib::Ctf::FileExt))
{
return MakePreflightErrorResult(-44601, "Ctf files are not on a hexagonal grid and do not need to be converted");
}
else if(inputPath.extension() != ("." + ebsdlib::Ang::FileExt))
{
return MakePreflightErrorResult(-44602, fmt::format("The file extension '{}' was not detected correctly for file '{}'", inputPath.extension().string(), inputPath.string()));
}
The algorithm has the same case-sensitive comparison before it reads each file:
ConvertHexGridToSquareGrid.cpp#L45-L46
if(inputPath.extension() == ("." + ebsdlib::Ang::FileExt))
{
A side effect: an uppercase .CTF file gets the misleading -44602 message, not the -44601 "Ctf files ... do not need to be converted" message.
Verification Unit Test
Add to src/Plugins/OrientationAnalysis/test/ConvertHexGridToSquareGridTest.cpp. It uses the k_HexToSqrTestFilesDir and k_Spacing constants that are already in that file. This is the test as it was run (it was written as a probe, so its name has the HoldRepro902 prefix):
TEST_CASE("HoldRepro902 ConvertHexGrid accepts uppercase ANG", "[HoldRepro]")
{
UnitTest::LoadPlugins();
const UnitTest::TestFileSentinel sentinel(unit_test::k_TestFilesDir, "convert_hex_grid_to_square_grid_test.tar.gz", k_HexToSqrTestFilesDir);
const fs::path source = fs::path(unit_test::k_TestFilesDir.view()) / k_HexToSqrTestFilesDir / "single/hex_grid.ang";
const fs::path root = fs::path(unit_test::k_BinaryTestOutputDir.view()) / "HoldRepro902Hex";
fs::create_directories(root);
for(const std::string extension : {".ang", ".ANG"})
{
const fs::path input = root / ("probe" + extension);
fs::copy_file(source, input, fs::copy_options::overwrite_existing);
ConvertHexGridToSquareGridFilter filter;
auto args = filter.getDefaultArguments();
args.insertOrAssign(ConvertHexGridToSquareGridFilter::k_MultipleFiles_Key, std::make_any<bool>(false));
args.insertOrAssign(ConvertHexGridToSquareGridFilter::k_InputPath_Key, std::make_any<fs::path>(input));
args.insertOrAssign(ConvertHexGridToSquareGridFilter::k_OutputPath_Key, std::make_any<fs::path>(root / (extension == ".ang" ? "lower" : "upper")));
args.insertOrAssign(ConvertHexGridToSquareGridFilter::k_OutputPrefix_Key, std::make_any<std::string>("Sqr_"));
args.insertOrAssign(ConvertHexGridToSquareGridFilter::k_Spacing_Key, std::make_any<std::vector<float32>>(k_Spacing));
DataStructure ds;
const auto preflight = filter.preflight(ds, args);
WARN(fmt::format("Hex {} preflight valid={}", extension, preflight.outputActions.valid()));
if(preflight.outputActions.invalid())
for(const auto& e : preflight.outputActions.errors())
{
WARN(fmt::format("{}: {}", e.code, e.message));
}
CHECK(preflight.outputActions.valid());
const auto result = filter.execute(ds, args);
if(result.result.invalid())
for(const auto& e : result.result.errors())
{
WARN(fmt::format("Hex {} execute {}: {}", extension, e.code, e.message));
}
CHECK(result.result.valid());
if(result.result.valid())
{
const auto out = root / (extension == ".ang" ? "lower" : "upper") / ("Sqr_probe" + extension);
CHECK(fs::exists(out));
}
}
}
Run only this test:
<build-dir>/bin/OrientationAnalysisUnitTest "HoldRepro902 ConvertHexGrid accepts uppercase ANG"
Failure output on develop b51d6c353 (macOS arm64, ci-macos-arm64 preset). The .ang control passes; .ANG fails:
warning:
Hex .ang preflight valid=true
warning:
Hex .ANG preflight valid=false
warning:
-44602: The file extension '.ANG' was not detected correctly for file '.../test_output/HoldRepro902Hex/probe.ANG'
FAILED:
CHECK( preflight.outputActions.valid() )
with expansion:
false
warning:
Hex .ANG execute -44602: The file extension '.ANG' was not detected correctly for file '.../test_output/HoldRepro902Hex/probe.ANG'
FAILED:
CHECK( result.result.valid() )
with expansion:
false
Proposed Fix
Compare the lower-case extension in both places. StringUtilities::toLower in src/simplnx/Utilities/StringUtilities.hpp already does this, and EbsdToH5EbsdFilter uses it since PR #1749.
In ConvertHexGridToSquareGridFilter.cpp (preflight):
const std::string extension = StringUtilities::toLower(inputPath.extension().string());
if(extension == ("." + ebsdlib::Ctf::FileExt))
{
return MakePreflightErrorResult(-44601, "Ctf files are not on a hexagonal grid and do not need to be converted");
}
else if(extension != ("." + ebsdlib::Ang::FileExt))
{
...
}
In Algorithms/ConvertHexGridToSquareGrid.cpp, Converter::operator(), make the same change. With Convert Multiple Files on, preflight checks only the first generated file, so the algorithm check also matters for the other files. The output file keeps the input file name, so Sqr_probe.ANG is written for probe.ANG.
Notes
EbsdToH5EbsdFilterhad the same problem in preflight, fixed by PR #1749. Its execute check (EbsdToH5Ebsd.cpp#L155-L157) is still case-sensitive. A probe on develop b51d6c353 shows that.ANGpasses preflight and fails at execute with -99512. That item is tracked in #1867 asEbsdToH5EbsdFilter#1. It is not part of this issue.- The file parameter itself (
FileSystemPathParameter) already acceptsprobe.ANG: the -44602 error comes from the filter's own check above.
- Ngôn ngữ chính
- C++
- Star
- 18
- Fork
- 15
- Merge trung bình
- 3 ngày 20 giờ
- Pull request đã merge (30 ngày)
- 27
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- 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.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của BlueQuartzSoftware/simplnx
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BlueQuartzSoftware/simplnx#1912 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug Filter
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 84/100
BlueQuartzSoftware/simplnx#1891 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
bug Filter
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
BlueQuartzSoftware/simplnx#1860 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation
Độ khó 1/5 1-3 giờ Mức phù hợp với người mới 88/100
BlueQuartzSoftware/simplnx#1847 ·
Maintainer thường phản hồi trong vòng 3 ngày
-
documentation
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
BlueQuartzSoftware/simplnx#1846 ·
Maintainer thường phản hồi trong vòng 3 ngày
Tất cả issue của BlueQuartzSoftware/simplnx
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 62/100
mw00/project-maya#877 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
llvm/offload-test-suite#1703 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
test(tools): test_invite_answer_wiring scans nothing in a checkout whose path contains tests/Đang mởbacklog bug
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 86/100
EchoTools/nevr-runtime#2154 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
BGI-shenzhen/PopLDdecay#25 ·