From 1afa386404d35634182600f7347035396fa96192 Mon Sep 17 00:00:00 2001 From: paul019 <39464035+paul019@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:32:35 +0200 Subject: [PATCH 1/5] Remove spaces in units --- src/api/console_stringifier.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/api/console_stringifier.py b/src/api/console_stringifier.py index a1b9a980..fd795e71 100644 --- a/src/api/console_stringifier.py +++ b/src/api/console_stringifier.py @@ -34,7 +34,8 @@ def _modify_unit(self, unit: str) -> str: Returns the modified unit. """ unit = ( - unit.replace(r"\squared", "^2") + unit.replace(" ", "") + .replace(r"\squared", "^2") .replace(r"\cubed", "^3") .replace("\\per\\", "/") .replace(r"\per", "/") From 297e2b626d141012941e871647e54ddc7015f807 Mon Sep 17 00:00:00 2001 From: paul019 <39464035+paul019@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:40:10 +0200 Subject: [PATCH 2/5] Detect percent as unit in console stringifier --- src/api/console_stringifier.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/api/console_stringifier.py b/src/api/console_stringifier.py index fd795e71..914cdbe3 100644 --- a/src/api/console_stringifier.py +++ b/src/api/console_stringifier.py @@ -37,6 +37,7 @@ def _modify_unit(self, unit: str) -> str: unit.replace(" ", "") .replace(r"\squared", "^2") .replace(r"\cubed", "^3") + .replace("\\percent", "\\%") .replace("\\per\\", "/") .replace(r"\per", "/") .replace("\\", " ") From fd34ca2d12333f17d952418371ffdc08d72f1a09 Mon Sep 17 00:00:00 2001 From: paul019 <39464035+paul019@users.noreply.github.com> Date: Thu, 11 Apr 2024 23:44:56 +0200 Subject: [PATCH 3/5] Replace error by uncert --- src/application/latex_commandifier.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/application/latex_commandifier.py b/src/application/latex_commandifier.py index 0b06f193..e43d2be3 100644 --- a/src/application/latex_commandifier.py +++ b/src/application/latex_commandifier.py @@ -28,7 +28,7 @@ def result_to_latex_cmd(self, result: Result) -> str: # Without error if len(result.uncertainties) > 0: - builder.add_branch("withoutError", self.result_to_latex_str_without_error(result)) + builder.add_branch("withoutUncert", self.result_to_latex_str_without_uncert(result)) # Single uncertainties for i, u in enumerate(result.uncertainties): @@ -82,7 +82,7 @@ def result_to_latex_str_value(self, result: Result) -> str: """ return self.s.create_str(result.value, [], "") - def result_to_latex_str_without_error(self, result: Result) -> str: + def result_to_latex_str_without_uncert(self, result: Result) -> str: """ Returns the result without error as LaTeX string making use of the siunitx package. """ From 0353346ff78ab0a968cb88e1626f4b7793eb018b Mon Sep 17 00:00:00 2001 From: paul019 <39464035+paul019@users.noreply.github.com> Date: Fri, 12 Apr 2024 11:41:39 +0200 Subject: [PATCH 4/5] Undo unwanted changes --- src/api/console_stringifier.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/api/console_stringifier.py b/src/api/console_stringifier.py index 914cdbe3..a1b9a980 100644 --- a/src/api/console_stringifier.py +++ b/src/api/console_stringifier.py @@ -34,10 +34,8 @@ def _modify_unit(self, unit: str) -> str: Returns the modified unit. """ unit = ( - unit.replace(" ", "") - .replace(r"\squared", "^2") + unit.replace(r"\squared", "^2") .replace(r"\cubed", "^3") - .replace("\\percent", "\\%") .replace("\\per\\", "/") .replace(r"\per", "/") .replace("\\", " ") From 219b3e8ad0076331254a36c55b0cb62142b71cdd Mon Sep 17 00:00:00 2001 From: paul019 <39464035+paul019@users.noreply.github.com> Date: Sun, 21 Apr 2024 23:16:12 +0200 Subject: [PATCH 5/5] Replace error by uncertainty in various places --- src/api/console_stringifier.py | 4 ++-- .../latex_better_siunitx_stringifier.py | 4 ++-- src/application/latex_commandifier.py | 16 ++++++++-------- src/application/latex_stringifier.py | 4 ++-- src/application/stringifier.py | 8 ++++---- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/api/console_stringifier.py b/src/api/console_stringifier.py index a1b9a980..e3a77dbc 100644 --- a/src/api/console_stringifier.py +++ b/src/api/console_stringifier.py @@ -13,8 +13,8 @@ class ConsoleStringifier(Stringifier): value_prefix = "" value_suffix = "" - error_name_prefix = " (" - error_name_suffix = ")" + uncertainty_name_prefix = " (" + uncertainty_name_suffix = ")" scientific_notation_prefix = "e" scientific_notation_suffix = "" diff --git a/src/application/latex_better_siunitx_stringifier.py b/src/application/latex_better_siunitx_stringifier.py index 4911c33c..46ee91b9 100644 --- a/src/application/latex_better_siunitx_stringifier.py +++ b/src/application/latex_better_siunitx_stringifier.py @@ -22,8 +22,8 @@ class LatexBetterSiunitxStringifier(Stringifier): value_prefix = "" value_suffix = "" - error_name_prefix = r"\Uncert" - error_name_suffix = "" + uncertainty_name_prefix = r"\Uncert" + uncertainty_name_suffix = "" scientific_notation_prefix = "e" scientific_notation_suffix = "" diff --git a/src/application/latex_commandifier.py b/src/application/latex_commandifier.py index e43d2be3..8012f41a 100644 --- a/src/application/latex_commandifier.py +++ b/src/application/latex_commandifier.py @@ -26,29 +26,29 @@ def result_to_latex_cmd(self, result: Result) -> str: builder.add_branch("", self.result_to_latex_str(result)) builder.add_branch("value", self.result_to_latex_str_value(result)) - # Without error + # Without uncertainty if len(result.uncertainties) > 0: builder.add_branch("withoutUncert", self.result_to_latex_str_without_uncert(result)) # Single uncertainties for i, u in enumerate(result.uncertainties): if len(result.uncertainties) == 1: - uncertainty_name = "error" + uncertainty_name = "uncert" else: uncertainty_name = u.name if u.name != "" else Helpers.number_to_word(i + 1) - uncertainty_name = f"error{Helpers.capitalize(uncertainty_name)}" - error_latex_str = self.s.create_str(u.uncertainty, [], result.unit) - builder.add_branch(uncertainty_name, error_latex_str) + uncertainty_name = f"uncert{Helpers.capitalize(uncertainty_name)}" + uncertainty_latex_str = self.s.create_str(u.uncertainty, [], result.unit) + builder.add_branch(uncertainty_name, uncertainty_latex_str) # Total uncertainty and short result if len(result.uncertainties) >= 2: short_result = result.get_short_result() if short_result is None: raise RuntimeError(error_messages.SHORT_RESULT_IS_NONE) - error_latex_str = self.s.create_str( + uncertainty_latex_str = self.s.create_str( short_result.uncertainties[0].uncertainty, [], result.unit ) - builder.add_branch("errorTotal", error_latex_str) + builder.add_branch("uncertTotal", uncertainty_latex_str) builder.add_branch("short", self.result_to_latex_str(short_result)) # Unit @@ -84,7 +84,7 @@ def result_to_latex_str_value(self, result: Result) -> str: def result_to_latex_str_without_uncert(self, result: Result) -> str: """ - Returns the result without error as LaTeX string making use of the siunitx package. + Returns the result without uncertainty as LaTeX string making use of the siunitx package. """ return self.s.create_str(result.value, [], result.unit) diff --git a/src/application/latex_stringifier.py b/src/application/latex_stringifier.py index 4380b385..08ae6f1b 100644 --- a/src/application/latex_stringifier.py +++ b/src/application/latex_stringifier.py @@ -19,8 +19,8 @@ class LatexStringifier(Stringifier): value_prefix = r"\num{" value_suffix = r"}" - error_name_prefix = r"_{\text{" - error_name_suffix = r"}}" + uncertainty_name_prefix = r"_{\text{" + uncertainty_name_suffix = r"}}" scientific_notation_prefix = r" \cdot 10^{" scientific_notation_suffix = "}" diff --git a/src/application/stringifier.py b/src/application/stringifier.py index ce78fdcd..35d70406 100644 --- a/src/application/stringifier.py +++ b/src/application/stringifier.py @@ -38,8 +38,8 @@ class Stringifier(Protocol): value_prefix: ClassVar[str] value_suffix: ClassVar[str] - error_name_prefix: ClassVar[str] - error_name_suffix: ClassVar[str] + uncertainty_name_prefix: ClassVar[str] + uncertainty_name_suffix: ClassVar[str] scientific_notation_prefix: ClassVar[str] scientific_notation_suffix: ClassVar[str] @@ -68,9 +68,9 @@ def create_str(self, value: Value, uncertainties: List[Uncertainty], unit: str) u_rounded = self._uncertainty_to_str(u, use_scientific_notation, exponent, factor) u_rounded = f" {self.plus_minus} {self.value_prefix}{u_rounded}{self.value_suffix}" if u.name != "": - u_rounded += self.error_name_prefix + u_rounded += self.uncertainty_name_prefix u_rounded += self._modify_uncertainty_name(u.name) - u_rounded += self.error_name_suffix + u_rounded += self.uncertainty_name_suffix uncertainties_rounded.append(u_rounded) # Assemble everything together