onekit 2.2.0__tar.gz → 2.2.1__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
1
  Metadata-Version: 2.3
2
2
  Name: onekit
3
- Version: 2.2.0
3
+ Version: 2.2.1
4
4
  Summary: All-in-One Python Kit.
5
5
  License: BSD 3-Clause
6
6
  Keywords: onekit
@@ -22,7 +22,7 @@ requires-python = ">=3.11"
22
22
  dependencies = []
23
23
 
24
24
  [tool.poetry]
25
- version = "2.2.0"
25
+ version = "2.2.1"
26
26
 
27
27
  [project.optional-dependencies]
28
28
  base = [
@@ -15,6 +15,8 @@ from mpl_toolkits.mplot3d.axes3d import Axes3D
15
15
  from onekit import numpykit as npk
16
16
  from onekit import pythonkit as pk
17
17
 
18
+ ArrayLike = npt.ArrayLike
19
+
18
20
  __all__ = (
19
21
  "Config",
20
22
  "FunctionPlotter",
@@ -484,14 +486,13 @@ def plot_contour(
484
486
 
485
487
 
486
488
  def plot_digitscale(
487
- x,
488
- /,
489
- *,
489
+ x: ArrayLike,
490
+ y: ArrayLike | None = None,
490
491
  cmap_name: str = "YlOrBr_r",
491
492
  kws_plot: dict[str, str] | None = None,
492
493
  ax=None,
493
494
  ) -> Axes:
494
- """Plot a scaled version of :math:`x` using digitscale.
495
+ """Plot a digit-scaled version of :math:`y` against :math:`x`.
495
496
 
496
497
  See Also
497
498
  --------
@@ -507,34 +508,40 @@ def plot_digitscale(
507
508
 
508
509
  kwargs_plot = dict(marker=".", color="black")
509
510
  kwargs_plot.update(kws_plot or dict())
511
+ for k in ["x", "y"]:
512
+ kwargs_plot.pop(k, None)
513
+
514
+ if y is None:
515
+ y = x
516
+ x = np.arange(len(y))
510
517
 
511
- x_values = np.asarray(x)
512
- x_scaled = npk.digitscale(x_values)
513
- ax.plot(x_scaled, **kwargs_plot)
518
+ y_values = np.asarray(y)
519
+ y_scaled = npk.digitscale(y_values)
520
+ ax.plot(x, y_scaled, **kwargs_plot)
514
521
  x_limits = ax.get_xlim()
515
522
 
516
- y_min = int(np.floor(x_scaled.min()))
517
- y_max = int(np.ceil(x_scaled.max()))
523
+ y_min = int(np.floor(y_scaled.min()))
524
+ y_max = int(np.ceil(y_scaled.max()))
518
525
  y_range = tuple(range(y_min, y_max))
519
526
  colors = discrete_cmap(y_max, name=cmap_name, lower_bound=0.2, upper_bound=0.8)
520
527
 
521
- for i, y in enumerate(y_range):
522
- ax.fill_between(x_limits, y, y + 1, color=colors[i], alpha=0.3)
528
+ for i, yi in enumerate(y_range):
529
+ ax.fill_between(x_limits, yi, yi + 1, color=colors[i], alpha=0.3)
523
530
 
524
531
  ax.set_xlim(x_limits)
525
532
  ax.set_yticks(y_range)
526
533
 
527
534
  ax.set_xlabel("index")
528
- ax.set_ylabel("num_digits(orig_value)")
535
+ ax.set_ylabel("num_digits(orig_value)", labelpad=6)
529
536
 
530
537
  ax.set_title(
531
538
  pk.concat_strings(
532
539
  ", ",
533
- f"mean={pk.num_to_str(x_values.mean())}",
534
- f"median={pk.num_to_str(float(np.median(x_values)))}",
535
- f"std={pk.num_to_str(x_values.std(ddof=1))}",
536
- f"min={pk.num_to_str(x_values.min())}",
537
- f"max={pk.num_to_str(x_values.max())}",
540
+ f"mean={pk.num_to_str(y_values.mean())}",
541
+ f"median={pk.num_to_str(float(np.median(y_values)))}",
542
+ f"std={pk.num_to_str(y_values.std(ddof=1))}",
543
+ f"min={pk.num_to_str(y_values.min())}",
544
+ f"max={pk.num_to_str(y_values.max())}",
538
545
  ),
539
546
  size="medium",
540
547
  pad=12,
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes