Skip to content

Commit

Permalink
moved around toStdDevSmalestPrecision
Browse files Browse the repository at this point in the history
Added missing examples to the resources
  • Loading branch information
rozyczko committed Feb 17, 2025
1 parent 3758254 commit 41501a2
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 33 deletions.
37 changes: 4 additions & 33 deletions easyDiffractionApp/Logic/Helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,14 @@
import os
import pathlib
import sys
import decimal
import importlib.util
import numpy as np
from uncertainties import ufloat

from PySide6.QtCore import Qt, QObject, QCoreApplication, QUrl, Signal, Slot, Property
#from PySide6.QtGui import QStyleHints
from PySide6.QtWidgets import QApplication

from EasyApp.Logic.Logging import console
from easydiffraction.io.cif import toStdDevSmalestPrecision as toStdDevSmalestPrecisionLib


class PersistentSettingsHandler:
Expand Down Expand Up @@ -235,19 +233,9 @@ def listToUri(self, fpathParts):

@Slot(float, float, result='QVariant')
def toStdDevSmalestPrecision(self, value, std_dev):
if std_dev > 1:
value_str = f'{round(value)}'
std_dev_str = f'{round(std_dev)}'
value_with_std_dev_str = f'{value_str}({std_dev_str})'
else:
precision = 1
std_dev_decimals = precision - int(np.floor(np.log10(std_dev) + 1))
std_dev = round(std_dev, std_dev_decimals)
std_dev_str = f'{std_dev:.{std_dev_decimals}f}'
value = round(value, std_dev_decimals)
value_str = f'{value:.{std_dev_decimals}f}'
clipped_std_dev = int(round(std_dev * 10**std_dev_decimals))
value_with_std_dev_str = f'{value_str}({clipped_std_dev})'
value, std_dev, _ = toStdDevSmalestPrecisionLib(value, std_dev)
value_str = f'{value}'
std_dev_str = f'{std_dev}'
return {'value': value_str, 'std_dev': std_dev_str}


Expand Down Expand Up @@ -313,20 +301,3 @@ def formatMsg(type, *args):
msg = ' ▌ '.join(msgs)
msg = f'{mark} {msg}'
return msg

@staticmethod
def toStdDevSmalestPrecision(value, std_dev):
if std_dev > 1:
value_str = f'{round(value)}'
std_dev_str = f'{round(std_dev)}'
value_with_std_dev_str = f'{value_str}({std_dev_str})'
else:
precision = 1
std_dev_decimals = precision - int(np.floor(np.log10(std_dev) + 1))
std_dev = round(std_dev, std_dev_decimals)
std_dev_str = f'{std_dev:.{std_dev_decimals}f}'
value = round(value, std_dev_decimals)
value_str = f'{value:.{std_dev_decimals}f}'
clipped_std_dev = int(round(std_dev * 10**std_dev_decimals))
value_with_std_dev_str = f'{value_str}({clipped_std_dev})'
return value_str, std_dev_str, value_with_std_dev_str
16 changes: 16 additions & 0 deletions easyDiffractionApp/resources.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,21 @@
<file>Examples/Na2Ca3Al2F14_WISH@ISIS/models/ncaf_light.png</file>
<file>Examples/Na2Ca3Al2F14_WISH@ISIS/summary/report.cif</file>
<file>Examples/Na2Ca3Al2F14_WISH@ISIS/project.cif</file>
<file>Examples/CeO2_iMATERIA@J-PARC/experiments/imateria.cif</file>
<file>Examples/CeO2_iMATERIA@J-PARC/experiments/imateria_dark.png</file>
<file>Examples/CeO2_iMATERIA@J-PARC/experiments/imateria_light.png</file>
<file>Examples/CeO2_iMATERIA@J-PARC/models/ceo.cif</file>
<file>Examples/CeO2_iMATERIA@J-PARC/models/ceo_dark.png</file>
<file>Examples/CeO2_iMATERIA@J-PARC/models/ceo_light.png</file>
<file>Examples/CeO2_iMATERIA@J-PARC/summary/report.cif</file>
<file>Examples/CeO2_iMATERIA@J-PARC/project.cif</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/experiments/heidi.cif</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/experiments/heidi_dark.png</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/experiments/heidi_light.png</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/models/tbti.cif</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/models/tbti_dark.png</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/models/tbti_light.png</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/summary/report.cif</file>
<file>Examples/Tb2Ti2O7_HEiDi@MLZ/project.cif</file>
</qresource>
</RCC>

0 comments on commit 41501a2

Please sign in to comment.