Skip to content

Commit f627d28

Browse files
committed
Rename id to pattern
1 parent 8e560c3 commit f627d28

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

pygmt/params/pattern.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ class Pattern(BaseParam):
3333
3434
Parameters
3535
----------
36-
id
37-
The pattern ID. It can be specified in two forms:
36+
pattern
37+
The pattern to use. It can be specified in two forms:
3838
3939
- An integer in the range of 1-90, corresponding to one of 90 predefined 64x64
4040
bit-patterns
@@ -69,7 +69,7 @@ class Pattern(BaseParam):
6969
>>> fig.show()
7070
"""
7171

72-
id: int | PathLike
72+
pattern: int | PathLike
7373
dpi: int | None = None
7474
bgcolor: str | None = None
7575
fgcolor: str | None = None
@@ -79,13 +79,13 @@ def _validate(self):
7979
"""
8080
Validate the parameters.
8181
"""
82-
# Integer pattern id must be in the range 1-90.
83-
if isinstance(self.id, int) and not (1 <= self.id <= 90):
82+
# Integer pattern number must be in the range 1-90.
83+
if isinstance(self.pattern, int) and not (1 <= self.pattern <= 90):
8484
raise GMTValueError(
85-
self.id,
86-
description="pattern id",
85+
self.pattern,
86+
description="pattern number",
8787
reason=(
88-
"Pattern id must be an integer in the range 1-90 "
88+
"Parameter 'pattern' must be an integer in the range 1-90 "
8989
"or the name of a 1-, 8-, or 24-bit image raster file."
9090
),
9191
)
@@ -104,7 +104,7 @@ def _aliases(self):
104104
Aliases for the Pattern class.
105105
"""
106106
return [
107-
Alias(self.id, name="id", prefix="P" if self.reversed else "p"),
107+
Alias(self.pattern, name="pattern", prefix="P" if self.reversed else "p"),
108108
Alias(self.bgcolor, name="bgcolor", prefix="+b"),
109109
Alias(self.fgcolor, name="fgcolor", prefix="+f"),
110110
Alias(self.dpi, name="dpi", prefix="+r"),

pygmt/tests/test_params_pattern.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def test_pattern():
1212
Test the Pattern class.
1313
"""
1414
assert str(Pattern(1)) == "p1"
15-
assert str(Pattern(id=1)) == "p1"
15+
assert str(Pattern(pattern=1)) == "p1"
1616

1717
assert str(Pattern("pattern.png")) == "ppattern.png"
1818

@@ -33,15 +33,14 @@ def test_pattern():
3333
assert str(pattern) == "ppattern.png+bred+fblue+r300"
3434

3535

36-
def test_pattern_invalid_id():
36+
def test_pattern_invalid_pattern():
3737
"""
38-
Test that an invalid pattern id raises a GMTValueError.
38+
Test that an invalid pattern number raises a GMTValueError.
3939
"""
40-
with pytest.raises(GMTValueError):
41-
_ = str(Pattern(91))
4240
with pytest.raises(GMTValueError):
4341
_ = str(Pattern(0))
44-
42+
with pytest.raises(GMTValueError):
43+
_ = str(Pattern(91))
4544

4645
def test_pattern_invalid_colors():
4746
"""

0 commit comments

Comments
 (0)