colourmap 1.1.20__tar.gz → 1.2.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: colourmap
3
- Version: 1.1.20
3
+ Version: 1.2.0
4
4
  Summary: Python package colourmap generates an N unique colors from the specified input colormap.
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License: MIT License
@@ -37,6 +37,8 @@ Description-Content-Type: text/markdown
37
37
  License-File: LICENSE
38
38
  Requires-Dist: matplotlib
39
39
  Requires-Dist: numpy
40
+ Requires-Dist: scipy
41
+ Dynamic: license-file
40
42
 
41
43
  # colourmap
42
44
 
@@ -1,3 +1,5 @@
1
+ import logging
2
+
1
3
  from colourmap.colourmap import (
2
4
  generate,
3
5
  fromlist,
@@ -12,8 +14,17 @@ from colourmap.colourmap import (
12
14
 
13
15
  __author__ = 'Erdogan Tasksen'
14
16
  __email__ = 'erdogant@gmail.com'
15
- __version__ = '1.1.20'
17
+ __version__ = '1.2.0'
16
18
 
19
+ # Setup root logger
20
+ _logger = logging.getLogger('colourmap')
21
+ _log_handler = logging.StreamHandler()
22
+ _fmt = '[{asctime}] [{name}] [{levelname}] {msg}'
23
+ _formatter = logging.Formatter(fmt=_fmt, style='{', datefmt='%d-%m-%Y %H:%M:%S')
24
+ _log_handler.setFormatter(_formatter)
25
+ _log_handler.setLevel(logging.DEBUG)
26
+ _logger.addHandler(_log_handler)
27
+ _logger.propagate = False
17
28
 
18
29
  # module level doc-string
19
30
  __doc__ = """
@@ -12,15 +12,9 @@ import matplotlib.pyplot as plt
12
12
  import numpy as np
13
13
  import logging
14
14
 
15
- # Ensuring a minimum width of 12
16
- NAME_WIDTH = max(len(__name__), 12)
17
- logger = logging.getLogger('')
18
- [logger.removeHandler(handler) for handler in logger.handlers[:]]
19
- logging.basicConfig(
20
- format=f"%(asctime)s [%(name)-{NAME_WIDTH}s]> %(levelname)-8s> %(message)s",
21
- datefmt="%d-%m-%y %H:%M:%S",
22
- level=logging.INFO)
23
15
  logger = logging.getLogger(__name__)
16
+ if not logger.hasHandlers():
17
+ logging.basicConfig(level=logging.INFO, format='[{asctime}] [{name}] [{levelname}] {msg}', style='{', datefmt='%d-%m-%Y %H:%M:%S')
24
18
 
25
19
 
26
20
  # %% Main
@@ -543,6 +537,7 @@ def _normalize(X):
543
537
  return out
544
538
 
545
539
 
540
+ #%%
546
541
  def convert_verbose_to_new(verbose):
547
542
  """Convert old verbosity to the new one."""
548
543
  # In case the new verbosity is used, convert to the old one.
@@ -563,25 +558,23 @@ def convert_verbose_to_new(verbose):
563
558
  return verbose
564
559
 
565
560
 
566
- # %%
567
561
  def get_logger():
568
562
  """Return logger status."""
569
563
  return logger.getEffectiveLevel()
570
564
 
571
565
 
572
- # %%
573
- def set_logger(verbose: [str, int] = 'info'):
566
+ def set_logger(verbose: [str, int] = 'info', return_status: bool = False):
574
567
  """Set the logger for verbosity messages.
575
568
 
576
569
  Parameters
577
570
  ----------
578
- verbose : [str, int], default is 'info' or 20
579
- Set the verbose messages using string or integer values.
580
- * [0, 60, None, 'silent', 'off', 'no']: No message.
581
- * [10, 'debug']: Messages from debug level and higher.
582
- * [20, 'info']: Messages from info level and higher.
583
- * [30, 'warning']: Messages from warning level and higher.
584
- * [50, 'critical', 'error']: Messages from critical level and higher.
571
+ verbose : str or int, optional, default='info' (20)
572
+ Logging verbosity level. Possible values:
573
+ - 0, 60, None, 'silent', 'off', 'no' : no messages.
574
+ - 10, 'debug' : debug level and above.
575
+ - 20, 'info' : info level and above.
576
+ - 30, 'warning' : warning level and above.
577
+ - 50, 'critical' : critical level and above.
585
578
 
586
579
  Returns
587
580
  -------
@@ -596,27 +589,32 @@ def set_logger(verbose: [str, int] = 'info'):
596
589
  > logger.critical("Hello critical")
597
590
 
598
591
  """
592
+ # Convert verbose to new
593
+ verbose = convert_verbose_to_new(verbose)
599
594
  # Set 0 and None as no messages.
600
595
  if (verbose==0) or (verbose is None):
601
596
  verbose=60
602
- verbose = convert_verbose_to_new(verbose)
603
597
  # Convert str to levels
604
598
  if isinstance(verbose, str):
605
- levels = {'silent': 60,
606
- 'off': 60,
607
- 'no': 60,
608
- 'debug': 10,
609
- 'info': 20,
610
- 'warning': 30,
611
- 'error': 50,
612
- 'critical': 50}
599
+ levels = {
600
+ 'silent': logging.CRITICAL + 10,
601
+ 'off': logging.CRITICAL + 10,
602
+ 'no': logging.CRITICAL + 10,
603
+ 'debug': logging.DEBUG,
604
+ 'info': logging.INFO,
605
+ 'warning': logging.WARNING,
606
+ 'error': logging.ERROR,
607
+ 'critical': logging.CRITICAL,
608
+ }
613
609
  verbose = levels[verbose]
614
610
 
615
611
  # Show examples
616
612
  logger.setLevel(verbose)
617
613
 
614
+ if return_status:
615
+ return verbose
616
+
618
617
 
619
- # %%
620
618
  def check_logger(verbose: [str, int] = 'info'):
621
619
  """Check the logger."""
622
620
  set_logger(verbose)
@@ -626,7 +624,6 @@ def check_logger(verbose: [str, int] = 'info'):
626
624
  logger.critical('CRITICAL')
627
625
 
628
626
 
629
- # %%
630
627
  def disable_tqdm():
631
628
  """Set the logger for verbosity messages."""
632
629
  return (True if (logger.getEffectiveLevel()>=30) else False)
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: colourmap
3
- Version: 1.1.20
3
+ Version: 1.2.0
4
4
  Summary: Python package colourmap generates an N unique colors from the specified input colormap.
5
5
  Author-email: Erdogan Taskesen <erdogant@gmail.com>
6
6
  License: MIT License
@@ -37,6 +37,8 @@ Description-Content-Type: text/markdown
37
37
  License-File: LICENSE
38
38
  Requires-Dist: matplotlib
39
39
  Requires-Dist: numpy
40
+ Requires-Dist: scipy
41
+ Dynamic: license-file
40
42
 
41
43
  # colourmap
42
44
 
@@ -1,2 +1,3 @@
1
1
  matplotlib
2
2
  numpy
3
+ scipy
@@ -19,6 +19,7 @@ classifiers = [
19
19
  dependencies = [
20
20
  'matplotlib',
21
21
  'numpy',
22
+ 'scipy',
22
23
  ]
23
24
 
24
25
  [project.urls]
File without changes
File without changes
File without changes
File without changes