Skip to content

Commit 6fc54bd

Browse files
committed
Replace "infos" with "info" across the codebase for proper English usage
1 parent 290000b commit 6fc54bd

File tree

13 files changed

+487
-56
lines changed

13 files changed

+487
-56
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ Other dependencies have been updated:
8282
* Added `info_callback` argument to all annotation class constructors
8383
* Added `set_info_callback` method to all annotation classes
8484
* The `info_callback` is a function that takes the annotation object and returns a string with the information to display
85-
* Default `info_callback` is redirected to the `get_infos` method of the annotation object (this makes the feature backward compatible)
85+
* Default `info_callback` is redirected to the `get_info` method of the annotation object (this makes the feature backward compatible)
8686

8787
🛠️ Bug fixes:
8888

plotpy/io.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -435,11 +435,11 @@ def _imwrite_dcm(filename, arr, template=None):
435435
"The `template` keyword argument is required to save DICOM files\n"
436436
"(that is the template DICOM structure object)"
437437
)
438-
infos = np.iinfo(arr.dtype)
439-
template.BitsAllocated = infos.bits
440-
template.BitsStored = infos.bits
441-
template.HighBit = infos.bits - 1
442-
template.PixelRepresentation = ("u", "i").index(infos.kind)
438+
info = np.iinfo(arr.dtype)
439+
template.BitsAllocated = info.bits
440+
template.BitsStored = info.bits
441+
template.HighBit = info.bits - 1
442+
template.PixelRepresentation = ("u", "i").index(info.kind)
443443
data_vr = ("US", "SS")[template.PixelRepresentation]
444444
template.Rows = arr.shape[0]
445445
template.Columns = arr.shape[1]

plotpy/items/annotation.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __init__(
7474

7575
def info_callback(annotation: AnnotatedShape) -> str:
7676
"""Return information on annotation"""
77-
return annotation.get_infos()
77+
return annotation.get_info()
7878

7979
self.info_callback = info_callback
8080
self.shape: AbstractShape = self.create_shape()
@@ -231,11 +231,11 @@ def get_text(self) -> str:
231231
text += "<br>"
232232
text += f"<i>{subtitle}</i>"
233233
if self.area_computations_visible:
234-
infos = self.info_callback(self)
235-
if infos:
234+
info = self.info_callback(self)
235+
if info:
236236
if text:
237237
text += "<br>"
238-
text += infos
238+
text += info
239239
return text
240240

241241
def x_to_str(self, x: float) -> str:
@@ -304,7 +304,7 @@ def get_tr_size_str(self):
304304
xs, ys = self.get_tr_size()
305305
return f"{self.x_to_str(xs)} x {self.y_to_str(ys)}"
306306

307-
def get_infos(self) -> str:
307+
def get_info(self) -> str:
308308
"""Get informations on current shape
309309
310310
Returns:
@@ -525,7 +525,7 @@ def get_tr_position(self):
525525
xt, yt = self.apply_transform_matrix(*self.shape.points[0])
526526
return xt, yt
527527

528-
def get_infos(self) -> str:
528+
def get_info(self) -> str:
529529
"""Get informations on current shape
530530
531531
Returns:
@@ -593,7 +593,7 @@ def set_label_position(self):
593593
self.label.set_pos(*compute_center(x1, y1, x2, y2))
594594

595595
# ----AnnotatedShape API-----------------------------------------------------
596-
def get_infos(self) -> str:
596+
def get_info(self) -> str:
597597
"""Get informations on current shape
598598
599599
Returns:
@@ -754,7 +754,7 @@ def get_tr_center(self) -> tuple[float, float]:
754754
"""Return shape center coordinates after applying transform matrix"""
755755
return self.shape.get_center()
756756

757-
def get_infos(self) -> str:
757+
def get_info(self) -> str:
758758
"""Get informations on current shape
759759
760760
Returns:
@@ -820,7 +820,7 @@ def get_tr_size(self):
820820
"""Return shape size after applying transform matrix"""
821821
return compute_rect_size(*self.get_transformed_coords(0, 2))
822822

823-
def get_infos(self) -> str:
823+
def get_info(self) -> str:
824824
"""Get informations on current shape
825825
826826
Returns:
@@ -912,7 +912,7 @@ def get_tr_size(self):
912912
return dx, dy
913913

914914
# ----AnnotatedShape API-----------------------------------------------------
915-
def get_infos(self) -> str:
915+
def get_info(self) -> str:
916916
"""Get informations on current shape
917917
918918
Returns:
@@ -1033,7 +1033,7 @@ def get_tr_size(self):
10331033
dx, dy = dy, dx
10341034
return dx, dy
10351035

1036-
def get_infos(self) -> str:
1036+
def get_info(self) -> str:
10371037
"""Get informations on current shape
10381038
10391039
Returns:
@@ -1064,7 +1064,7 @@ def get_tr_diameter(self):
10641064
return compute_distance(*self.get_transformed_coords(0, 1))
10651065

10661066
# ----AnnotatedShape API-------------------------------------------------
1067-
def get_infos(self) -> str:
1067+
def get_info(self) -> str:
10681068
"""Get informations on current shape
10691069
10701070
Returns:

plotpy/items/label.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1078,22 +1078,22 @@ class DataInfoLabel(LabelItem):
10781078
10791079
Args:
10801080
labelparam: Label parameters
1081-
infos: List of objects implementing the ``get_text`` method
1081+
info: List of objects implementing the ``get_text`` method
10821082
"""
10831083

10841084
__implements__ = (IBasePlotItem,)
10851085

10861086
def __init__(
1087-
self, labelparam: LabelParam | None = None, infos: list[Any] | None = None
1087+
self, labelparam: LabelParam | None = None, info: list[Any] | None = None
10881088
) -> None:
10891089
super().__init__(None, labelparam)
1090-
if isinstance(infos, ObjectInfo):
1091-
infos = [infos]
1092-
self.infos = infos
1090+
if isinstance(info, ObjectInfo):
1091+
info = [info]
1092+
self.info = info
10931093

10941094
def __reduce__(self) -> tuple[type, tuple]:
10951095
"""Return a tuple containing the constructor and its arguments"""
1096-
return (self.__class__, (self.labelparam, self.infos))
1096+
return (self.__class__, (self.labelparam, self.info))
10971097

10981098
def types(self) -> tuple[type[IItemType], ...]:
10991099
"""Returns a group or category for this item.
@@ -1111,6 +1111,6 @@ def update_text(self):
11111111
text = ["<b>%s</b>" % title]
11121112
else:
11131113
text = []
1114-
for info in self.infos:
1114+
for info in self.info:
11151115
text.append(info.get_text())
11161116
self.set_text("<br/>".join(text))

plotpy/tests/benchmarks/test_benchmarks.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class BaseBM:
5151
@classmethod
5252
def print_header(cls):
5353
"""Print header for benchmark results"""
54-
execenv.print(f"PlotPy plot benchmark [{about.get_python_libs_infos()}]")
54+
execenv.print(f"PlotPy plot benchmark [{about.get_python_libs_info()}]")
5555
execenv.print()
5656
table_header = (
5757
"N".rjust(10) + " | " + "∆t (ms)".rjust(7) + " | " + "Description"

plotpy/tests/features/test_computations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def test_computations():
2323
curve = make.curve(x, y, "ab", "b")
2424
range = make.xrange(-2, 2)
2525
disp0 = make.range_info_label(
26-
range, "BR", "x = %.1f ± %.1f cm", title="Range infos"
26+
range, "BR", "x = %.1f ± %.1f cm", title="Range info"
2727
)
2828

2929
disp1 = make.computation(
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Licensed under the terms of the BSD 3-Clause
4+
# (see plotpy/LICENSE for details)
5+
6+
"""Logarithmic scale test for image plotting"""
7+
8+
# guitest: show
9+
10+
import numpy as np
11+
from guidata.qthelpers import qt_app_context
12+
13+
from plotpy.builder import make
14+
from plotpy.tests import vistools as ptv
15+
16+
LOG_MIN, LOG_MAX = 1, 10**8
17+
WAVELENGTHS = (371, 382, 393, 404, 415)
18+
19+
20+
def create_data() -> np.ndarray:
21+
"""Create a sample data set, representing a spectrum"""
22+
num_bins = 1024
23+
log_bins = np.logspace(np.log10(LOG_MIN), np.log10(LOG_MAX), num_bins)
24+
sample_data = np.zeros((num_bins - 1, len(WAVELENGTHS)))
25+
for i_lambda in range(len(WAVELENGTHS)):
26+
num_samples = 100000
27+
mean1, std1 = 10 ** (2 + i_lambda * 0.7), 10 ** (2 + i_lambda * 0.7) * 0.3
28+
mean2, std2 = 10 ** (4 + i_lambda * 0.5), 10 ** (4 + i_lambda * 0.5) * 0.2
29+
raw_data = np.abs(
30+
np.concatenate(
31+
[
32+
np.random.normal(mean1, std1, num_samples // 2),
33+
np.random.normal(mean2, std2, num_samples // 2),
34+
]
35+
)
36+
)
37+
hist_values, _ = np.histogram(raw_data, bins=log_bins)
38+
sample_data[:, i_lambda] = hist_values
39+
return sample_data
40+
41+
42+
def test_image_log() -> None:
43+
"""Image with logarithmic scale"""
44+
with qt_app_context(exec_loop=True):
45+
data = create_data()
46+
xdata = min(WAVELENGTHS), max(WAVELENGTHS)
47+
ydata = LOG_MIN, LOG_MAX
48+
x = np.linspace(xdata[0], xdata[1], data.shape[1] + 1)
49+
y = np.linspace(ydata[0], ydata[1], data.shape[0] + 1)
50+
y = np.log10(np.clip(y, LOG_MIN, LOG_MAX))
51+
items = [make.xyimage(x, y, data, interpolation="nearest")]
52+
_win = ptv.show_items(
53+
items,
54+
plot_type="curve",
55+
wintitle=test_image_log.__doc__,
56+
xlabel="Wavelength",
57+
ylabel="log10(Intensity)",
58+
)
59+
60+
61+
if __name__ == "__main__":
62+
test_image_log()

0 commit comments

Comments
 (0)