Coverage for skema/img2mml/schema.py: 100%

8 statements  

« prev     ^ index     » next       coverage.py v7.5.0, created at 2024-04-30 17:15 +0000

1# -*- coding: utf-8 -*- 

2""" 

3Data models used by REST endpoints for eqn2mml, img2mml, and latex2mml 

4""" 

5 

6from typing_extensions import Annotated 

7from pydantic import ConfigDict, BaseModel, Field 

8from fastapi import File 

9 

10 

11ImageBytes = Annotated[ 

12 bytes, 

13 File( 

14 description="bytes of a PNG of an equation", 

15 # examples={ 

16 # "bayes-rule": { 

17 # "summary": "PNG of Bayes' rule", 

18 # "description": "PNG of Bayes' rule", 

19 # "value": str(img_path_bayes_rule_eqn), 

20 # } 

21 # }, 

22 ), 

23] 

24 

25class LatexEquation(BaseModel): 

26 tex_src: str = Field(title="LaTeX equation", description="The LaTeX equation to process") 

27 model_config = ConfigDict(json_schema_extra={ 

28 "example": { 

29 "tex_src": "\\frac{\\partial x}{\\partial t} = {\\alpha x} - {\\beta x y}", 

30 }, 

31 "examples": [ 

32 { 

33 "tex_src": "\\frac{\\partial x}{\\partial t} = {\\alpha x} - {\\beta x y}" 

34 }, 

35 { 

36 "tex_src": "\\frac{\\partial y}{\\partial t} = {\\alpha x y} - {\\gamma y}" 

37 }, 

38 { 

39 "tex_src": "E = mc^{2}", 

40 }, 

41 { 

42 "tex_src": "\\frac{P(\\textrm{a } | \\textrm{ b}) \\times P(\\textrm{b})}{P(\\textrm{a})}", 

43 } 

44 ] 

45 })