py2ls 0.1.5.7__py3-none-any.whl → 0.1.5.9__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.
@@ -48,3 +48,14 @@ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144a
48
48
  bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720958208 +0200 remote set-head
49
49
  bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720960171 +0200 remote set-head
50
50
  bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720962134 +0200 remote set-head
51
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720964097 +0200 remote set-head
52
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720965917 +0200 remote set-head
53
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720967880 +0200 remote set-head
54
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720970455 +0200 remote set-head
55
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720972867 +0200 remote set-head
56
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720976483 +0200 remote set-head
57
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720979266 +0200 remote set-head
58
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720981230 +0200 remote set-head
59
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720983188 +0200 remote set-head
60
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720985088 +0200 remote set-head
61
+ bf67907e337021ebff434e02b19b30a741c144af bf67907e337021ebff434e02b19b30a741c144af Jianfeng Liu <macjianfeng@jflmbp.speedport.ip> 1720987051 +0200 remote set-head
py2ls/chat.py ADDED
@@ -0,0 +1,124 @@
1
+ import os
2
+ from datetime import datetime
3
+ import time
4
+ from duckduckgo_search import AsyncDDGS
5
+ import asyncio
6
+ import concurrent.futures
7
+ from pprint import pp
8
+
9
+ dir_save = '/Users/macjianfeng/Dropbox/Downloads/'
10
+
11
+ async def fupdate(fpath, content=None):
12
+ content = content or ""
13
+ if os.path.exists(fpath):
14
+ with open(fpath, 'r') as file:
15
+ old_content = file.read()
16
+ else:
17
+ old_content = ''
18
+
19
+ with open(fpath, 'w') as file:
20
+ file.write(content)
21
+ file.write(old_content)
22
+
23
+ async def echo_einmal(*args, **kwargs):
24
+ """
25
+ query, model="gpt", verbose=True, log=True, dir_save=dir_save
26
+ """
27
+ global dir_save
28
+
29
+ query = None
30
+ model = kwargs.get('model', 'gpt')
31
+ verbose = kwargs.get('verbose', True)
32
+ log = kwargs.get('log', True)
33
+ dir_save = kwargs.get('dir_save', dir_save)
34
+
35
+ for arg in args:
36
+ if isinstance(arg, str):
37
+ if os.path.isdir(arg):
38
+ dir_save = arg
39
+ elif len(arg) <= 5:
40
+ model = arg
41
+ else:
42
+ query = arg
43
+ elif isinstance(arg, dict):
44
+ verbose = arg.get("verbose", verbose)
45
+ log = arg.get("log", log)
46
+
47
+ def is_in_any(str_candi_short, str_full, ignore_case=True):
48
+ if isinstance(str_candi_short, str):
49
+ str_candi_short = [str_candi_short]
50
+ res_bool = []
51
+ if ignore_case:
52
+ [res_bool.append(i in str_full.lower()) for i in str_candi_short]
53
+ else:
54
+ [res_bool.append(i in str_full) for i in str_candi_short]
55
+ return any(res_bool)
56
+
57
+ def valid_mod_name(str_fly):
58
+ if is_in_any(str_fly, "claude-3-haiku"):
59
+ return "claude-3-haiku"
60
+ elif is_in_any(str_fly, "gpt-3.5"):
61
+ return "gpt-3.5"
62
+ elif is_in_any(str_fly, "llama-3-70b"):
63
+ return "llama-3-70b"
64
+ elif is_in_any(str_fly, "mixtral-8x7b"):
65
+ return "mixtral-8x7b"
66
+ else:
67
+ print(f"not support your model {model}, supported models: 'claude','gpt(default)', 'llama','mixtral'")
68
+ return "gpt-3.5" # default model
69
+
70
+ model_valid = valid_mod_name(model)
71
+
72
+ async def run_ddgs_chat(query, model_valid):
73
+ async with AsyncDDGS() as ddgs:
74
+ loop = asyncio.get_running_loop()
75
+ with concurrent.futures.ThreadPoolExecutor() as pool:
76
+ res = await loop.run_in_executor(pool, ddgs.chat, query, model_valid)
77
+ return res
78
+
79
+ res = await run_ddgs_chat(query, model_valid)
80
+
81
+ if verbose:
82
+ print("\n") # add a newline
83
+ # pp(res)
84
+ print(res)
85
+
86
+ if log:
87
+ dt_str = datetime.fromtimestamp(time.time()).strftime('%Y-%m-%d_%H:%M:%S')
88
+ res_ = f"\n\n#### Q: {query}\n\n##### Ans: {dt_str}\n\n> {res}\n"
89
+ if bool(os.path.basename(dir_save)):
90
+ fpath = dir_save
91
+ else:
92
+ os.makedirs(dir_save, exist_ok=True)
93
+ fpath = os.path.join(dir_save, "log_ai.md")
94
+ await fupdate(fpath=fpath, content=res_)
95
+ print(f"log file: {fpath}")
96
+
97
+ return res
98
+
99
+ async def echo(*args, **kwargs):
100
+ while True:
101
+ try:
102
+ print("\nEnter your query (or 'quit' to stop): ")
103
+ query = input()
104
+ if query.lower() == 'quit':
105
+ break
106
+ response = await echo_einmal(query, *args, **kwargs)
107
+ except Exception as e:
108
+ print(f"Error: {e}")
109
+ break
110
+ await asyncio.sleep(0.5)
111
+ def chat(*args, **kwargs):
112
+ return echo_einmal(*args, **kwargs)
113
+
114
+ def ai(*args, **kwargs):
115
+ return echo_einmal(*args, **kwargs)
116
+
117
+ async def ai(*args, **kwargs):
118
+ return echo_einmal(*args, **kwargs)
119
+
120
+ async def main():
121
+ await echo(log=1)
122
+
123
+ if __name__ == "__main__":
124
+ asyncio.run(main())
py2ls/ips.py CHANGED
@@ -5,12 +5,12 @@ import json
5
5
  import matplotlib
6
6
  import matplotlib.pyplot as plt
7
7
  import matplotlib.ticker as tck
8
+ from cycler import cycler
8
9
  from mpl_toolkits.mplot3d import Axes3D
9
- # import seaborn as sns
10
+ import seaborn as sns
10
11
 
11
12
  import sys, os,shutil,re, yaml,json,subprocess
12
13
  import importlib.util
13
- from cycler import cycler
14
14
  import time
15
15
  from dateutil import parser
16
16
  from datetime import datetime
@@ -226,14 +226,10 @@ def echo(*args,**kwargs):
226
226
  return res
227
227
 
228
228
  def chat(*args, **kwargs):
229
- if len(args) == 1 and isinstance(args[0], str):
230
- kwargs['query'] = args[0]
231
- return echo(**kwargs)
229
+ return echo(*args, **kwargs)
232
230
 
233
231
  def ai(*args, **kwargs):
234
- if len(args) == 1 and isinstance(args[0], str):
235
- kwargs['query'] = args[0]
236
- return echo(**kwargs)
232
+ return echo(*args, **kwargs)
237
233
 
238
234
  def detect_lang(text, output='lang',verbose=True):
239
235
  dir_curr_script=os.path.dirname(os.path.abspath(__file__))
@@ -2052,7 +2048,9 @@ def figsets(*args):
2052
2048
  # tick location
2053
2049
  if "tic" in key.lower() or "tk" in key.lower():
2054
2050
  if ("loc" in key.lower()) or ("po" in key.lower()):
2055
- if isinstance(value, (str, list)):
2051
+ if isinstance(value,str):
2052
+ value=[value]
2053
+ if isinstance(value, list):
2056
2054
  loc = []
2057
2055
  for i in value:
2058
2056
  if ("l" in i.lower()) and ("a" not in i.lower()):
@@ -2072,16 +2070,22 @@ def figsets(*args):
2072
2070
  ax.yaxis.set_ticks_position("none")
2073
2071
  # ticks / labels
2074
2072
  elif "x" in key.lower():
2073
+ if value is None:
2074
+ value=[]
2075
2075
  if "la" not in key.lower():
2076
2076
  ax.set_xticks(value)
2077
2077
  if "la" in key.lower():
2078
2078
  ax.set_xticklabels(value)
2079
2079
  elif "y" in key.lower():
2080
+ if value is None:
2081
+ value=[]
2080
2082
  if "la" not in key.lower():
2081
2083
  ax.set_yticks(value)
2082
2084
  if "la" in key.lower():
2083
2085
  ax.set_yticklabels(value)
2084
2086
  elif "z" in key.lower():
2087
+ if value is None:
2088
+ value=[]
2085
2089
  if "la" not in key.lower():
2086
2090
  ax.set_zticks(value)
2087
2091
  if "la" in key.lower():
py2ls/plot.py CHANGED
@@ -1,8 +1,96 @@
1
1
  from scipy.signal import savgol_filter
2
2
  import numpy as np
3
+ import matplotlib
3
4
  import matplotlib.pyplot as plt
5
+ import matplotlib.ticker as tck
6
+ import seaborn as sns
7
+ from cycler import cycler
4
8
 
5
9
 
10
+ def read_mplstyle(style_file):
11
+ # Load the style file
12
+ plt.style.use(style_file)
13
+
14
+ # Get the current style properties
15
+ style_dict = plt.rcParams
16
+
17
+ # Convert to dictionary
18
+ style_dict = dict(style_dict)
19
+ # Print the style dictionary
20
+ for i, j in style_dict.items():
21
+ print(f"\n{i}::::{j}")
22
+ return style_dict
23
+ # #example usage:
24
+ # style_file = "/ std-colors.mplstyle"
25
+ # style_dict = read_mplstyle(style_file)
26
+
27
+
28
+ # set up the colorlist, give the number, or the colormap's name
29
+ def get_color(n=1, cmap="auto", how="start"):
30
+ # Extract the colormap as a list
31
+ def cmap2hex(cmap_name):
32
+ cmap_ = matplotlib.pyplot.get_cmap(cmap_name)
33
+ colors = [cmap_(i) for i in range(cmap_.N)]
34
+ return [matplotlib.colors.rgb2hex(color) for color in colors]
35
+ # usage: clist = cmap2hex("viridis")
36
+ # cycle times, total number is n (defaultn=10)
37
+ def cycle2list(colorlist, n=10):
38
+ cycler_ = cycler(tmp=colorlist)
39
+ clist = []
40
+ for i, c_ in zip(range(n), cycler_()):
41
+ clist.append(c_["tmp"])
42
+ if i > n:
43
+ break
44
+ return clist
45
+ def hue2rgb(hex_colors):
46
+ def hex_to_rgb(hex_color):
47
+ """Converts a hexadecimal color code to RGB values."""
48
+ if hex_colors.startswith("#"):
49
+ hex_color = hex_color.lstrip("#")
50
+ return tuple(int(hex_color[i : i + 2], 16) / 255.0 for i in (0, 2, 4))
51
+ if isinstance(hex_colors, str):
52
+ return hex_to_rgb(hex_colors)
53
+ elif isinstance(hex_colors, (list)):
54
+ """Converts a list of hexadecimal color codes to a list of RGB values."""
55
+ rgb_values = [hex_to_rgb(hex_color) for hex_color in hex_colors]
56
+ return rgb_values
57
+ if "aut" in cmap:
58
+ colorlist = [
59
+ "#474747",
60
+ "#FF2C00",
61
+ "#0C5DA5",
62
+ "#845B97",
63
+ "#58BBCC",
64
+ "#FF9500",
65
+ "#D57DBE",
66
+ ]
67
+ else:
68
+ colorlist = cmap2hex(cmap)
69
+ if "st" in how.lower() or "be" in how.lower():
70
+ # cycle it
71
+ clist = cycle2list(colorlist, n=n)
72
+ if "l" in how.lower() or "p" in how.lower():
73
+ clist = []
74
+ [
75
+ clist.append(colorlist[i])
76
+ for i in [int(i) for i in np.linspace(0, len(colorlist) - 1, n)]
77
+ ]
78
+
79
+ return clist # a color list
80
+ # example usage: clist = get_color(4,cmap="auto", how="start") # get_color(4, cmap="hot", how="linspace")
81
+
82
+ """
83
+ # n = 7
84
+ # clist = get_color(n, cmap="auto", how="linspace") # get_color(100)
85
+ # plt.figure(figsize=[8, 5], dpi=100)
86
+ # x = np.linspace(0, 2 * np.pi, 50) * 100
87
+ # y = np.sin(x)
88
+ # for i in range(1, n + 1):
89
+ # plt.plot(x, y + i, c=clist[i - 1], lw=5, label=str(i))
90
+ # plt.legend()
91
+ # plt.ylim(-2, 20)
92
+ # figsets(plt.gca(), {"style": "whitegrid"}) """
93
+
6
94
  def stdshade(ax=None,*args, **kwargs):
7
95
  # Separate kws_line and kws_fill if necessary
8
96
  kws_line = kwargs.pop('kws_line', {})
@@ -14,7 +102,7 @@ def stdshade(ax=None,*args, **kwargs):
14
102
  def str2list(str_):
15
103
  l = []
16
104
  [l.append(x) for x in str_]
17
- return l
105
+ return l
18
106
  def hue2rgb(hex_colors):
19
107
  def hex_to_rgb(hex_color):
20
108
  """Converts a hexadecimal color code to RGB values."""
@@ -225,3 +313,350 @@ plot.stdshade(data,
225
313
  plt.legend()
226
314
 
227
315
  """
316
+
317
+ def adjust_spines(ax=None, spines=['left', 'bottom'],distance=2):
318
+ if ax is None:
319
+ ax = plt.gca()
320
+ for loc, spine in ax.spines.items():
321
+ if loc in spines:
322
+ spine.set_position(('outward', distance)) # outward by 2 points
323
+ # spine.set_smart_bounds(True)
324
+ else:
325
+ spine.set_color('none') # don't draw spine
326
+ # turn off ticks where there is no spine
327
+ if 'left' in spines:
328
+ ax.yaxis.set_ticks_position('left')
329
+ else:
330
+ ax.yaxis.set_ticks([])
331
+ if 'bottom' in spines:
332
+ ax.xaxis.set_ticks_position('bottom')
333
+ else:
334
+ # no xaxis ticks
335
+ ax.xaxis.set_ticks([])
336
+ # And then plot the data:
337
+ def figsets(*args):
338
+ fig = plt.gcf()
339
+ fontsize = 11
340
+ fontname = "Arial"
341
+ sns_themes = ["white", "whitegrid", "dark", "darkgrid", "ticks"]
342
+ sns_contexts = ["notebook", "talk", "poster"] # now available "paper"
343
+ scienceplots_styles = ["science","nature",
344
+ "scatter","ieee","no-latex","std-colors","high-vis","bright","dark_background","science",
345
+ "high-vis","vibrant","muted","retro","grid","high-contrast","light","cjk-tc-font","cjk-kr-font",
346
+ ]
347
+ def sets_priority(ax,key, value):
348
+ if ("fo" in key) and (("size" in key) or ("sz" in key)):
349
+ fontsize=value
350
+ plt.rcParams.update({"font.size": value})
351
+ # style
352
+ if "st" in key.lower() or "th" in key.lower():
353
+ if isinstance(value, str):
354
+ if (value in plt.style.available) or (value in scienceplots_styles):
355
+ plt.style.use(value)
356
+ elif value in sns_themes:
357
+ sns.set_style(value)
358
+ elif value in sns_contexts:
359
+ sns.set_context(value)
360
+ else:
361
+ print(
362
+ f"\nWarning\n'{value}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
363
+ )
364
+ if isinstance(value, list):
365
+ for i in value:
366
+ if (i in plt.style.available) or (i in scienceplots_styles):
367
+ plt.style.use(i)
368
+ elif i in sns_themes:
369
+ sns.set_style(i)
370
+ elif i in sns_contexts:
371
+ sns.set_context(i)
372
+ else:
373
+ print(
374
+ f"\nWarning\n'{i}' is not a plt.style,select on below:\n{plt.style.available+sns_themes+sns_contexts+scienceplots_styles}"
375
+ )
376
+ if "la" in key.lower():
377
+ if "loc" in key.lower() or "po" in key.lower():
378
+ for i in value:
379
+ if "l" in i.lower():
380
+ ax.yaxis.set_label_position("left")
381
+ if "r" in i.lower():
382
+ ax.yaxis.set_label_position("right")
383
+ if "t" in i.lower():
384
+ ax.xaxis.set_label_position("top")
385
+ if "b" in i.lower():
386
+ ax.xaxis.set_label_position("bottom")
387
+ if ("x" in key.lower()) and (
388
+ "tic" not in key.lower() and "tk" not in key.lower()
389
+ ):
390
+ ax.set_xlabel(value, fontname=fontname)
391
+ if ("y" in key.lower()) and (
392
+ "tic" not in key.lower() and "tk" not in key.lower()
393
+ ):
394
+ ax.set_ylabel(value, fontname=fontname)
395
+ if ("z" in key.lower()) and (
396
+ "tic" not in key.lower() and "tk" not in key.lower()
397
+ ):
398
+ ax.set_zlabel(value, fontname=fontname)
399
+ # tick location
400
+ if "tic" in key.lower() or "tk" in key.lower():
401
+ if ("loc" in key.lower()) or ("po" in key.lower()):
402
+ if isinstance(value,str):
403
+ value=[value]
404
+ if isinstance(value, list):
405
+ loc = []
406
+ for i in value:
407
+ if ("l" in i.lower()) and ("a" not in i.lower()):
408
+ ax.yaxis.set_ticks_position("left")
409
+ if "r" in i.lower():
410
+ ax.yaxis.set_ticks_position("right")
411
+ if "t" in i.lower():
412
+ ax.xaxis.set_ticks_position("top")
413
+ if "b" in i.lower():
414
+ ax.xaxis.set_ticks_position("bottom")
415
+ if i.lower() in ["a", "both", "all", "al", ":"]:
416
+ ax.xaxis.set_ticks_position("both")
417
+ ax.yaxis.set_ticks_position("both")
418
+ if i.lower() in ["xnone",'xoff',"none"]:
419
+ ax.xaxis.set_ticks_position("none")
420
+ if i.lower() in ["ynone",'yoff','none']:
421
+ ax.yaxis.set_ticks_position("none")
422
+ # ticks / labels
423
+ elif "x" in key.lower():
424
+ if value is None:
425
+ value=[]
426
+ if "la" not in key.lower():
427
+ ax.set_xticks(value)
428
+ if "la" in key.lower():
429
+ ax.set_xticklabels(value)
430
+ elif "y" in key.lower():
431
+ if value is None:
432
+ value=[]
433
+ if "la" not in key.lower():
434
+ ax.set_yticks(value)
435
+ if "la" in key.lower():
436
+ ax.set_yticklabels(value)
437
+ elif "z" in key.lower():
438
+ if value is None:
439
+ value=[]
440
+ if "la" not in key.lower():
441
+ ax.set_zticks(value)
442
+ if "la" in key.lower():
443
+ ax.set_zticklabels(value)
444
+ # rotation
445
+ if "angle" in key.lower() or ("rot" in key.lower()):
446
+ if "x" in key.lower():
447
+ ax.tick_params(axis="x", rotation=value)
448
+ if "y" in key.lower():
449
+ ax.tick_params(axis="y", rotation=value)
450
+
451
+ if "bo" in key in key: # and ("p" in key or "l" in key):
452
+ # print("'ticks' style is recommended")
453
+ if isinstance(value, (str, list)):
454
+ locations = []
455
+ for i in value:
456
+ if "l" in i.lower():
457
+ locations.append("left")
458
+ if "r" in i.lower():
459
+ locations.append("right")
460
+ if "t" in i.lower():
461
+ locations.append("top")
462
+ if "b" in i.lower():
463
+ locations.append("bottom")
464
+ if i.lower() in ["a", "both", "all", "al", ":"]:
465
+ [
466
+ locations.append(x)
467
+ for x in ["left", "right", "top", "bottom"]
468
+ ]
469
+ for i in value:
470
+ if i.lower() in "none":
471
+ locations = []
472
+ # check spines
473
+ for loc, spi in ax.spines.items():
474
+ if loc in locations:
475
+ spi.set_position(("outward", 0))
476
+ else:
477
+ spi.set_color("none") # no spine
478
+ if key == "tick" or key == "ticks" or key == "ticks_para":
479
+ if isinstance(value, dict):
480
+ for k, val in value.items():
481
+ if "wh" in k.lower():
482
+ ax.tick_params(
483
+ which=val
484
+ ) # {'major', 'minor', 'both'}, default: 'major'
485
+ elif "dir" in k.lower():
486
+ ax.tick_params(direction=val) # {'in', 'out', 'inout'}
487
+ elif "len" in k.lower():
488
+ ax.tick_params(length=val)
489
+ elif ("wid" in k.lower()) or ("wd" in k.lower()):
490
+ ax.tick_params(width=val)
491
+ elif "ax" in k.lower():
492
+ ax.tick_params(axis=val) # {'x', 'y', 'both'}, default: 'both'
493
+ elif ("c" in k.lower()) and ("ect" not in k.lower()):
494
+ ax.tick_params(colors=val) # Tick color.
495
+ elif "pad" in k.lower():
496
+ ax.tick_params(
497
+ pad=val
498
+ ) # float, distance in points between tick and label
499
+ elif (
500
+ ("lab" in k.lower())
501
+ and ("s" in k.lower())
502
+ and ("z" in k.lower())
503
+ ):
504
+ ax.tick_params(
505
+ labelsize=val
506
+ ) # float, distance in points between tick and label
507
+
508
+ if "mi" in key.lower() and "tic" in key.lower():
509
+ if "x" in value.lower() or "x" in key.lower():
510
+ ax.xaxis.set_minor_locator(tck.AutoMinorLocator()) # ax.minorticks_on()
511
+ if "y" in value.lower() or "y" in key.lower():
512
+ ax.yaxis.set_minor_locator(
513
+ tck.AutoMinorLocator()
514
+ ) # ax.minorticks_off()
515
+ if value.lower() in ["both", ":", "all", "a", "b", "on"]:
516
+ ax.minorticks_on()
517
+ if key == "colormap" or key == "cmap":
518
+ plt.set_cmap(value)
519
+ def sets_small(ax,key, value):
520
+ if key == "figsize":
521
+ pass
522
+ if key == "xlim":
523
+ ax.set_xlim(value)
524
+ if key == "ylim":
525
+ ax.set_ylim(value)
526
+ if key == "zlim":
527
+ ax.set_zlim(value)
528
+ if "sc" in key.lower():
529
+ if "x" in key.lower():
530
+ ax.set_xscale(value)
531
+ if "y" in key.lower():
532
+ ax.set_yscale(value)
533
+ if "z" in key.lower():
534
+ ax.set_zscale(value)
535
+ if key == "grid":
536
+ if isinstance(value, dict):
537
+ for k, val in value.items():
538
+ if "wh" in k.lower():
539
+ ax.grid(
540
+ which=val
541
+ ) # {'major', 'minor', 'both'}, default: 'major'
542
+ elif "ax" in k.lower():
543
+ ax.grid(axis=val) # {'x', 'y', 'both'}, default: 'both'
544
+ elif ("c" in k.lower()) and ("ect" not in k.lower()):
545
+ ax.grid(color=val) # Tick color.
546
+ elif "l" in k.lower() and ("s" in k.lower()):
547
+ ax.grid(linestyle=val)
548
+ elif "l" in k.lower() and ("w" in k.lower()):
549
+ ax.grid(linewidth=val)
550
+ elif "al" in k.lower():
551
+ ax.grid(alpha=val)
552
+ else:
553
+ if value == "on" or value is True:
554
+ ax.grid(visible=True)
555
+ elif value == "off" or value is False:
556
+ ax.grid(visible=False)
557
+ if "tit" in key.lower():
558
+ if "sup" in key.lower():
559
+ plt.suptitle(value)
560
+ else:
561
+ ax.set_title(value)
562
+ if key.lower() in ["spine", "adjust", "ad", "sp", "spi", "adj","spines"]:
563
+ if isinstance(value, bool) or (value in ["go", "do", "ja", "yes"]):
564
+ if value:
565
+ adjust_spines(ax) # dafault distance=2
566
+ if isinstance(value, (float, int)):
567
+ adjust_spines(ax=ax, distance=value)
568
+ if "c" in key.lower() and ("sp" in key.lower() or "ax" in key.lower()):
569
+ for loc, spi in ax.spines.items():
570
+ spi.set_color(value)
571
+
572
+ for arg in args:
573
+ if isinstance(arg,matplotlib.axes._axes.Axes):
574
+ ax=arg
575
+ args=args[1:]
576
+ if 'ax' not in locals():
577
+ ax=plt.gca()
578
+
579
+ for arg in args:
580
+ if isinstance(arg, dict):
581
+ for k, val in arg.items():
582
+ sets_priority(ax,k, val)
583
+ for k, val in arg.items():
584
+ sets_small(ax,k, val)
585
+ else:
586
+ Nargin = len(args) // 2
587
+ ax.labelFontSizeMultiplier = 1
588
+ ax.titleFontSizeMultiplier = 1
589
+ ax.set_facecolor("w")
590
+
591
+ for ip in range(Nargin):
592
+ key = args[ip * 2].lower()
593
+ value = args[ip * 2 + 1]
594
+ sets_priority(ax,key, value)
595
+ for ip in range(Nargin):
596
+ key = args[ip * 2].lower()
597
+ value = args[ip * 2 + 1]
598
+ sets_small(ax,key, value)
599
+ colors = [
600
+ "#474747",
601
+ "#FF2C00",
602
+ "#0C5DA5",
603
+ "#845B97",
604
+ "#58BBCC",
605
+ "#FF9500",
606
+ "#D57DBE",
607
+ ]
608
+ matplotlib.rcParams["axes.prop_cycle"] = cycler(color=colors)
609
+ if len(fig.get_axes()) > 1:
610
+ plt.tight_layout()
611
+ plt.gcf().align_labels()
612
+
613
+
614
+ def figsave(*args,dpi=300):
615
+ dir_save = None
616
+ fname = None
617
+ for arg in args:
618
+ if isinstance(arg, str):
619
+ if '/' in arg or '\\' in arg:
620
+ dir_save = arg
621
+ elif '/' not in arg and '\\' not in arg:
622
+ fname = arg
623
+ # Backup original values
624
+ if '/' in dir_save:
625
+ if dir_save[-1] != '/':
626
+ dir_save = dir_save + '/'
627
+ elif '\\' in dir_save:
628
+ if dir_save[-1] != '\\':
629
+ dir_save = dir_save + '\\'
630
+ else:
631
+ raise ValueError('Check the Path of dir_save Directory')
632
+ ftype = fname.split('.')[-1]
633
+ if len(fname.split('.')) == 1:
634
+ ftype = 'nofmt'
635
+ fname = dir_save + fname + '.' + ftype
636
+ else:
637
+ fname = dir_save + fname
638
+ # Save figure based on file type
639
+ if ftype.lower() == 'eps':
640
+ plt.savefig(fname, format='eps', bbox_inches='tight')
641
+ plt.savefig(fname.replace('.eps', '.pdf'),
642
+ format='pdf', bbox_inches='tight',dpi=dpi)
643
+ elif ftype.lower() == 'nofmt': # default: both "tif" and "pdf"
644
+ fname_corr=fname.replace('nofmt','pdf')
645
+ plt.savefig(fname_corr, format='pdf', bbox_inches='tight',dpi=dpi)
646
+ fname=fname.replace('nofmt','tif')
647
+ plt.savefig(fname, format='tiff', dpi=dpi, bbox_inches='tight')
648
+ print(f"default saving filetype: both 'tif' and 'pdf")
649
+ elif ftype.lower() == 'pdf':
650
+ plt.savefig(fname, format='pdf', bbox_inches='tight',dpi=dpi)
651
+ elif ftype.lower() in ['jpg', 'jpeg']:
652
+ plt.savefig(fname, format='jpeg', dpi=dpi, bbox_inches='tight')
653
+ elif ftype.lower() == 'png':
654
+ plt.savefig(fname, format='png', dpi=dpi,
655
+ bbox_inches='tight', transparent=True)
656
+ elif ftype.lower() in ['tiff', 'tif']:
657
+ plt.savefig(fname, format='tiff', dpi=dpi, bbox_inches='tight')
658
+ elif ftype.lower() == 'emf':
659
+ plt.savefig(fname, format='emf', dpi=dpi, bbox_inches='tight')
660
+ elif ftype.lower() == 'fig':
661
+ plt.savefig(fname, format='pdf', bbox_inches='tight',dpi=dpi)
662
+ print(f'\nSaved @: dpi={dpi}\n{fname}')
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: py2ls
3
- Version: 0.1.5.7
3
+ Version: 0.1.5.9
4
4
  Summary: py(thon)2(too)ls
5
5
  Author: Jianfeng
6
6
  Author-email: Jianfeng.Liu0413@gmail.com
@@ -21,7 +21,7 @@ py2ls/.git/index,sha256=ypuqDA3K3KBipX7FdqdgRQozfYsKAFZ-NV09-uWkL-E,1791
21
21
  py2ls/.git/info/exclude,sha256=ZnH-g7egfIky7okWTR8nk7IxgFjri5jcXAbuClo7DsE,240
22
22
  py2ls/.git/logs/HEAD,sha256=n-qGQXJL1v859RevL9KKxp-QckcdkwtFE_0V2hJKyeY,3071
23
23
  py2ls/.git/logs/refs/heads/main,sha256=n-qGQXJL1v859RevL9KKxp-QckcdkwtFE_0V2hJKyeY,3071
24
- py2ls/.git/logs/refs/remotes/origin/HEAD,sha256=EBINh4QbBbWNrNhfKy8uklH_3OvnVcsXE7T9-FFHMZc,8133
24
+ py2ls/.git/logs/refs/remotes/origin/HEAD,sha256=K0KrDkFF0rwNJgwjuO3YFyJGUPBMCRer6KI1-5WksdY,9915
25
25
  py2ls/.git/logs/refs/remotes/origin/main,sha256=E4VJChrdCLBY0vhc8_zfVvT_BBBaJAnq524hLd6MiCU,2736
26
26
  py2ls/.git/objects/01/d5bd8065e6860c0bd23ff9fa57161806a099e1,sha256=hEQ8nqJnGsfFsuV5wc4cZas58rehXvT0v5ANx1zmMAY,584
27
27
  py2ls/.git/objects/09/08da26de58c114225ad81f484b80bf5d351b34,sha256=NOyYvrJxATpK3aDdP1_stwkqOQRDwJn7DSy6isyKImE,925
@@ -119,20 +119,21 @@ py2ls/LICENSE,sha256=UOZ1F5fFDe3XXvG4oNnkL1-Ecun7zpHzRxjp-XsMeAo,11324
119
119
  py2ls/README.md,sha256=CwvJWAnSXnCnrVHlnEbrxxi6MbjbE_MT6DH2D53S818,11572
120
120
  py2ls/__init__.py,sha256=R5OBEeK0uOULvUsY1YjIj-EAQKlVPW32uh_hQHuN5Bg,109
121
121
  py2ls/brain_atlas.py,sha256=w1o5EelRjq89zuFJUNSz4Da8HnTCwAwDAZ4NU4a-bAY,5486
122
+ py2ls/chat.py,sha256=3OUKKju03Flbjmotiq6u62JAEky2SeZzIuRG3-Tc7Pw,3793
122
123
  py2ls/correlators.py,sha256=RbOaJIPLCHJtUm5SFi_4dCJ7VFUPWR0PErfK3K26ad4,18243
123
124
  py2ls/data/.DS_Store,sha256=1lFlJ5EFymdzGAUAaI30vcaaLHt3F1LwpG7xILf9jsM,6148
124
125
  py2ls/data/db2ls_sql_chtsht.json,sha256=ls9d7Sm8TLeujanWHfHlWhU85Qz1KnAizO_9X3wUH7E,6933
125
126
  py2ls/data/lang_code_iso639.json,sha256=qZiU7H2RLJjDMXK22C-jhwzLJCI5vKmampjB1ys4ek4,2157
126
127
  py2ls/db2ls.py,sha256=MMfFX47aIPIyu7fU9aPvX9lbPRPYOpJ_VXwlnWk-8qo,13615
127
128
  py2ls/freqanalysis.py,sha256=F4218VSPbgL5tnngh6xNCYuNnfR-F_QjECUUxrPYZss,32594
128
- py2ls/ips.py,sha256=xyWKqnLN2PFgAFupzzTykbU-EF2tp3rRCj6j8xpCDOM,96822
129
+ py2ls/ips.py,sha256=rYbL-ds0rNDffYq2bXU-ctTrFZIAg8wDMPfyvkJ7ZSE,96920
129
130
  py2ls/netfinder.py,sha256=ZsLWGYMeRuGvxj2nqE0Z8ANoaVl18Necfw0HQfh2q7I,45548
130
- py2ls/plot.py,sha256=EbRx_6RuYT1EqDoi_01E6UbO6YPMXQJy83SuKqiOgto,7696
131
+ py2ls/plot.py,sha256=Prqd8vIc27QMW4l0aq23wG_XAlV7ZKhuNuhakUVIpDs,25526
131
132
  py2ls/setuptools-70.1.0-py3-none-any.whl,sha256=2bi3cUVal8ip86s0SOvgspteEF8SKLukECi-EWmFomc,882588
132
133
  py2ls/sleep_events_detectors.py,sha256=36MCuRrpurn0Uvzpo3p3b3_JlVsRNHSWCXbJxCGM3mg,51546
133
134
  py2ls/stats.py,sha256=Wd9yCKQ_61QD29WMEgMuEcreFxF91NmlPW65iWT2B5w,39041
134
135
  py2ls/translator.py,sha256=6S7MmTZmjj8NljVmj0W5uEauu4ePxso3AMf2LvGVRQA,30516
135
136
  py2ls/wb_detector.py,sha256=7y6TmBUj9exCZeIgBAJ_9hwuhkDh1x_-yg4dvNY1_GQ,6284
136
- py2ls-0.1.5.7.dist-info/METADATA,sha256=vUwZ_D3iMt___SHaEdzoR1q0l0h0_qknuh-IFAiHoUQ,17943
137
- py2ls-0.1.5.7.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
138
- py2ls-0.1.5.7.dist-info/RECORD,,
137
+ py2ls-0.1.5.9.dist-info/METADATA,sha256=csvd_uWYyRoqehIr3NVEwNA9hbtJ1rYlANRfLV7kt2I,17943
138
+ py2ls-0.1.5.9.dist-info/WHEEL,sha256=FMvqSimYX_P7y0a7UY-_Mc83r5zkBZsCYPm7Lr0Bsq4,88
139
+ py2ls-0.1.5.9.dist-info/RECORD,,