@@ -1834,61 +1834,6 @@ def _str_lower_equal(obj, s):
18341834 return isinstance (obj , str ) and obj .lower () == s
18351835
18361836
1837- def _define_aliases (alias_d , cls = None ):
1838- """
1839- Class decorator for defining property aliases.
1840-
1841- Use as ::
1842-
1843- @cbook._define_aliases({"property": ["alias", ...], ...})
1844- class C: ...
1845-
1846- For each property, if the corresponding ``get_property`` is defined in the
1847- class so far, an alias named ``get_alias`` will be defined; the same will
1848- be done for setters. If neither the getter nor the setter exists, an
1849- exception will be raised.
1850-
1851- The alias map is stored as the ``_alias_map`` attribute on the class and
1852- can be used by `.normalize_kwargs` (which assumes that higher priority
1853- aliases come last).
1854- """
1855- if cls is None : # Return the actual class decorator.
1856- return functools .partial (_define_aliases , alias_d )
1857-
1858- def make_alias (name ): # Enforce a closure over *name*.
1859- @functools .wraps (getattr (cls , name ))
1860- def method (self , * args , ** kwargs ):
1861- return getattr (self , name )(* args , ** kwargs )
1862- return method
1863-
1864- for prop , aliases in alias_d .items ():
1865- exists = False
1866- for prefix in ["get_" , "set_" ]:
1867- if prefix + prop in vars (cls ):
1868- exists = True
1869- for alias in aliases :
1870- method = make_alias (prefix + prop )
1871- method .__name__ = prefix + alias
1872- method .__doc__ = "Alias for `{}`." .format (prefix + prop )
1873- setattr (cls , prefix + alias , method )
1874- if not exists :
1875- raise ValueError (
1876- "Neither getter nor setter exists for {!r}" .format (prop ))
1877-
1878- def get_aliased_and_aliases (d ):
1879- return {* d , * (alias for aliases in d .values () for alias in aliases )}
1880-
1881- preexisting_aliases = getattr (cls , "_alias_map" , {})
1882- conflicting = (get_aliased_and_aliases (preexisting_aliases )
1883- & get_aliased_and_aliases (alias_d ))
1884- if conflicting :
1885- # Need to decide on conflict resolution policy.
1886- raise NotImplementedError (
1887- f"Parent class already defines conflicting aliases: { conflicting } " )
1888- cls ._alias_map = {** preexisting_aliases , ** alias_d }
1889- return cls
1890-
1891-
18921837def _array_perimeter (arr ):
18931838 """
18941839 Get the elements on the perimeter of *arr*.
0 commit comments