Skip to content

Commit dacf698

Browse files
committed
Remove broken metaclass stuff
1 parent ac94063 commit dacf698

File tree

1 file changed

+0
-61
lines changed

1 file changed

+0
-61
lines changed

proplot/artist.py

-61
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
Create a metaclass
44
"""
55
import matplotlib.artist as martist
6-
import matplotlib.lines as mlines
76

87
__all__ = []
98

@@ -46,67 +45,7 @@ def _gen_properties(cls):
4645
yield name, property(*args, doc=getter.__doc__)
4746

4847

49-
# Approach #1: Apply properties to all artists
5048
for cls in _gen_subclasses(martist.Artist):
5149
for name, prop in _gen_properties(cls):
5250
setattr(cls, name, prop)
5351
print(f'Added properties to {cls.__name__}.')
54-
55-
56-
# Approach #2: Requires importing proplot before matplotlib.
57-
# This will not work for ProPlot but may be in matplotlib's future.
58-
class Propertifier(type): # create new class definitions
59-
"""
60-
Artist metaclass.
61-
"""
62-
def __init__(cls, *args, **kwargs):
63-
"""
64-
Add property getters and setters to all matplotlib artist subclasses.
65-
"""
66-
super().__init__(*args, **kwargs)
67-
for name, property in _gen_properties(cls):
68-
setattr(cls, name, property)
69-
print(f'Added properties to {cls.__name__}.')
70-
71-
72-
class Artist(martist.Artist, metaclass=Propertifier):
73-
"""
74-
New base class for all matplotlib artists that
75-
uses `Propertifier` as the metaclass.
76-
"""
77-
78-
79-
# Apply monkey patch
80-
import matplotlib.artist as martist
81-
martist.Artist = Artist
82-
83-
84-
# Testing metaclasses
85-
class MetaClass(type):
86-
def __init__(cls, *args, **kwargs):
87-
print('Brand new class!', cls)
88-
super().__init__(*args, **kwargs)
89-
90-
91-
A = MetaClass('A', (object,), {})
92-
B = MetaClass('B', (A,), {})
93-
94-
95-
# Testing Artist
96-
class Test(Artist):
97-
def set_foo(self, foo):
98-
print('set foo!', foo)
99-
100-
def get_foo(self):
101-
print('get foo!')
102-
103-
def get_bar(self):
104-
print('get bar!')
105-
106-
107-
class Line2D(Artist, mlines.Line2D):
108-
pass
109-
110-
111-
test = Test()
112-
line = Line2D([0], [0])

0 commit comments

Comments
 (0)