@@ -1849,41 +1849,57 @@ def __init__(self, state):
1849
1849
Rule .__init__ (self , thickness , np .inf , np .inf , state )
1850
1850
1851
1851
1852
+ _GlueSpec = namedtuple (
1853
+ "_GlueSpec" , "width stretch stretch_order shrink shrink_order" )
1854
+ _GlueSpec ._named = {
1855
+ 'fil' : _GlueSpec (0. , 1. , 1 , 0. , 0 ),
1856
+ 'fill' : _GlueSpec (0. , 1. , 2 , 0. , 0 ),
1857
+ 'filll' : _GlueSpec (0. , 1. , 3 , 0. , 0 ),
1858
+ 'neg_fil' : _GlueSpec (0. , 0. , 0 , 1. , 1 ),
1859
+ 'neg_fill' : _GlueSpec (0. , 0. , 0 , 1. , 2 ),
1860
+ 'neg_filll' : _GlueSpec (0. , 0. , 0 , 1. , 3 ),
1861
+ 'empty' : _GlueSpec (0. , 0. , 0 , 0. , 0 ),
1862
+ 'ss' : _GlueSpec (0. , 1. , 1 , - 1. , 1 ),
1863
+ }
1864
+
1865
+
1852
1866
class Glue (Node ):
1853
1867
"""
1854
1868
Most of the information in this object is stored in the underlying
1855
- `GlueSpec ` class, which is shared between multiple glue objects.
1869
+ ``_GlueSpec` ` class, which is shared between multiple glue objects.
1856
1870
(This is a memory optimization which probably doesn't matter anymore, but
1857
1871
it's easier to stick to what TeX does.)
1858
1872
"""
1859
1873
1874
+ @cbook .deprecated ("3.3" )
1875
+ @property
1876
+ def glue_subtype (self ):
1877
+ return "normal"
1878
+
1879
+ @cbook ._delete_parameter ("3.3" , "copy" )
1860
1880
def __init__ (self , glue_type , copy = False ):
1861
1881
Node .__init__ (self )
1862
- self .glue_subtype = 'normal'
1863
1882
if isinstance (glue_type , str ):
1864
- glue_spec = GlueSpec . factory ( glue_type )
1865
- elif isinstance (glue_type , GlueSpec ):
1883
+ glue_spec = _GlueSpec . _named [ glue_type ]
1884
+ elif isinstance (glue_type , _GlueSpec ):
1866
1885
glue_spec = glue_type
1867
1886
else :
1868
1887
raise ValueError ("glue_type must be a glue spec name or instance" )
1869
- if copy :
1870
- glue_spec = glue_spec .copy ()
1871
- self .glue_spec = glue_spec
1888
+ self .glue_spec = glue_spec
1872
1889
1873
1890
def shrink (self ):
1874
1891
Node .shrink (self )
1875
1892
if self .size < NUM_SIZE_LEVELS :
1876
- if self .glue_spec .width != 0. :
1877
- self .glue_spec = self .glue_spec .copy ()
1878
- self .glue_spec .width *= SHRINK_FACTOR
1893
+ g = self .glue_spec
1894
+ self .glue_spec = g ._replace (width = g .width * SHRINK_FACTOR )
1879
1895
1880
1896
def grow (self ):
1881
1897
Node .grow (self )
1882
- if self .glue_spec .width != 0. :
1883
- self .glue_spec = self .glue_spec .copy ()
1884
- self .glue_spec .width *= GROW_FACTOR
1898
+ g = self .glue_spec
1899
+ self .glue_spec = g ._replace (width = g .width * GROW_FACTOR )
1885
1900
1886
1901
1902
+ @cbook .deprecated ("3.3" )
1887
1903
class GlueSpec :
1888
1904
"""See `Glue`."""
1889
1905
@@ -1908,16 +1924,9 @@ def factory(cls, glue_type):
1908
1924
return cls ._types [glue_type ]
1909
1925
1910
1926
1911
- GlueSpec ._types = {
1912
- 'fil' : GlueSpec (0. , 1. , 1 , 0. , 0 ),
1913
- 'fill' : GlueSpec (0. , 1. , 2 , 0. , 0 ),
1914
- 'filll' : GlueSpec (0. , 1. , 3 , 0. , 0 ),
1915
- 'neg_fil' : GlueSpec (0. , 0. , 0 , 1. , 1 ),
1916
- 'neg_fill' : GlueSpec (0. , 0. , 0 , 1. , 2 ),
1917
- 'neg_filll' : GlueSpec (0. , 0. , 0 , 1. , 3 ),
1918
- 'empty' : GlueSpec (0. , 0. , 0 , 0. , 0 ),
1919
- 'ss' : GlueSpec (0. , 1. , 1 , - 1. , 1 )
1920
- }
1927
+ with cbook ._suppress_matplotlib_deprecation_warning ():
1928
+ GlueSpec ._types = {k : GlueSpec (** v ._asdict ())
1929
+ for k , v in _GlueSpec ._named .items ()}
1921
1930
1922
1931
1923
1932
# Some convenient ways to get common kinds of glue
0 commit comments