DHI / DHI/mikecore-python

MeshFile element-code check is a tautology and does nothing

Offen
#46 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
Python
Sterne
5
Forks
1
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Beschreibung

`mikecore/MeshFile.py` (around line 281, in `ReadMesh`) contains:

```python
# Element code must be 21 or 25 (21 for triangular meshes, 25 for mixed meshes)
if (elmtCode != 21) or (elmtCode != 25):
pass # TODO?? Do we care?
```

The condition is a tautology: no integer can be equal to both 21 and 25, so `!= 21 or != 25` is true for every possible value — including the two the comment says are valid. It needs `and`.

Today this is harmless, because the body is `pass`. The problem is the invitation: the `TODO` asks someone to decide what to do with an unexpected code, and anyone who fills the body in — with a `raise`, a warning, anything — makes it fire on *every* mesh, valid ones included.

The check is also redundant as written. A few lines further down, `ElementType` is derived per element from the number of corners actually parsed, so the header code is not what the reader relies on.

Two things to settle:

1. Remove the dead block so the trap is gone. (Doing this in a PR alongside this issue.)
2. Decide the policy: should an element code other than 21 or 25 raise, warn, or continue to be ignored? Right now `elmtCode` is read from the header and never used for anything.

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Rechercherichtung

Beginne in mikecore/MeshFile.py bei ReadMesh um Zeile 281 und verfolge dann, wie elmtCode und die spätere Ableitung von ElementType verwendet werden. Bestätige, ob der Header-Code irgendeine erforderliche Rolle spielt, entscheide über das Verhalten für Codes außer 21 und 25 und stelle sicher, dass der tote tautologische Block entfernt wird, ohne das Parsen gültiger Meshes zu ändern.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Bewertung

Tech-Stack
python
Bereich
data
Issue-Typ
Bug
Schwierigkeit
5/5
Geschätzter Aufwand
Über eine Woche
Aktivitätsstatus
Aktiv
Klarheit
Größtenteils klar
Anfängerfreundlichkeit
35/100

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.