@@ -1849,41 +1849,57 @@ def __init__(self, state):
18491849 Rule .__init__ (self , thickness , np .inf , np .inf , state )
18501850
18511851
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+
18521866class Glue (Node ):
18531867 """
18541868 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.
18561870 (This is a memory optimization which probably doesn't matter anymore, but
18571871 it's easier to stick to what TeX does.)
18581872 """
18591873
1874+ @cbook .deprecated ("3.3" )
1875+ @property
1876+ def glue_subtype (self ):
1877+ return "normal"
1878+
1879+ @cbook ._delete_parameter ("3.3" , "copy" )
18601880 def __init__ (self , glue_type , copy = False ):
18611881 Node .__init__ (self )
1862- self .glue_subtype = 'normal'
18631882 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 ):
18661885 glue_spec = glue_type
18671886 else :
18681887 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
18721889
18731890 def shrink (self ):
18741891 Node .shrink (self )
18751892 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 )
18791895
18801896 def grow (self ):
18811897 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 )
18851900
18861901
1902+ @cbook .deprecated ("3.3" )
18871903class GlueSpec :
18881904 """See `Glue`."""
18891905
@@ -1908,16 +1924,9 @@ def factory(cls, glue_type):
19081924 return cls ._types [glue_type ]
19091925
19101926
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 ()}
19211930
19221931
19231932# Some convenient ways to get common kinds of glue
0 commit comments