feat(sclass): kanonisches LCA-Systemformat (Schemas + LCASystem) - #130
Open
lepy wants to merge 4 commits into
Open
feat(sclass): kanonisches LCA-Systemformat (Schemas + LCASystem)#130lepy wants to merge 4 commits into
lepy wants to merge 4 commits into
Conversation
sdata pflegt die kanonischen Tabellen-Schemas eines matrixbasierten LCA-Systems (Heijungs & Suh 2002): flows/processes/elementary_flows/ exchanges_a/exchanges_b/uncertainty via sdata.schema.TableSchema, samt der getrennten Verteilungs-Parametrisierungs-Spalten der uncertainty-Tabelle (lognormal_underlying_* vs. lognormal_geometric_*, ohne Arithmetik). Format-Vertrag: Matrix-Konvention Output +, Input − (keine flip-/negative- Flags im nativen Format); die Zeilenordnung ist normativ und geht in die Content-Prüfsumme ein. LCASystem erbt DataFrameGroup und ergänzt content_checksum() über alle Teiltabellen (kanonische CSV je Tabelle → Zeilen-/Spaltenordnung zählen), validate_tables() gegen die Pflichtspalten sowie einen verlustfreien CSV-Roundtrip (to_csv_dir/from_csv_dir). JSON-Roundtrip erbt DataFrameGroup. Tests: Zeilen-Permutation ⇒ andere Prüfsumme, JSON- und CSV-Roundtrip verlustfrei (Ordnung + Werte), Schema-Validierung schlägt bei fehlender Pflichtspalte an. 17 neue Tests, gesamte Suite grün. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
`LCASystem.to_csv_dir`/`from_csv_dir` legten den CSV-Dialekt bisher nicht fest; `from_csv_dir` reichte `**read_csv_kwargs` an `pandas.read_csv` durch. Damit konnte ein abweichender Dialekt (z. B. `;`-getrennt, Dezimalkomma) still falsch gelesen werden und die Ordnungs-/Content-Prüfsummen-Garantie untergraben. - Dialekt gepinnt: `sep=","`, `decimal="."`, UTF-8, NaN als leere Zelle (`na_rep=""` beim Schreiben) — als öffentlicher Vertrag `CSV_DIALECT` dokumentiert; Ordnungs- und Prüfsummen-Garantien gelten nur für ihn. - `**read_csv_kwargs` aus `from_csv_dir` entfernt — keine Hintertür, die sep/decimal/encoding überschreibt. - Tests: fremder Dialekt wird NICHT still korrekt gelesen (fällt als falsche Spaltenform auf); Dialekt-Override wird abgelehnt; Roundtrip bleibt prüfsummenstabil. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Not up to standards ⛔🔴 Issues
|
| Category | Results |
|---|---|
| Documentation | 12 minor |
| Complexity | 1 medium |
🟢 Metrics 26 complexity · 0 duplication
Metric Results Complexity 26 Duplication 0
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
Die RESULTS-Schemas im selben Vertragsstil wie das Eingabe-System (Ordnung normativ, CSV_DIALECT gepinnt, deterministische content_checksum): results (Kennzahlen je Zielgroesse), draws (g-Draws als lange Tabelle, optional), provenance (key/value: Seeds, Generator, Hashes). Die Benennung ist normativ (H 2024 Tab. 14.2): interpercentile_lower/_upper sind Interperzentil-Grenzen (Streuung), nie Konfidenz; nominal statt "true value". LCATableGroup als geteilte Basis extrahiert (schema-gebundene Ablage, content_checksum, Validierung, gepinnter CSV-Roundtrip); LCASystem und der neue LCAResults erben davon. from_csv_dir liest mit float_precision="round_trip" — der Default-Parser von read_csv (pandas >=3) verlor bei vollpraezisen float64 Stellen, sodass die content_checksum nach dem Roundtrip von MC-Ergebnisfloats nicht mehr stimmte; Teil des Dialekt-Vertrags.
…entieren Die uncertainty-Tabelle parametrisiert stets den Betrag |x| einer Zelle, nie den vorzeichenbehafteten Wert; das Vorzeichen traegt allein der Nominaleintrag in exchanges_a/exchanges_b (Matrix-Konvention Output +, Input −), Anwendung sign(nominal)·Ziehung beim Konsumenten. So kann eine rein positive Familie (Lognormal) eine negative Zelle nicht mehr still ins Positive kippen. Fuer positive Zellen ist sign = +1 (kein Unterschied). Reine Dokumentation/Beschreibungstexte — keine Strukturaenderung: - Modul-Docstring: Absatz "Vorzeichen-Vertrag der uncertainty-Tabelle". - UNCERTAINTY_DIST_COLUMNS-Kommentar: Betrags-Vertrag ergaenzt. - dist-Schema-description: Hinweis "parametrisiert |x|, Vorzeichen aus dem Nominaleintrag". Suite unveraendert gruen. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Was
sdata.sclass.lca— kanonisches Austauschformat für Matrix-LCA-Systeme (Schema-Heimat-Entscheidung aus dem lepus-lca-Projekt, 2026-07-15). Zwei Commits:b2c7279— Format:flows/processes(mitreference_output) /elementary_flows/exchanges_a/exchanges_b(COO) /uncertaintyuncertaintymit expliziter Verteilungs-Parametrisierung (getrennte Spaltensätze*_underlying_*vs.*_geometric_*)LCASystem(DataFrameGroup-Basis): Content-Prüfsumme über alle Teiltabellen,validate_tables(), verlustfreier CSV-/JSON-Roundtrip4430f33— CSV-Dialekt als Vertrag (Härtung nach Review):CSV_DIALECTgepinnt (sep=",", decimal=".", UTF-8, definierte NaN-Politik); Ordnungs-/Prüfsummen-Garantien gelten nur für diesen Dialekt**read_csv_kwargs-Hintertür entferntTests
21 Tests (
tests/test_sclass_lca.py); gesamte Suite grün (813 passed, 2 skipped).Konsument
lepus-lca
main(Importer + 13×10-Golden laufen End-to-End gegen dieses Format; CI dort skippt sdata-Tests sichtbar, bis dieses Feature released ist). Nach Merge + Release ≥ 1.5 pinnt lepus-lca auf PyPI statt lokaler Quelle.🤖 Generated with Claude Code