mirror of
				https://github.com/fjosw/pyerrors.git
				synced 2025-11-04 01:25:46 +01:00 
			
		
		
		
	feat: implemented unary positive operation for Obs and CObs classes,
included tolerance for exception in Obs.plot_piechart
This commit is contained in:
		
					parent
					
						
							
								da45a398b7
							
						
					
				
			
			
				commit
				
					
						c9e1cd10af
					
				
			
		
					 1 changed files with 9 additions and 3 deletions
				
			
		| 
						 | 
					@ -582,7 +582,7 @@ class Obs:
 | 
				
			||||||
        ensemble to the error and returns a dictionary containing the fractions."""
 | 
					        ensemble to the error and returns a dictionary containing the fractions."""
 | 
				
			||||||
        if not hasattr(self, 'e_dvalue'):
 | 
					        if not hasattr(self, 'e_dvalue'):
 | 
				
			||||||
            raise Exception('Run the gamma method first.')
 | 
					            raise Exception('Run the gamma method first.')
 | 
				
			||||||
        if self._dvalue == 0.0:
 | 
					        if np.isclose(0.0, self._dvalue, atol=1e-15):
 | 
				
			||||||
            raise Exception('Error is 0.0')
 | 
					            raise Exception('Error is 0.0')
 | 
				
			||||||
        labels = self.e_names
 | 
					        labels = self.e_names
 | 
				
			||||||
        sizes = [self.e_dvalue[name] ** 2 for name in labels] / self._dvalue ** 2
 | 
					        sizes = [self.e_dvalue[name] ** 2 for name in labels] / self._dvalue ** 2
 | 
				
			||||||
| 
						 | 
					@ -729,6 +729,9 @@ class Obs:
 | 
				
			||||||
    def __rsub__(self, y):
 | 
					    def __rsub__(self, y):
 | 
				
			||||||
        return -1 * (self - y)
 | 
					        return -1 * (self - y)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __pos__(self):
 | 
				
			||||||
 | 
					        return self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __neg__(self):
 | 
					    def __neg__(self):
 | 
				
			||||||
        return -1 * self
 | 
					        return -1 * self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -911,8 +914,11 @@ class CObs:
 | 
				
			||||||
    def __abs__(self):
 | 
					    def __abs__(self):
 | 
				
			||||||
        return np.sqrt(self.real**2 + self.imag**2)
 | 
					        return np.sqrt(self.real**2 + self.imag**2)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __neg__(other):
 | 
					    def __pos__(self):
 | 
				
			||||||
        return -1 * other
 | 
					        return self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    def __neg__(self):
 | 
				
			||||||
 | 
					        return -1 * self
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    def __eq__(self, other):
 | 
					    def __eq__(self, other):
 | 
				
			||||||
        return self.real == other.real and self.imag == other.imag
 | 
					        return self.real == other.real and self.imag == other.imag
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue