@@ -27,7 +27,6 @@ class cupy(object):
2727
2828
2929import warnings
30- warnings .simplefilter ('default' )
3130
3231
3332def color_values (agg , color_key , alpha = 255 ):
@@ -537,21 +536,25 @@ def _run_numpy_natural_break(data, num_sample, k):
537536
538537 # warning if number of total data points to fit the model bigger than 40k
539538 if sample_data .size >= 40000 :
540- warnings .warn ('natural_breaks Warning: Natural break classification '
541- '(Jenks) has a complexity of O(n^2), '
542- 'your classification with {} data points may take '
543- 'a long time.' .format (sample_data .size ),
544- Warning )
539+ with warnings .catch_warnings ():
540+ warnings .simplefilter ('default' )
541+ warnings .warn ('natural_breaks Warning: Natural break '
542+ 'classification (Jenks) has a complexity of O(n^2), '
543+ 'your classification with {} data points may take '
544+ 'a long time.' .format (sample_data .size ),
545+ Warning )
545546
546547 uv = np .unique (sample_data )
547548 uvk = len (uv )
548549
549550 if uvk < k :
550- warnings .warn ('natural_breaks Warning: Not enough unique values '
551- 'in data array for {} classes. '
552- 'n_samples={} should be >= n_clusters={}. '
553- 'Using k={} instead.' .format (k , uvk , k , uvk ),
554- Warning )
551+ with warnings .catch_warnings ():
552+ warnings .simplefilter ('default' )
553+ warnings .warn ('natural_breaks Warning: Not enough unique values '
554+ 'in data array for {} classes. '
555+ 'n_samples={} should be >= n_clusters={}. '
556+ 'Using k={} instead.' .format (k , uvk , k , uvk ),
557+ Warning )
555558 uv .sort ()
556559 bins = uv
557560 else :
@@ -649,21 +652,25 @@ def _run_cupy_natural_break(data, num_sample, k):
649652
650653 # warning if number of total data points to fit the model bigger than 40k
651654 if sample_data .size >= 40000 :
652- warnings .warn ('natural_breaks Warning: Natural break classification '
653- '(Jenks) has a complexity of O(n^2), '
654- 'your classification with {} data points may take '
655- 'a long time.' .format (sample_data .size ),
656- Warning )
655+ with warnings .catch_warnings ():
656+ warnings .simplefilter ('default' )
657+ warnings .warn ('natural_breaks Warning: Natural break '
658+ 'classification (Jenks) has a complexity of O(n^2), '
659+ 'your classification with {} data points may take '
660+ 'a long time.' .format (sample_data .size ),
661+ Warning )
657662
658663 uv = cupy .unique (sample_data )
659664 uvk = len (uv )
660665
661666 if uvk < k :
662- warnings .warn ('natural_breaks Warning: Not enough unique values '
663- 'in data array for {} classes. '
664- 'n_samples={} should be >= n_clusters={}. '
665- 'Using k={} instead.' .format (k , uvk , k , uvk ),
666- Warning )
667+ with warnings .catch_warnings ():
668+ warnings .simplefilter ('default' )
669+ warnings .warn ('natural_breaks Warning: Not enough unique values '
670+ 'in data array for {} classes. '
671+ 'n_samples={} should be >= n_clusters={}. '
672+ 'Using k={} instead.' .format (k , uvk , k , uvk ),
673+ Warning )
667674 uv .sort ()
668675 bins = uv
669676 else :
0 commit comments