Skip to content

Commit

Permalink
Merge branch 'main' into add_nen_soil_types
Browse files Browse the repository at this point in the history
  • Loading branch information
johan-tuls authored Oct 16, 2024
2 parents e1a55ac + f6c97e7 commit 69899ab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 12 deletions.
23 changes: 13 additions & 10 deletions blueprints/codes/latex_formula.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
@dataclass(frozen=True)
class LatexFormula:
"""Latex formula representation.
Depending on the context this could include the unit, the formula, the result, etc.
Attributes
Expand All @@ -28,6 +29,7 @@ class LatexFormula:
equation: str = ""
numeric_equation: str = ""
comparison_operator_label: str = "="
unit: str = ""

@property
def complete(self) -> str:
Expand All @@ -39,13 +41,9 @@ def complete(self) -> str:
Return symbol = equation = numeric_equation = result
"""
all_sub_equations = [
self.return_symbol,
self.equation,
self.numeric_equation,
self.result,
]
return f" {self.comparison_operator_label} ".join([eq for eq in all_sub_equations if eq != ""])
all_sub_equations = [self.return_symbol, self.equation, self.numeric_equation, f"{self.result}"]
long_formula = f" {self.comparison_operator_label} ".join([eq for eq in all_sub_equations if eq != ""])
return long_formula + f" {self.unit}" if self.unit else long_formula

@property
def short(self) -> str:
Expand All @@ -57,7 +55,8 @@ def short(self) -> str:
Return symbol = result
"""
return f"{self.return_symbol} {self.comparison_operator_label} {self.result}"
short_formula = f"{self.return_symbol} {self.comparison_operator_label} {self.result}"
return short_formula + f" {self.unit}" if self.unit else short_formula

def __str__(self) -> str:
"""String representation of the formula."""
Expand Down Expand Up @@ -89,7 +88,9 @@ def latex_fraction(numerator: str | float, denominator: str | float) -> str:


def latex_min_curly_brackets(*args: str | float) -> str:
r"""Return a string which will output: min{arg_1; arg_2; ...; arg_N} in latex and it will also automatically ensure floats are converted to latex
r"""Return a string which will output: min{arg_1; arg_2; ...; arg_N} in latex.
It will also automatically ensure floats are converted to latex
text.
Examples
Expand All @@ -112,7 +113,9 @@ def latex_min_curly_brackets(*args: str | float) -> str:


def latex_max_curly_brackets(*args: str | float) -> str:
r"""Return a string which will output: max{arg_1; arg_2; ...; arg_N} in latex and it will also automatically ensure floats are converted to latex
r"""Return a string which will output: max{arg_1; arg_2; ...; arg_N} in latex.
It will also automatically ensure floats are converted to latex
text.
Examples
Expand Down
4 changes: 2 additions & 2 deletions requirements_dev.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
mypy==1.11.2
ruff==0.6.3
ruff==0.6.8
pre-commit==3.8.0
pytest==8.3.2
pytest==8.3.3
pytest-cov==5.0.0
pytest-describe==2.2.0
pytest-pspec==0.0.4
Expand Down

0 comments on commit 69899ab

Please sign in to comment.