Application Programming Interface#

Data#

diet.data.find_ingredient(query: Optional[str])[source]#

Find an ingredient.

Parameters:

query (str, optional) – Query. Do not specify to launch an interactive search.

Returns:

Ingredient information.

Return type:

dict

diet.data.find_ingredient()[source]
diet.data.nutrients = {'ALC': 'Alcohol total', 'ASH': 'Ash', 'CA': 'Calcium', 'CARTA': 'Alfa-carotene', 'CARTBTOT': 'Beta-carotene', 'CHO': 'Carbohydrate available', 'CHOCAL': 'Cholecalciferol (Vit D3)', 'CHOCALOH': '25-hydroxycholecalciferol (25OHVitD3)', 'CHORL': 'Cholesterol', 'CRYPXB': 'Beta-cryptoxanthin', 'CU': 'Copper', 'ENERCC': 'Energy kcal', 'ENERCJ': 'Energy kJ', 'F10:0': 'C10:0', 'F10:1CIS': 'C10:1 cis', 'F10:1TRS': 'C10:1 trans', 'F11:0': 'C11:0', 'F12:0': 'C12:0', 'F12:1CIS': 'C12:1 cis', 'F12:1TRS': 'C12:1 trans', 'F13:0': 'C13:0', 'F14:0': 'C14:0', 'F14:1CIS': 'C14:1 cis', 'F14:1TRS': 'C14:1 trans', 'F15:0': 'C15:0', 'F16:0': 'C16:0', 'F16:1CIS': 'C16:1 cis', 'F16:1TRS': 'C16:1 trans', 'F17:0': 'C17:0', 'F18:0': 'C18:0', 'F18:1CIS': 'C18:1 cis', 'F18:1TRS': 'C18:1 total trans', 'F18:2CN6': 'C18:2 n-6 (linoleic acid)', 'F18:2CN9': 'C18:2 n-9 cis', 'F18:2CT': 'C18:2 cis trans', 'F18:2R': 'C18:2 remainder', 'F18:2TC': 'C18:2 trans cis', 'F18:2TTN6': 'C18:2 n-6 trans', 'F18:3CN3': 'C18:3 n-3 cis (ALA)', 'F18:3CN6': 'C18:3 n-6 cis', 'F18:3TTTN3': 'C18:3 n-3 trans', 'F18:4CN3': 'C18:4 n-3 cis', 'F19:0': 'C19:0', 'F20:0': 'C20:0', 'F20:1CIS': 'C20:1 cis', 'F20:1TRS': 'C20:1 trans', 'F20:2CN6': 'C20:2 n-6 cis', 'F20:2TT': 'C20:2 n-6 trans', 'F20:3CN3': 'C20:3 n-3 cis', 'F20:3CN6': 'C20:3 n-6 cis', 'F20:3CN9': 'C20:3 n-9 cis', 'F20:4CN3': 'C20:4 n-3 cis', 'F20:4CN6': 'C20:4 n-6 cis', 'F20:5CN3': 'C20:5 n-3 cis (EPA)', 'F21:0': 'C21:0', 'F21:5CN3': 'C21:5 n-3 all-cis', 'F22:0': 'C22:0', 'F22:1CIS': 'C22:1 cis', 'F22:1TRS': 'C22:1 trans', 'F22:2CN3': 'C22:2 n-3 cis', 'F22:2CN6': 'C22:2 n-6 cis', 'F22:3CN3': 'C22:3 n-3 cis', 'F22:4CN6': 'C22:4 n-6 cis', 'F22:5CN3': 'C22:5 n-3 cis (DPA)', 'F22:5CN6': 'C22:5 n-6 cis', 'F22:6CN3': 'C22:6 n-3 cis (DHA)', 'F23:0': 'C23:0', 'F24:0': 'C24:0', 'F24:1CIS': 'C24:1 cis', 'F24:1TRS': 'C24:1 trans', 'F24:2CN6': 'C24:2 n-6 ciscis', 'F25:0': 'C25:0', 'F26:0': 'C26:0', 'F4:0': 'C4:0', 'F6:0': 'C6:0', 'F8:0': 'C8:0', 'FACID': 'Fatty acids total', 'FAMSCIS': 'Fatty acids monounsaturated cis total', 'FAMSCXR': 'Fatty acids monounsaturated cis remainder', 'FAMSTXR': 'Fatty acids monounsaturated trans remainder', 'FAPU': 'Fatty acids total polyunsaturated total', 'FAPUN3': 'Fatty acids n-3 polyunsaturated cis', 'FAPUN6': 'Fatty acids n-6 polyunsaturated cis', 'FAPUXR': 'Fatty acids polyunsaturated c+t remainder', 'FASAT': 'Fatty acids saturated total', 'FASATXR': 'Fatty acids saturated remainder', 'FAT': 'Fat total', 'FATRS': 'Fatty acids trans total', 'FAUN': 'Fatty acid unidentified', 'FE': 'Iron total', 'FIBT': 'Fibre dietary total', 'FOL': 'Dietary folate equivalents', 'FOLAC': 'Folic acid synthetic', 'FOLFD': 'Folate food', 'HAEM': 'Iron haem', 'ID': 'Iodine', 'K': 'Potassium', 'LUTN': 'Lutein', 'LYCPN': 'Lycopene', 'MG': 'Magnesium', 'NA': 'Sodium', 'NHAEM': 'Iron non-haem', 'NIA': 'Niacin (Vit B3)', 'NT': 'Nitrogen total', 'OA': 'Organic acids total', 'P': 'Phosphorus', 'POLYL': 'Polyols total', 'PROT': 'Protein total', 'PROTAN': 'Protein animal', 'PROTPL': 'Protein plant', 'RETOL': 'Retinol', 'RIBF': 'Riboflavin (Vit B2)', 'SE': 'Selenium total', 'STARCH': 'Starch total', 'SUGAR': 'Sugars total', 'THIA': 'Thiamin (Vit B1)', 'TOCPHA': 'Alpha-tocopherol', 'TOCPHB': 'Beta-tocopherol', 'TOCPHD': 'Delta-tocopherol', 'TOCPHG': 'Gamma-tocopherol', 'VITA_RAE': 'Retinol activity equialents (RAE)', 'VITA_RE': 'Retinol equivalents (RE)', 'VITB12': 'Cobalamin (Vit B12)', 'VITB6': 'Pyridoxin (Vit B6)', 'VITC': 'Ascorbic acid (Vit C)', 'VITD': 'Vitamin D total', 'VITE': 'Vitamin E total', 'VITK': 'Vitamin K total', 'VITK1': 'Vitamin K1', 'VITK2': 'Vitamin K2', 'WATER': 'Water total', 'ZEA': 'Zeaxanthin', 'ZN': 'Zinc'}#

Map nutrient abbreviations to descriptive names.

Type:

dict[str, str]

diet.data.rdi = {'CA': 800.0 mg, 'CU': 0.7 mg, 'FE': 6.0 mg, 'FOL': 320.0 ug, 'ID': 95.0 ug, 'K': 3400.0 mg, 'MG': 330.0 mg, 'NA': 2300.0 mg, 'NIA': 12.0 mg, 'P': 580.0 mg, 'RIBF': 1.1 mg, 'SE': 45.0 ug, 'THIA': 1.0 mg, 'VITA_RAE': 625.0 ug, 'VITA_RE': 625.0 ug, 'VITB12': 2.0 ug, 'VITB6': 1.1 mg, 'VITC': 75.0 mg, 'VITD': 10.0 ug, 'VITE': 15.0 mg, 'ZN': 9.4 mg}#

RDIs per nutrient.

Type:

dict[str, diet.quantity.Quantity]

IO#

diet.io.load_file(path)[source]#

Load recipe file.

Parameters:

path (str) – Path to file.

Returns:

Recipes by day. dict: Metadata.

Return type:

dict

Quantity#

class diet.quantity.Quantity(number: Number, unit: str)[source]#

A quantity with a unit.

number#

Number.

Type:

float

unit#

Unit.

Type:

str

classmethod parse(x: str, unit: str = '') Quantity[source]#

Parse a string and construct the corresponding quantity.

Parameters:
  • x (str or numbers.Number) – Specification of quantity.

  • unit (str, optional) – Unit.

Returns:

Specified quantity.

Return type:

Quantity

parse(cls, x: numbers.Number, unit: str) diet.quantity.Quantity[source]
simplify_unit() Quantity[source]#

Simplify the unit of the quantity according to units.

Returns:

Same quantity with simplified unit.

Return type:

Quantity

diet.quantity.units = {}#

Simply a unit into a quantity with another unit.

Type:

dict[str, Quantity]

Util#

diet.util.print_table(data)[source]#

Print a table.

Parameters:

data (Iterable[tuple]) – An iterable over rows, where every row is a tuple containing the values for all columns.