[utils.curves] use numpy.trapezoid for 2.0 compatibility
fall back to trapz if import fails
This commit is contained in:
		
							parent
							
								
									6c76e1f5cf
								
							
						
					
					
						commit
						9b2f8599e6
					
				@ -2,6 +2,11 @@ import numpy
 | 
				
			|||||||
from numpy.typing import ArrayLike, NDArray
 | 
					from numpy.typing import ArrayLike, NDArray
 | 
				
			||||||
from numpy import pi
 | 
					from numpy import pi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					try:
 | 
				
			||||||
 | 
					    from numpy import trapezoid
 | 
				
			||||||
 | 
					except ImportError:
 | 
				
			||||||
 | 
					    from numpy import trapz as trapezoid
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
def bezier(
 | 
					def bezier(
 | 
				
			||||||
        nodes: ArrayLike,
 | 
					        nodes: ArrayLike,
 | 
				
			||||||
@ -68,8 +73,8 @@ def euler_bend(
 | 
				
			|||||||
        yy = []
 | 
					        yy = []
 | 
				
			||||||
        for ll in numpy.linspace(0, ll_max, num_points_spiral):
 | 
					        for ll in numpy.linspace(0, ll_max, num_points_spiral):
 | 
				
			||||||
            qq = numpy.linspace(0, ll, 1000)        # integrate to current arclength
 | 
					            qq = numpy.linspace(0, ll, 1000)        # integrate to current arclength
 | 
				
			||||||
            xx.append(numpy.trapz( numpy.cos(qq * qq / 2), qq))
 | 
					            xx.append(trapezoid( numpy.cos(qq * qq / 2), qq))
 | 
				
			||||||
            yy.append(numpy.trapz(-numpy.sin(qq * qq / 2), qq))
 | 
					            yy.append(trapezoid(-numpy.sin(qq * qq / 2), qq))
 | 
				
			||||||
        xy_part = numpy.stack((xx, yy), axis=1)
 | 
					        xy_part = numpy.stack((xx, yy), axis=1)
 | 
				
			||||||
        return xy_part
 | 
					        return xy_part
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user