plotext-plus 1.0.9__py3-none-any.whl → 1.0.10__py3-none-any.whl

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.
plotext_plus/_date.py CHANGED
@@ -1,60 +1,78 @@
1
+ from datetime import UTC # useful for dates before 1970 in windows
1
2
  from datetime import datetime as dt
2
- from datetime import timezone as tz # useful for dates before 1970 in windows
3
3
 
4
- class date_class():
5
-
4
+
5
+ class DateClass:
6
+
6
7
  def __init__(self):
7
8
  self.date_form()
8
9
  self.time0 = 0
9
- self.set_time0('01/01/1900')
10
+ self.set_time0("01/01/1900")
10
11
 
11
- def date_form(self, input_form = None, output_form = None): # it sets the datetime form used for functions that output date string and input date string
12
- input_form = 'd/m/Y' if input_form is None else input_form
12
+ def date_form(
13
+ self, input_form=None, output_form=None
14
+ ): # it sets the datetime form used for functions that output date string and input date string
15
+ input_form = "d/m/Y" if input_form is None else input_form
13
16
  output_form = input_form if output_form is None else output_form
14
17
  self.input_form = self.correct_form(input_form)
15
18
  self.output_form = self.correct_form(output_form)
16
-
17
- def set_time0(self, string, input_form = None): # the origin of time, useful for log scale not to hit the 0 timestamp
19
+
20
+ def set_time0(
21
+ self, string, input_form=None
22
+ ): # the origin of time, useful for log scale not to hit the 0 timestamp
18
23
  self.time0 = self.string_to_time(string, input_form, 0)
19
24
 
20
- def today_datetime(self): # today in datetime form
25
+ def today_datetime(self): # today in datetime form
21
26
  return dt.today()
22
-
23
- def today_string(self, output_form = None): # today in string form
27
+
28
+ def today_string(self, output_form=None): # today in string form
24
29
  return self.datetime_to_string(self.today_datetime(), output_form)
25
-
26
- def datetime_to_string(self, datetime, output_form = None): # from datetime form to string form
27
- output_form = self.output_form if output_form is None else self.correct_form(output_form)
30
+
31
+ def datetime_to_string(
32
+ self, datetime, output_form=None
33
+ ): # from datetime form to string form
34
+ output_form = (
35
+ self.output_form if output_form is None else self.correct_form(output_form)
36
+ )
28
37
  return datetime.strftime(output_form)
29
-
30
- def datetimes_to_strings(self, datetimes, output_form = None): # from datetime form to string form
38
+
39
+ def datetimes_to_strings(
40
+ self, datetimes, output_form=None
41
+ ): # from datetime form to string form
31
42
  return [self.datetime_to_string(el, output_form) for el in datetimes]
32
43
 
33
- def string_to_datetime(self, string, input_form = None): # from date and times in string form to standard datetime input_form
34
- input_form = self.input_form if input_form is None else self.correct_form(input_form)
44
+ def string_to_datetime(
45
+ self, string, input_form=None
46
+ ): # from date and times in string form to standard datetime input_form
47
+ input_form = (
48
+ self.input_form if input_form is None else self.correct_form(input_form)
49
+ )
35
50
  return dt.strptime(string, input_form)
36
51
 
37
- ##############################################
38
- ############ Utilities ################
39
- ##############################################
52
+ ##############################################
53
+ ############ Utilities ################
54
+ ##############################################
40
55
 
41
56
  def correct_form(self, date_form):
42
- return ''.join(['%' + el if el.isalpha() else el for el in date_form])
57
+ return "".join(["%" + el if el.isalpha() else el for el in date_form])
43
58
 
44
- def string_to_time(self, string, input_form = None, time0 = None):
45
- input_form = self.input_form if input_form is None else self.correct_form(input_form)
59
+ def string_to_time(self, string, input_form=None, time0=None):
60
+ input_form = (
61
+ self.input_form if input_form is None else self.correct_form(input_form)
62
+ )
46
63
  time0 = self.time0 if time0 is None else time0
47
64
  try:
48
- return dt.strptime(string, input_form).replace(tzinfo = tz.utc).timestamp() - time0
49
- except:
50
- raise ValueError('Date Form should be: ' + input_form)
65
+ return (
66
+ dt.strptime(string, input_form).replace(tzinfo=UTC).timestamp() - time0
67
+ )
68
+ except ValueError as e:
69
+ raise ValueError("Date Form should be: " + input_form) from e
51
70
 
52
- def strings_to_time(self, strings, input_form = None):
71
+ def strings_to_time(self, strings, input_form=None):
53
72
  return [self.string_to_time(el, input_form) for el in strings]
54
73
 
55
- def time_to_string(self, time, output_form = None):
74
+ def time_to_string(self, time, output_form=None):
56
75
  return self.datetime_to_string(dt.fromtimestamp(time + self.time0), output_form)
57
-
58
- def times_to_string(self, times, input_form = None):
59
- return [self.time_to_string(el, input_form) for el in times]
60
76
 
77
+ def times_to_string(self, times, input_form=None):
78
+ return [self.time_to_string(el, input_form) for el in times]
plotext_plus/_default.py CHANGED
@@ -1,33 +1,35 @@
1
- #from plotext_plus._utility import bar_marker
2
- from plotext_plus._utility import no_color, plot_marker
1
+ # from plotext_plus._utility import bar_marker
2
+ from plotext_plus._utility import no_color
3
+ from plotext_plus._utility import plot_marker
4
+
5
+
6
+ class DefaultFigureClass:
3
7
 
4
- class default_figure_class():
5
-
6
8
  def __init__(self):
7
9
  self.set_limitsize()
8
10
  self.set_size_term()
9
11
  self.set_size_term_inf()
10
12
  self.interactive = False
11
13
 
12
- def set_limitsize(self, limit_width = None, limit_height = None):
14
+ def set_limitsize(self, limit_width=None, limit_height=None):
13
15
  self.limit_width = True if limit_width is None else bool(limit_width)
14
16
  self.limit_height = True if limit_height is None else bool(limit_height)
15
17
  self.limit_size = [self.limit_width, self.limit_height]
16
18
 
17
- def set_size_term(self, width = None, height = None):
19
+ def set_size_term(self, width=None, height=None):
18
20
  self.width_term = 211 * 2 // 3 if width is None else int(width)
19
21
  self.height_term = 53 * 2 // 3 if height is None else int(height)
20
22
  self.size_term = [self.width_term, self.height_term]
21
23
 
22
- def set_size_term_inf(self, width = None, height = None):
24
+ def set_size_term_inf(self, width=None, height=None):
23
25
  m = 5
24
26
  self.width_term_inf = m * self.width_term if width is None else int(width)
25
27
  self.height_term_inf = m * self.height_term if height is None else int(height)
26
28
  self.size_term_inf = [self.width_term, self.height_term]
27
29
 
28
-
29
- class default_monitor_class():
30
-
30
+
31
+ class DefaultMonitorClass:
32
+
31
33
  def __init__(self):
32
34
  self.marker = plot_marker
33
35
  self.color_init()
@@ -38,7 +40,7 @@ class default_monitor_class():
38
40
  self.bar_init()
39
41
  self.confusion_matrix_init()
40
42
 
41
- def color_init(self): # Default Values for Color Set with Outside Functions
43
+ def color_init(self): # Default Values for Color Set with Outside Functions
42
44
  self.canvas_color = "white"
43
45
  self.axes_color = "white"
44
46
  self.ticks_color = "black"
@@ -47,37 +49,42 @@ class default_monitor_class():
47
49
  def axes_init(self): # Default Values for Variables Set with Outside Functions
48
50
  self.xaxes = [True, True]
49
51
  self.yaxes = [True, True]
50
- self.xfrequency = [5, 5] # lower and upper xaxes ticks frequency
51
- self.yfrequency = [7, 7] # left and right yaxes ticks frequency
52
- self.xdirection = [1, 1] # direction of x axes
52
+ self.xfrequency = [5, 5] # lower and upper xaxes ticks frequency
53
+ self.yfrequency = [7, 7] # left and right yaxes ticks frequency
54
+ self.xdirection = [1, 1] # direction of x axes
53
55
  self.ydirection = [1, 1]
54
- self.xticks = [None, None] # xticks coordinates for both axes
56
+ self.xticks = [None, None] # xticks coordinates for both axes
55
57
  self.yticks = [None, None]
56
58
 
57
59
  def canvas_init(self):
58
- self.xscale = ["linear", "log"] # the two possibilities, the first is default
60
+ self.xscale = ["linear", "log"] # the two possibilities, the first is default
59
61
  self.yscale = ["linear", "log"]
60
62
  self.grid = [False, False]
61
-
63
+
62
64
  def text_init(self):
63
- self.alignment = ['left', 'center', 'right', 'top', 'bottom', 'dynamic']
64
- self.orientation = ['horizontal', 'vertical'] # the two possible orientations, the first is the default: v = vertical, h = horizontal
65
-
66
- def draw_init(self): # Default Values for Variables Set with Draw internal Arguments
67
- self.xside = ["lower", "upper"] # the two possibilities, the first is default
68
- self.yside = ["left", "right"] # the two possibilities, the first is default
65
+ self.alignment = ["left", "center", "right", "top", "bottom", "dynamic"]
66
+ self.orientation = [
67
+ "horizontal",
68
+ "vertical",
69
+ ] # the two possible orientations, the first is the default: v = vertical, h = horizontal
70
+
71
+ def draw_init(
72
+ self,
73
+ ): # Default Values for Variables Set with Draw internal Arguments
74
+ self.xside = ["lower", "upper"] # the two possibilities, the first is default
75
+ self.yside = ["left", "right"] # the two possibilities, the first is default
69
76
  self.lines = False
70
77
  self.fill = False
71
78
  self.fill_internal = "internal"
72
- #self.filly = False
79
+ # self.filly = False
73
80
  self.label = None
74
81
 
75
82
  def bar_init(self):
76
83
  self.bar_marker = "sd"
77
- self.bar_fill = True # bar plot filled or not
78
- self.bar_width = 4 / 5 # bar width
84
+ self.bar_fill = True # bar plot filled or not
85
+ self.bar_width = 4 / 5 # bar width
79
86
  self.hist_bins = 10
80
87
 
81
88
  def confusion_matrix_init(self):
82
- self.cmatrix_color = 'orange+'
83
- self.cmatrix_style = 'bold'
89
+ self.cmatrix_color = "orange+"
90
+ self.cmatrix_style = "bold"