Skip to content

Commit 01049f1

Browse files
committed
Mixin version
1 parent 9732a3f commit 01049f1

File tree

2 files changed

+16
-13
lines changed

2 files changed

+16
-13
lines changed

lib/matplotlib/scale.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -79,14 +79,18 @@ def limit_range_for_scale(self, vmin, vmax, minpos):
7979
return vmin, vmax
8080

8181

82-
class TransformScaleBase(Transform):
83-
"""Base transform for scales to allow a deep copy"""
82+
class CopyableTransformMixin():
83+
"""
84+
Mixin to support copy and deep copy on transforms. This alows scales,
85+
and hence norms, to be copyable.
86+
"""
8487
def __deepcopy__(self, memo):
8588
return self.frozen()
8689

90+
__copy__ = __deepcopy__
91+
8792

88-
class LinearTransform(TransformScaleBase, IdentityTransform):
89-
"""Mixed class for Identity"""
93+
class LinearTransform(CopyableTransformMixin, IdentityTransform):
9094
pass
9195

9296

@@ -124,9 +128,9 @@ def get_transform(self):
124128
return LinearTransform()
125129

126130

127-
class FuncTransform(TransformScaleBase):
131+
class FuncTransform(CopyableTransformMixin, Transform):
128132
"""
129-
A simple transform that takes and arbitrary function for the
133+
A transform that takes and arbitrary function for the
130134
forward and inverse transform.
131135
"""
132136

@@ -202,7 +206,7 @@ def set_default_locators_and_formatters(self, axis):
202206
axis.set_minor_locator(NullLocator())
203207

204208

205-
class LogTransform(TransformScaleBase):
209+
class LogTransform(CopyableTransformMixin, Transform):
206210
input_dims = output_dims = 1
207211

208212
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
@@ -244,7 +248,7 @@ def inverted(self):
244248
return InvertedLogTransform(self.base)
245249

246250

247-
class InvertedLogTransform(TransformScaleBase):
251+
class InvertedLogTransform(CopyableTransformMixin, Transform):
248252
input_dims = output_dims = 1
249253

250254
def __init__(self, base):
@@ -370,7 +374,7 @@ def get_transform(self):
370374
return self._transform
371375

372376

373-
class SymmetricalLogTransform(TransformScaleBase):
377+
class SymmetricalLogTransform(CopyableTransformMixin, Transform):
374378
input_dims = output_dims = 1
375379

376380
def __init__(self, base, linthresh, linscale):
@@ -402,7 +406,7 @@ def inverted(self):
402406
self.linscale)
403407

404408

405-
class InvertedSymmetricalLogTransform(TransformScaleBase):
409+
class InvertedSymmetricalLogTransform(CopyableTransformMixin, Transform):
406410
input_dims = output_dims = 1
407411

408412
def __init__(self, base, linthresh, linscale):
@@ -505,7 +509,7 @@ def get_transform(self):
505509
return self._transform
506510

507511

508-
class LogitTransform(TransformScaleBase):
512+
class LogitTransform(CopyableTransformMixin, Transform):
509513
input_dims = output_dims = 1
510514

511515
@_api.rename_parameter("3.3", "nonpos", "nonpositive")
@@ -531,7 +535,7 @@ def __str__(self):
531535
return "{}({!r})".format(type(self).__name__, self._nonpositive)
532536

533537

534-
class LogisticTransform(TransformScaleBase):
538+
class LogisticTransform(CopyableTransformMixin, Transform):
535539
input_dims = output_dims = 1
536540

537541
@_api.rename_parameter("3.3", "nonpos", "nonpositive")

lib/matplotlib/tests/test_colors.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1269,7 +1269,6 @@ def test_repr_html():
12691269
png = cmap._repr_png_()
12701270
assert base64.b64encode(png).decode('ascii') in html
12711271
assert cmap.name in html
1272-
<<<<<<< HEAD
12731272
assert html.startswith('<div')
12741273
assert html.endswith('</div>')
12751274

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy