From 9b2d879dabc1390e38586e590de08c54603ebd6c Mon Sep 17 00:00:00 2001 From: linarphy Date: Fri, 16 Jun 2023 15:06:36 +0200 Subject: [PATCH] optimize consecutive & clean unused var --- utils.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/utils.py b/utils.py index 5162430..39e4511 100644 --- a/utils.py +++ b/utils.py @@ -2,8 +2,6 @@ from astropy.io.fits import open import cv2 import numpy as np -global_i = 0 - def load( filename ): """ retrieve data from naroo fits @@ -96,8 +94,6 @@ def fill( data , point , tolerance , limit = 100000 ): """ give the coordinate of all points that fill the area with the given tolerance """ - global global_i - global_i += 1 if not isinstance( data , np.ndarray ) and not isinstance( data , list ): raise ValueError( 'data must be a list, ' + type( data ) + ' given' ) if not isinstance( point , np.ndarray ) and not isinstance( point , tuple ) and not isinstance( point , list ): @@ -185,7 +181,7 @@ def consecutive( list_ ): index = last_consecutive( list_ ) if index == len( list_ ) - 1: return [ list_ ] - return consecutive( list_[ : index + 1 ] ) + consecutive( list_[ index + 1 : ] ) # happy recursion \o/ + return [ list_[ : index + 1 ] ] + consecutive( list_[ index + 1 : ] ) # happy recursion \o/ def last_consecutive( list_ ): """ return the last index of the first consecutive list