Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Added __repr__ implementation on all locators and formators#25767

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Open
Daniil-Aleshechkin wants to merge33 commits intomatplotlib:main
base:main
Choose a base branch
Loading
fromDaniil-Aleshechkin:added-repr-implementation-on-all-locators-and-formators
Open
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
33 commits
Select commitHold shift + click to select a range
7321b87
Added __repr__ implementation on all locators and formators
Daniil-AleshechkinApr 26, 2023
0605320
Fixed flake8 issues
Daniil-AleshechkinApr 26, 2023
fc305e4
Whitespace
Daniil-AleshechkinApr 26, 2023
afbf1ec
Make some methods that don't need to be public private
Daniil-AleshechkinApr 26, 2023
b6781c7
Added functools.wraps decorator
Daniil-AleshechkinApr 26, 2023
d3aef45
Removed added __init__ method on runtime
Daniil-AleshechkinApr 26, 2023
e6cc3b1
Added a seperate default init implemetation that should match the sig…
Daniil-AleshechkinApr 26, 2023
a0754b7
Fixed wrong function call
Daniil-AleshechkinApr 26, 2023
0845b90
Removed git artifact
Daniil-AleshechkinApr 26, 2023
8db91fc
Added missing if check and fixed flake issues
Daniil-AleshechkinApr 26, 2023
03006f7
Fixed bad undo
Daniil-AleshechkinApr 26, 2023
e51f4e8
Added extra check to ensure we're not wrapping inherited wrapped func…
Daniil-AleshechkinApr 26, 2023
95ab01f
Updated check to check a marker to account for the default case
Daniil-AleshechkinApr 26, 2023
5de2d24
Made the check for the marker safer
Daniil-AleshechkinApr 26, 2023
26de7ab
Updated my solution to avoid double wrapping functions
Daniil-AleshechkinApr 26, 2023
68252ae
Removed overriden default init for the wrapper
Daniil-AleshechkinApr 27, 2023
23d9ba9
Removed general repr and manually created reprs
Daniil-Aleshechkin-IQMay 8, 2023
06a7da4
Whitespace
Daniil-Aleshechkin-IQMay 8, 2023
6298a59
Removed depricated attribute
Daniil-Aleshechkin-IQMay 8, 2023
ff128da
Added unit tests
Daniil-Aleshechkin-IQMay 8, 2023
6d3c802
Fixed flake8 issues
Daniil-Aleshechkin-IQMay 8, 2023
3b96310
Whitespace
Daniil-Aleshechkin-IQMay 8, 2023
1b520ae
Fixed tests
Daniil-Aleshechkin-IQMay 8, 2023
16d693d
Fixed typo
Daniil-Aleshechkin-IQMay 8, 2023
32b3266
Updated assertions
Daniil-Aleshechkin-IQMay 8, 2023
5e614b1
Fix unit test class name
Daniil-Aleshechkin-IQMay 9, 2023
471b852
Fixed tests
Daniil-Aleshechkin-IQMay 9, 2023
8bb64ac
Added import from numpy
Daniil-Aleshechkin-IQMay 9, 2023
98d59e9
Properly imported numpy.array for eval
Daniil-Aleshechkin-IQMay 9, 2023
3e874f7
added references to sut classes
Daniil-Aleshechkin-IQMay 9, 2023
bbef256
Removed unused import
Daniil-Aleshechkin-IQMay 9, 2023
075e9c7
Formattin
Daniil-Aleshechkin-IQMay 9, 2023
94daa84
Fixed array assertion
Daniil-Aleshechkin-IQMay 9, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletionslib/matplotlib/projections/polar.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -287,6 +287,9 @@ class ThetaLocator(mticker.Locator):
locations of every 45 degrees are returned.
"""

def __repr__(self):
return f"{self.__class__.__name__}(base={self.base.__repr__()})"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

These__repr__ should all be:

Suggested change
returnf"{self.__class__.__name__}(base={self.base.__repr__()})"
returnf"{self.__class__.__name__}(base={self.base!r})"


def __init__(self, base):
self.base = base
self.axis = self.base.axis = _AxisWrapper(self.base.axis)
Expand DownExpand Up@@ -455,6 +458,11 @@ class RadialLocator(mticker.Locator):
scale of the *r*-axis).
"""

def __repr__(self):
return f"{self.__class__.__name__}(" + \
f"base={self.base.__repr__()}, " + \
f"axes={self._axes.__repr__()})"

def __init__(self, base, axes=None):
self.base = base
self._axes = axes
Expand Down
133 changes: 133 additions & 0 deletionslib/matplotlib/tests/test_ticker.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1633,3 +1633,136 @@ def test_set_offset_string(formatter):
assert formatter.get_offset() == ''
formatter.set_offset_string('mpl')
assert formatter.get_offset() == 'mpl'


class TestReprImplementation:
def test_LogLocator(self):
sut = mticker.LogLocator(base=10, numticks=15)

result = sut.__repr__()

assert result.startswith("LogLocator(")
assert "base=10" in result
assert "numticks=15" in result
assert result.endswith(")")

def test_NullLocator(self):
sut = mticker.NullFormatter()

assert sut.__repr__() == "NullFormatter()"

def test_MultipleLocator(self):
sut = mticker.MultipleLocator(0.5)

assert sut.__repr__() == "MultipleLocator(base=0.5)"

def test_FixedLocator(self):
sut = mticker.FixedLocator([0, 1, 5])
result = sut.__repr__()

assert result.startswith("FixedLocator(")
assert "locs=array([0, 1, 5])" in result
assert "nbins=None" in result
assert result.endswith(")")

def test_LinearLocator(self):
sut = mticker.LinearLocator(numticks=3)

result = sut.__repr__()

assert result.startswith("LinearLocator(")
assert "numticks=3" in result
assert r"presets={}" in result
assert result.endswith(")")

def test_IndexLocator(self):
sut = mticker.IndexLocator(base=0.5, offset=0.25)

result = sut.__repr__()

assert result.startswith("IndexLocator(")
assert "base=0.5" in result
assert "offset=0.25" in result
assert result.endswith(")")

def test_AutoLocator(self):
sut = mticker.AutoLocator()

assert sut.__repr__() == "AutoLocator()"

def test_MaxNLocator(self):
sut = mticker.MaxNLocator(nbins=4)

result = sut.__repr__()
assert result.startswith("MaxNLocator(")
assert "nbins=4" in result
assert result.endswith(")")


class TestEvalReprImplementation:
def test_LogLocator(self):
sut = mticker.LogLocator(base=10, numticks=15)

result = eval(sut.__repr__(), {"array": np.array,
"LogLocator": mticker.LogLocator})

assert result.__class__ == sut.__class__
assert result._base == sut._base
assert result._subs == sut._subs

def test_NullLocator(self):
sut = mticker.NullFormatter()

result = eval(sut.__repr__(), {"NullFormatter": mticker.NullFormatter})

assert result.__class__ == sut.__class__

def test_MultipleLocator(self):
sut = mticker.MultipleLocator(0.5)

result = eval(sut.__repr__(), {"MultipleLocator": mticker.MultipleLocator})

assert result.__class__ == sut.__class__
assert result._edge.step == sut._edge.step

def test_FixedLocator(self):
sut = mticker.FixedLocator([0, 1, 5])

result = eval(sut.__repr__(), {"array": np.array,
"FixedLocator": mticker.FixedLocator})

assert result.__class__ == sut.__class__
assert np.array_equal(sut.locs, result.locs)

def test_LinearLocator(self):
sut = mticker.LinearLocator(numticks=3)

result = eval(sut.__repr__(), {"LinearLocator": mticker.LinearLocator})

assert result.__class__ == sut.__class__
assert result.numticks == sut.numticks

def test_IndexLocator(self):
sut = mticker.IndexLocator(base=0.5, offset=0.25)

result = eval(sut.__repr__(), {"IndexLocator": mticker.IndexLocator})

assert result.__class__ == sut.__class__
assert result._base == sut._base
assert result.offset == sut.offset

def test_AutoLocator(self):
sut = mticker.AutoLocator()

result = eval(sut.__repr__(), {"AutoLocator": mticker.AutoLocator})

assert result.__class__ == sut.__class__

def test_MaxNLocator(self):
sut = mticker.MaxNLocator(nbins=4)

result = eval(sut.__repr__(), {"array": np.array,
"MaxNLocator": mticker.MaxNLocator})

assert result.__class__ == sut.__class__
assert result._nbins == sut._nbins
Loading

[8]ページ先頭

©2009-2025 Movatter.jp