# Import and Export `evidencelib` keeps data exchange small and explicit. JSON and CSV are intended for round trips. LaTeX is intended for paper-ready tables. All imports require the target `Frame`. The frame carries the model semantics, especially for DSmT and hybrid models, so imported mass data is interpreted against the frame you provide. ## Dictionaries ```python from evidencelib import Frame, MassFunction frame = Frame.dst(["A", "B"]) m = MassFunction.from_dict(frame, {"A": 0.2, "A|B": 0.8}) assert m.to_dict() == {"A": 0.2, "A|B": 0.8} ``` `from_dict()` also accepts schema-wrapped dictionaries produced by decoding `to_json()`. ## JSON ```python text = m.to_json() restored = MassFunction.from_json(frame, text) ``` The JSON payload contains: - `schema`: the `evidencelib.mass.v2` schema name, - `frame`: atom, model, region-count, and exact possible-region metadata, - `masses`: proposition strings mapped to mass values. The stored frame metadata is validation metadata only. It does not replace the `Frame` object passed to `from_json()`. Version 2 records the model's possible Venn regions, so hybrid models with the same atom names and region count but different constraints cannot be confused. Legacy v1 data remains readable for DST and free DSmT frames. Because v1 cannot identify hybrid constraints safely, importing v1 into a hybrid target raises an error and requires re-export from the original model. ## CSV ```python csv_text = m.to_csv() restored = MassFunction.from_csv(frame, csv_text) ``` The CSV format has two columns: ```text proposition,mass A,0.2 A|B,0.8 ``` Headerless CSV can be imported with `has_header=False`: ```python restored = MassFunction.from_csv(frame, "A,0.2\nA|B,0.8\n", has_header=False) ``` ## LaTeX Use `to_latex()` when you want a table for a paper or thesis. ```python latex = m.to_latex( columns=("mass", "belief", "plausibility"), caption="Mass assignment", label="tab:mass", ) ``` By default, LaTeX exports only focal propositions. Pass `rows="all"` to include every proposition generated by the frame: ```python m.to_latex(rows="all") ``` Use `rows="all"` carefully on DSmT frames because the hyper-power set can grow quickly. Supported column names are: | Column | Aliases | | --- | --- | | `mass` | `m` | | `belief` | `bel` | | `plausibility` | `pl` | | `commonality` | `q` | The default LaTeX output uses `booktabs` rules. Include `\usepackage{booktabs}` in your document preamble, or pass `booktabs=False`.