Ejemplo n.º 1
0
 def latex(self, **kwargs):
     inner_str = NumberSet.latex(self, **kwargs)
     # only fence if forceFence=True (nested exponents is an
     # example of when fencing must be forced)
     kwargs['fence'] = (kwargs['forceFence']
                        if 'forceFence' in kwargs else False)
     return maybeFencedString(inner_str, **kwargs)
Ejemplo n.º 2
0
 def formatted(self, formatType, **kwargs):
     # begin building the inner_str
     inner_str = self.base.formatted(formatType, fence=True, forceFence=True)
     if self.getStyle('exponent') == 'raised':
         inner_str = (
                 inner_str
                 + r'^{'+self.exponent.formatted(formatType, fence=False)
                 + '}')
     elif self.getStyle('exponent') == 'radical':
         if self.exponent == frac(one, two):
             if formatType == 'string':
                 inner_str = (
                         r'sqrt('
                         + self.base.formatted(formatType, fence=True,
                                               forceFence=True)
                         + ')')
             elif formatType == 'latex':
                 inner_str = (
                         r'\sqrt{'
                         + self.base.formatted(formatType, fence=True,
                                               forceFence=True)
                         + '}')
         else:
             raise ValueError("Unkown radical type, exponentiating to the power "
                              "of %s"%str(self.exponent))
             
     # only fence if forceFence=True (nested exponents is an
     # example of when fencing must be forced)
     kwargs['fence'] = (
         kwargs['forceFence'] if 'forceFence' in kwargs else False)
     return maybeFencedString(inner_str, **kwargs)
Ejemplo n.º 3
0
 def formatted(self, formatType, **kwargs):
     inner_str = self.base.formatted(
         formatType, forceFence=True) + r'^{' + self.exponent.formatted(
             formatType, fence=False) + '}'
     # only fence if forceFence=True (nested exponents is an example of when fencing must be forced)
     kwargs['fence'] = kwargs[
         'forceFence'] if 'forceFence' in kwargs else False
     return maybeFencedString(inner_str, **kwargs)
Ejemplo n.º 4
0
 def string(self, **kwargs):
     return maybeFencedString('-' + self.operand.string(fence=True),
                              **kwargs)