@@ -382,11 +382,11 @@ cdef class WithUnit:
382382 def imag (WithUnit self ):
383383 return self .__with_value(self .value.imag)
384384
385- def round (WithUnit self , unit ):
386- try :
387- return self .in_units_of(unit, True )
388- except NotTUnitsLikeError:
389- return NotImplemented
385+ # def round(WithUnit self, unit):
386+ # try:
387+ # return self.in_units_of(unit, True)
388+ # except NotTUnitsLikeError:
389+ # return NotImplemented
390390
391391 def __int__ (self ):
392392 if self .base_units.unit_count != 0 :
@@ -652,22 +652,22 @@ cdef class WithUnit:
652652
653653 def conjugate(self ) -> 'WithUnit':
654654 return self.__with_value(self.value.conjugate())
655+
656+ # def floor(self , u ):
657+ # cdef WithUnit converted
658+ # try:
659+ # converted = self.in_units_of(u, False)
660+ # return converted.__with_value(floor(converted.value))
661+ # except NotTUnitsLikeError:
662+ # return NotImplemented
655663
656- def floor(self , u ):
657- cdef WithUnit converted
658- try :
659- converted = self .in_units_of(u, False )
660- return converted.__with_value(floor(converted.value))
661- except NotTUnitsLikeError:
662- return NotImplemented
663-
664- def ceil (self , u ):
665- cdef WithUnit converted
666- try :
667- converted = self .in_units_of(u, False )
668- return converted.__with_value(ceil(converted.value))
669- except NotTUnitsLikeError:
670- return NotImplemented
664+ # def ceil(self, u):
665+ # cdef WithUnit converted
666+ # try:
667+ # converted = self.in_units_of(u, False)
668+ # return converted.__with_value(ceil(converted.value))
669+ # except NotTUnitsLikeError:
670+ # return NotImplemented
671671
672672 def sign (self ) -> int | np.ndarray:
673673 return np.sign(self.value_in_base_units())
@@ -704,6 +704,9 @@ cdef class WithUnit:
704704 self .display_units.__setstate__(pickle_info[' display_units' ])
705705 self .base_units.__setstate__(pickle_info[' base_units' ])
706706
707+ def __format__ (self , spec: str ) -> str:
708+ return self.value.__format__(spec ) + ' ' + str(self.unit )
709+
707710_try_interpret_as_with_unit = None
708711_is_value_consistent_with_default_unit_database = None
709712def init_base_unit_functions(
0 commit comments