custom __copy__ for SubPattern and GridRepetition
the difference between copy/deepcopy should be whether a copy is made of the contained pattern
This commit is contained in:
		
							parent
							
								
									7b0a567625
								
							
						
					
					
						commit
						4bc51f765f
					
				| @ -100,14 +100,23 @@ class GridRepetition: | ||||
|             mirrored = [False, False] | ||||
|         self.mirrored = mirrored | ||||
| 
 | ||||
|     def  __copy__(self) -> 'GridRepetition': | ||||
|         new = GridRepetition(pattern=self.pattern, | ||||
|                              a_vector=self.a_vector.copy(), | ||||
|                              b_vector=copy.copy(self.b_vector), | ||||
|                              a_count=self.a_count, | ||||
|                              b_count=self.b_count, | ||||
|                              offset=self.offset.copy(), | ||||
|                              rotation=self.rotation, | ||||
|                              dose=self.dose, | ||||
|                              scale=self.scale, | ||||
|                              mirrored=self.mirrored.copy()) | ||||
|         return new | ||||
| 
 | ||||
|     def  __deepcopy__(self, memo: Dict = None) -> 'GridReptition': | ||||
|         memo = {} if memo is None else memo | ||||
|         new = copy.copy(self) | ||||
|         new.pattern = copy.deepcopy(self.pattern, memo) | ||||
|         new._offset = self._offset.copy() | ||||
|         new._mirrored = copy.deepcopy(self._mirrored, memo) | ||||
|         new._a_vector = self._a_vector.copy() | ||||
|         new._b_vector = copy.copy(self._b_vector)       # ndarray or None so don't need deepcopy | ||||
|         return new | ||||
| 
 | ||||
|     # offset property | ||||
|  | ||||
| @ -47,12 +47,19 @@ class SubPattern: | ||||
|             mirrored = [False, False] | ||||
|         self.mirrored = mirrored | ||||
| 
 | ||||
|     def  __copy__(self) -> 'SubPattern': | ||||
|         new = SubPattern(pattern=self.pattern, | ||||
|                          offset=self.offset.copy(), | ||||
|                          rotation=self.rotation, | ||||
|                          dose=self.dose, | ||||
|                          scale=self.scale, | ||||
|                          mirrored=self.mirrored.copy()) | ||||
|         return new | ||||
| 
 | ||||
|     def  __deepcopy__(self, memo: Dict = None) -> 'SubPattern': | ||||
|         memo = {} if memo is None else memo | ||||
|         new = copy.copy(self) | ||||
|         new.pattern = copy.deepcopy(self.pattern, memo) | ||||
|         new._offset = self._offset.copy() | ||||
|         new._mirrored = copy.deepcopy(self._mirrored, memo) | ||||
|         return new | ||||
| 
 | ||||
|     # offset property | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user