Skip to content

Fix Bug in power 0.5

sqrtM=dsiUnit(r'\metre')**0.5

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
Cell In[17], line 2
      1 sqrtM=dsiUnit(r'\metre')**0.5
----> 2 Latex(sqrtM.toLatex())

File C:\repos\dsiUnits\venv\lib\site-packages\dsiUnits.py:109, in dsiUnit.toLatex(self, wrapper, prefix, suffix)
    107 if len(self.tree) == 1:  # no fractions
    108     for node in self.tree[0]:
--> 109         latexArray.append(node.toLatex())
    110     latexString = r'\,'.join(latexArray)
    111 elif len(self.tree) == 2:  # one fraction

File C:\repos\dsiUnits\venv\lib\site-packages\dsiUnitNode.py:77, in dsiUnitNode.toLatex(self)
     75         raise RuntimeError("Found invalid unit in valid node, this should not happen! Report this incident at: https://gitlab1.ptb.de/digitaldynamicmeasurement/dsiUnits/-/issues/new")
     76 elif self.exponent != 1:
---> 77     if not self.exponent.denominator == 1: # exponent is not an integer
     78         if self.exponent.denominator == 2: # square root
     79             latexString = r'\sqrt{' + latexString 

AttributeError: 'float' object has no attribute 'denominator'