Skip to content

520 feature request set n decimals as abstract method to latex formula #522

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

johan-tuls
Copy link
Contributor

Description

Please write a description of the changes you made here.

Fixes # (issue)

Type of change

Please delete options that are not relevant.

  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

Checklist:

  • [ X] I have added tests that prove my fix is effective or that my feature works
  • [ X] I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • [X ] New and existing unit tests pass locally with my changes

@johan-tuls johan-tuls requested a review from GerjanDorgelo March 5, 2025 14:32
@johan-tuls johan-tuls linked an issue Mar 5, 2025 that may be closed by this pull request
2 tasks
Copy link

github-actions bot commented Mar 5, 2025

Thank you so much for contributing to Blueprints! This is your Pull Request # 2 to this project.
Your contributions help thousands of engineers work more efficiently and accurately.

Now that you've created your pull request, please don't go away; take a look at the bottom of this page for the automated checks that should already be running. If they pass, great! If not, please click on 'Details' and see if you can fix the problem they've identified. A maintainer should be along shortly to review your pull request and help get it added!

@johan-tuls johan-tuls self-assigned this Mar 5, 2025
@@ -41,12 +41,12 @@ def _evaluate(
raise ValueError(f"Invalid f_ck: {f_ck}. f_ck cannot be negative")
return 2.5 * (f_ck - 10) * 10**-6

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 3.12."""
return LatexFormula(
return_symbol=r"\epsilon_{ca}(\infty)",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this one is not editable now. But it also cannot be the same amount of decimals as the others, as this value in particular is small. We need to think about a fix. Maybe max(6, n)?

@@ -57,15 +57,15 @@ def _evaluate(
raise ValueError(f"Invalid t: {t}. t cannot be negative")
return 5.39 * rho_1000 * np.exp(6.7 * mu) * (t / 1000) ** (0.75 * (1 - mu)) * 10**-5

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 3.28."""
return LatexFormula(
return_symbol=r"\frac{\Delta \sigma_{pr}}{\sigma_{pl}}",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -57,15 +57,15 @@ def _evaluate(
raise ValueError(f"Invalid t: {t}. t cannot be negative")
return 0.66 * rho_1000 * np.exp(9.1 * mu) * (t / 1000) ** (0.75 * (1 - mu)) * 10**-5

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 3.29."""
return LatexFormula(
return_symbol=r"\frac{\Delta \sigma_{pr}}{\sigma_{pl}}",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -57,15 +57,15 @@ def _evaluate(
raise ValueError(f"Invalid t: {t}. t cannot be negative")
return 1.98 * rho_1000 * np.exp(8 * mu) * (t / 1000) ** (0.75 * (1 - mu)) * 10**-5

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 3.30."""
return LatexFormula(
return_symbol=r"\frac{\Delta \sigma_{pr}}{\sigma_{pl}}",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -62,13 +62,14 @@ def _evaluate(

return k_r * k_phi * (f_yd / e_s) / (0.45 * d)

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 5.34."""
return LatexFormula(
return_symbol=r"\frac{1}{r}",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -41,12 +41,12 @@ def _evaluate(f_ck: MPA, f_yk: MPA) -> DIMENSIONLESS:
raise_if_negative(f_ck=f_ck, f_yk=f_yk)
return (0.08 * np.sqrt(f_ck)) / f_yk

def latex(self) -> LatexFormula:
def latex(self, n: int = 2) -> LatexFormula:
"""Returns LatexFormula object for formula 9.5N."""
return LatexFormula(
return_symbol=r"\rho_{w,min}",
result=f"{self:.6f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -95,6 +95,8 @@
"""Newton per square meter (N/m²), represented as a float."""
KN_M2 = float
"""Kilonewton per square meter (kN/m²), represented as a float."""
KN_M3 = float
"""Kilonewton per cubic meter (kN/m3), represented as a float."""
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

³

@@ -44,12 +44,12 @@ def _evaluate(
raise_if_less_or_equal_to_zero(l_0=l_0)
return theta_i * l_0 / 2

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 5.2."""
return LatexFormula(
return_symbol=r"e_i",
result=f"{self:.4f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

@@ -53,13 +53,13 @@ def _evaluate(
raise_if_negative(theta_0=theta_0, alpha_h=alpha_h, alpha_m=alpha_m)
return theta_0 * alpha_h * alpha_m

def latex(self) -> LatexFormula:
def latex(self, n: int = 3) -> LatexFormula:
"""Returns LatexFormula object for formula 5.1."""
return LatexFormula(
return_symbol=r"\theta_i",
result=f"{self:.4f}",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as before

msg = "Radius is equal to- or larger than 0.3m, use: Eq2Dot21ModulusHorizontalSubgrade"
raise ValueError(msg)

def latex(self, n: int = 3) -> LatexFormula:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nothing is preventing a user from submitting a negative value. maybe its wice to always pick the larger value of 0 and n?

@GerjanDorgelo
Copy link
Contributor

Because of merges to the main, there are a few extra files that require this change.

@egarciamendez egarciamendez added the in review This MR has been reviewed, and changes are made accordingly label Apr 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in review This MR has been reviewed, and changes are made accordingly
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[✨ Feature request]: Set n decimals as abstract method to latex Formula
4 participants