optimize consecutive & clean unused var
This commit is contained in:
parent
a6781588bb
commit
9b2d879dab
1 changed files with 1 additions and 5 deletions
6
utils.py
6
utils.py
|
@ -2,8 +2,6 @@ from astropy.io.fits import open
|
||||||
import cv2
|
import cv2
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
global_i = 0
|
|
||||||
|
|
||||||
def load( filename ):
|
def load( filename ):
|
||||||
"""
|
"""
|
||||||
retrieve data from naroo fits
|
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
|
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 ):
|
if not isinstance( data , np.ndarray ) and not isinstance( data , list ):
|
||||||
raise ValueError( 'data must be a list, ' + type( data ) + ' given' )
|
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 ):
|
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_ )
|
index = last_consecutive( list_ )
|
||||||
if index == len( list_ ) - 1:
|
if index == len( list_ ) - 1:
|
||||||
return [ list_ ]
|
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_ ):
|
def last_consecutive( list_ ):
|
||||||
"""
|
"""
|
||||||
return the last index of the first consecutive list
|
return the last index of the first consecutive list
|
||||||
|
|
Loading…
Reference in a new issue