SoilID: Fix component-group selection being sorted alphabetically instead of by cond_prob
@johannesparty がすでに取り組んでいます。
2026年9月24日 から。
評価
この issue はまだ評価されていません。
説明
Summary
process_distance_scores sorts component-instance rows by descending cond_prob, but then groups them with sort=True. This reorders the groups alphabetically by compname before selecting the first 12 groups, so the function can discard high-probability component groups and retain lower-probability groups solely because their names sort earlier.
Location
soil_id/utils.py, in process_distance_scores:
mucompdata_pd = mucompdata_pd.sort_values(
["cond_prob", comp_name_col], ascending=[False, True]
)
mucompdata_comp_grps = [
g for _, g in mucompdata_pd.groupby([comp_name_col], sort=True)
]
mucompdata_comp_grps = mucompdata_comp_grps[: min(12, len(mucompdata_comp_grps))]
Expected behavior
The selected 12 component groups should be the groups with the highest cond_prob values, preserving the ranking established before grouping.
Actual behavior
sort=True orders the groups by the component name key. Consequently, mucompdata_comp_grps[:12] selects the first 12 groups alphabetically rather than the 12 highest-ranked groups.
Proposed fix
Use sort=False so pandas yields groups in first-appearance order, which follows the preceding cond_prob descending sort:
mucompdata_comp_grps = [
g for _, g in mucompdata_pd.groupby([comp_name_col], sort=False)
]
Add or update regression tests to verify that the retained groups are the highest-probability component groups, not the alphabetically first groups.
Related issue in the same block
The loop below reassigns and modifies only a local group variable, so its distance sort and min_dist assignment are not reflected in mucompdata_comp_grps or the final concatenated DataFrame:
for group in mucompdata_comp_grps:
group = group.sort_values(distance_col).reset_index(drop=True)
group["min_dist"] = group[distance_col].iloc[0]
The implementation should also preserve those intended modifications, for example by assigning the transformed groups back into the list. This should be covered by tests or handled as part of the fix if it is within scope.
@johannesparty regarding our conversation today, we originally truncated the number of soil series (compname) to 12 in the old app due to display issues. It probably makes sense to remove this constraint because, in the US case, many 1000m buffers can contain more than 12 soils.
- 主要言語
- Python
- スター
- 2
- フォーク
- 3
- 平均マージ
- 16時間 14分
- マージ済み PR(30日)
- 1
環境構築
- Dockerfile または Docker Compose ファイルあり
- プルリクエストのテンプレートなし
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
techmatters/soil-id-algorithm のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
techmatters/soil-id-algorithm#386 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
techmatters/soil-id-algorithm#390 · コメント 1 件 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
techmatters/soil-id-algorithm#388 ·
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
techmatters/soil-id-algorithm#387 ·
-
soil_sim: divide-by-zero in ilr/clr when a particle fraction is 0 (simulation/confidence metric)オープン
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
techmatters/soil-id-algorithm#385 ·
techmatters/soil-id-algorithm の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
Graphify-Labs/graphify#4860 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
:bug: Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
scikit-image/scikit-image#8377 ·
メンテナーはふだん 1 日以内に返信
-
Ingredient import validation accepts negative nutrient values and NaN対応中かも @LukeSekai が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
wger-project/wger#2564 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
apache/ponymail-foal#351 ·
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
メンテナーはふだん 4 日以内に返信