texer 0.5.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,263 @@
1
+ Metadata-Version: 2.4
2
+ Name: texer
3
+ Version: 0.5.12
4
+ Summary: Generate LaTeX tables and figures with glom-style specs
5
+ Author-email: Thibaut Lamadon <thibaut.lamadon@example.com>
6
+ License-Expression: MIT
7
+ Keywords: latex,tables,pgfplots,tikz,typesetting,scientific
8
+ Classifier: Development Status :: 3 - Alpha
9
+ Classifier: Intended Audience :: Science/Research
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.9
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Topic :: Text Processing :: Markup :: LaTeX
18
+ Classifier: Topic :: Scientific/Engineering
19
+ Classifier: Typing :: Typed
20
+ Requires-Python: >=3.9
21
+ Description-Content-Type: text/markdown
22
+ License-File: LICENSE
23
+ Requires-Dist: glom>=23.0.0
24
+ Provides-Extra: dev
25
+ Requires-Dist: pytest>=7.0.0; extra == "dev"
26
+ Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
27
+ Requires-Dist: mypy>=1.0.0; extra == "dev"
28
+ Provides-Extra: docs
29
+ Requires-Dist: mkdocs>=1.5.0; extra == "docs"
30
+ Requires-Dist: mkdocs-material>=9.5.0; extra == "docs"
31
+ Requires-Dist: mkdocstrings[python]>=0.24.0; extra == "docs"
32
+ Requires-Dist: numpy>=1.20.0; extra == "docs"
33
+ Dynamic: license-file
34
+
35
+ # texer
36
+
37
+ [![PyPI version](https://badge.fury.io/py/texer.svg)](https://pypi.org/project/texer/)
38
+ [![Documentation](https://img.shields.io/badge/docs-GitHub%20Pages-blue)](https://tlamadon.github.io/texer)
39
+
40
+ Generate LaTeX tables and figures (PGFPlots) with Python using a glom-style spec system.
41
+
42
+ ## Installation
43
+
44
+ ```bash
45
+ pip install texer
46
+ ```
47
+
48
+ ## Quick Start
49
+
50
+ ### Tables
51
+
52
+ ```python
53
+ from texer import Table, Tabular, Row, Ref, Iter, Format, evaluate
54
+
55
+ # Define structure with specs
56
+ table = Table(
57
+ Tabular(
58
+ columns="lcc",
59
+ header=Row("Experiment", "Result", "Error"),
60
+ rows=Iter(
61
+ Ref("experiments"),
62
+ template=Row(
63
+ Ref("name"),
64
+ Format(Ref("result"), ".3f"),
65
+ Format(Ref("error"), ".1%"),
66
+ )
67
+ ),
68
+ toprule=True,
69
+ bottomrule=True,
70
+ ),
71
+ caption=Ref("table_title"),
72
+ label="tab:results",
73
+ )
74
+
75
+ # Provide data
76
+ data = {
77
+ "table_title": "Experimental Results",
78
+ "experiments": [
79
+ {"name": "Trial A", "result": 3.14159, "error": 0.023},
80
+ {"name": "Trial B", "result": 2.71828, "error": 0.015},
81
+ ]
82
+ }
83
+
84
+ print(evaluate(table, data))
85
+ ```
86
+
87
+ ### Plots
88
+
89
+ ```python
90
+ from texer import PGFPlot, Axis, AddPlot, Coordinates, Ref, Iter, evaluate
91
+
92
+ plot = PGFPlot(
93
+ Axis(
94
+ xlabel=Ref("x_label"),
95
+ ylabel=Ref("y_label"),
96
+ grid=True,
97
+ plots=[
98
+ AddPlot(
99
+ color="blue",
100
+ mark="*",
101
+ coords=Coordinates(
102
+ Iter(Ref("measurements"), x=Ref("time"), y=Ref("value"))
103
+ ),
104
+ )
105
+ ],
106
+ legend=[Ref("series_name")],
107
+ )
108
+ )
109
+
110
+ data = {
111
+ "x_label": "Time (hours)",
112
+ "y_label": "Temperature (°C)",
113
+ "series_name": "Sensor 1",
114
+ "measurements": [
115
+ {"time": 0, "value": 20.5},
116
+ {"time": 1, "value": 22.3},
117
+ {"time": 2, "value": 25.1},
118
+ ]
119
+ }
120
+
121
+ print(evaluate(plot, data))
122
+ ```
123
+
124
+ ### Saving and Compiling
125
+
126
+ Save to file and compile to PDF directly:
127
+
128
+ ```python
129
+ from texer import Table, Tabular, Row, evaluate
130
+
131
+ table = Table(
132
+ Tabular(columns="lc", rows=[Row("Name", "Value")]),
133
+ caption="Results",
134
+ )
135
+
136
+ # Save to .tex file
137
+ evaluate(table, output_file="table.tex")
138
+
139
+ # Save with preamble for standalone compilation
140
+ evaluate(table, output_file="table.tex", with_preamble=True)
141
+
142
+ # Compile directly to PDF
143
+ pdf_path = evaluate(table, output_file="table.tex", compile=True)
144
+ ```
145
+
146
+ ### Cycle Lists
147
+
148
+ PGFPlots cycle lists allow you to define a sequence of styles that are automatically applied to successive `\addplot` commands. When using cycle lists, `AddPlot` automatically generates `\addplot+` (instead of `\addplot`) when no explicit styling is provided, allowing PGFPlots to pick the next style from the cycle list:
149
+
150
+ ```python
151
+ from texer import PGFPlot, Axis, AddPlot, Coordinates
152
+
153
+ # Using a predefined cycle list
154
+ plot = PGFPlot(
155
+ Axis(
156
+ cycle_list_name="color list",
157
+ plots=[
158
+ # These generate \addplot+ to use cycle list styles
159
+ AddPlot(coords=Coordinates([(0, 0), (1, 1), (2, 4)])),
160
+ AddPlot(coords=Coordinates([(0, 1), (1, 2), (2, 3)])),
161
+ ],
162
+ )
163
+ )
164
+
165
+ # Custom cycle list with style dictionaries
166
+ plot = PGFPlot(
167
+ Axis(
168
+ cycle_list=[
169
+ {"color": "blue", "mark": "*", "line width": "2pt"},
170
+ {"color": "red", "mark": "square*", "line width": "2pt"},
171
+ {"color": "green", "mark": "triangle*", "line width": "2pt"},
172
+ ],
173
+ plots=[
174
+ # Automatically uses \addplot+ to apply cycle list styles
175
+ AddPlot(coords=Coordinates([(0, 1), (1, 2), (2, 4)])),
176
+ AddPlot(coords=Coordinates([(0, 2), (1, 3), (2, 5)])),
177
+ ],
178
+ )
179
+ )
180
+
181
+ # Simple color cycle
182
+ plot = PGFPlot(
183
+ Axis(
184
+ cycle_list=["blue", "red", "green"],
185
+ plots=[
186
+ AddPlot(coords=Coordinates([(0, 0), (1, 1)])),
187
+ AddPlot(coords=Coordinates([(0, 1), (1, 2)])),
188
+ ],
189
+ )
190
+ )
191
+
192
+ # Override cycle list with explicit styling
193
+ plot = PGFPlot(
194
+ Axis(
195
+ cycle_list=["blue", "red", "green"],
196
+ plots=[
197
+ # This uses the cycle list (generates \addplot+)
198
+ AddPlot(coords=Coordinates([(0, 0), (1, 1)])),
199
+ # This overrides with explicit styling (generates \addplot)
200
+ AddPlot(color="purple", mark="x", coords=Coordinates([(0, 1), (1, 2)])),
201
+ ],
202
+ )
203
+ )
204
+ ```
205
+
206
+ ## Documentation
207
+
208
+ For complete documentation, visit: **[Documentation Site](https://tlamadon.github.io/texer)**
209
+
210
+ Or build the docs locally:
211
+
212
+ ```bash
213
+ pip install -e ".[docs]"
214
+ mkdocs serve
215
+ ```
216
+
217
+ Then open http://127.0.0.1:8000
218
+
219
+ ## Key Features
220
+
221
+ - **Data-driven**: Separate structure from data
222
+ - **Type-safe**: Full type hints and mypy support
223
+ - **Glom-style specs**: Familiar pattern for data extraction
224
+ - **LaTeX best practices**: Automatic escaping, booktabs tables
225
+ - **NumPy integration**: Direct support for NumPy arrays
226
+ - **PDF compilation**: Built-in `compile=True` option in `evaluate()`
227
+
228
+ ## Core Concepts
229
+
230
+ texer uses **specs** to describe how to extract and transform data:
231
+
232
+ - **`Ref("path")`** - Access data by path (e.g., `Ref("user.name")`)
233
+ - **`Iter(source, template=...)`** - Loop over collections
234
+ - **`Format(value, ".2f")`** - Format values
235
+ - **`Cond(test, if_true, if_false)`** - Conditional logic
236
+ - **`Raw(r"\textbf{bold}")`** - Unescaped LaTeX
237
+
238
+ See the [Core Concepts](docs/getting-started/core-concepts.md) guide for details.
239
+
240
+ ## LaTeX Requirements
241
+
242
+ For PDF compilation, you need a LaTeX distribution:
243
+
244
+ - **Ubuntu/Debian**: `sudo apt-get install texlive-latex-base texlive-pictures`
245
+ - **macOS**: `brew install --cask mactex`
246
+ - **Windows**: [MiKTeX](https://miktex.org/) or [TeX Live](https://www.tug.org/texlive/)
247
+
248
+ ## Development
249
+
250
+ ```bash
251
+ # Install dev dependencies
252
+ pip install -e ".[dev]"
253
+
254
+ # Run tests
255
+ pytest
256
+
257
+ # Type checking
258
+ mypy src
259
+ ```
260
+
261
+ ## License
262
+
263
+ MIT
@@ -0,0 +1,11 @@
1
+ texer/__init__.py,sha256=IvFrW7nmFkj_v3OHW7E8nl6EoKuE2qFpdRTXpwkmP3Y,856
2
+ texer/eval.py,sha256=K7hM4o2y2alM0xTEVQoCz9MFSAYFgFf-xoWCXiN81gM,8966
3
+ texer/pgfplots.py,sha256=cLhEL5CgyB16UdPrRxmLCd8OR_uONBXAv7kd9CYPQaI,51656
4
+ texer/specs.py,sha256=RCHhK01YeJU7qL2E9sHBNiJrbL6j3V5wfnT9stZTm44,17070
5
+ texer/tables.py,sha256=vLHbGt8pn8w5n9deD3JmD6M49M46mb0q1fCJLRibX2k,10053
6
+ texer/utils.py,sha256=Y-eneJzArMSU_6Kdqf_iIOklc1rHEQ4cFk7SxtcNjH8,8814
7
+ texer-0.5.12.dist-info/licenses/LICENSE,sha256=dUhuoK-TCRQMpuLEAdfme-qPSJI0TlcH9jlNxeg9_EQ,1056
8
+ texer-0.5.12.dist-info/METADATA,sha256=6c9zumIyRBEk26yOfcZc3v-JcR_1XC5p7p5qDP8Rww4,7233
9
+ texer-0.5.12.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
10
+ texer-0.5.12.dist-info/top_level.txt,sha256=c4hgYulO-XqUdfmX4S2j8rubo5KjdvsqhgaVmDsVgkU,6
11
+ texer-0.5.12.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (80.9.0)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1 @@
1
+ texer