3636
3737from sage .misc .classcall_metaclass import ClasscallMetaclass , typecall
3838from sage .misc .fast_methods import WithEqualityById
39- from sage .structure .sage_object import SageObject
40-
4139from sage .plot .colors import colors , Color
40+ from sage .structure .sage_object import SageObject
4241
4342
4443uniq_c = 0
@@ -57,25 +56,7 @@ def _new_global_texture_id():
5756 """
5857 global uniq_c
5958 uniq_c += 1
60- return "texture%s" % uniq_c
61-
62-
63- def is_Texture (x ):
64- r"""
65- Deprecated. Use ``isinstance(x, Texture)`` instead.
66-
67- EXAMPLES::
68-
69- sage: from sage.plot.plot3d.texture import is_Texture, Texture
70- sage: t = Texture(0.5)
71- sage: is_Texture(t)
72- doctest:...: DeprecationWarning: Please use isinstance(x, Texture)
73- See https://github.com/sagemath/sage/issues/27593 for details.
74- True
75- """
76- from sage .misc .superseded import deprecation
77- deprecation (27593 , "Please use isinstance(x, Texture)" )
78- return isinstance (x , Texture )
59+ return f"texture{ uniq_c } "
7960
8061
8162def parse_color (info , base = None ):
@@ -124,21 +105,22 @@ def parse_color(info, base=None):
124105 """
125106 if isinstance (info , Color ):
126107 return info .rgb ()
127- elif isinstance (info , str ):
108+ if isinstance (info , str ):
128109 try :
129110 return Color (info )
130111 except KeyError :
131- raise ValueError ("unknown color '%s'" % info )
132- else :
133- r , g , b = base
134- # We don't want to lose the data when we split it into its respective components.
135- if not r :
136- r = 1e-5
137- if not g :
138- g = 1e-5
139- if not b :
140- b = 1e-5
141- return (float (info * r ), float (info * g ), float (info * b ))
112+ raise ValueError (f"unknown color '{ info } '" )
113+
114+ r , g , b = base
115+ # We don't want to lose the data when we split it into its
116+ # respective components.
117+ if not r :
118+ r = 1e-5
119+ if not g :
120+ g = 1e-5
121+ if not b :
122+ b = 1e-5
123+ return (float (info * r ), float (info * g ), float (info * b ))
142124
143125
144126class Texture (WithEqualityById , SageObject , metaclass = ClasscallMetaclass ):
@@ -278,7 +260,7 @@ def __classcall__(cls, id=None, **kwds):
278260 return typecall (cls , id , ** kwds )
279261
280262 def __init__ (self , id , color = (.4 , .4 , 1 ), opacity = 1 , ambient = 0.5 ,
281- diffuse = 1 , specular = 0 , shininess = 1 , name = None , ** kwds ):
263+ diffuse = 1 , specular = 0 , shininess = 1 , name = None , ** kwds ) -> None :
282264 r"""
283265 Construction of a texture.
284266
@@ -321,7 +303,7 @@ def __init__(self, id, color=(.4, .4, 1), opacity=1, ambient=0.5,
321303 specular = parse_color (specular , color )
322304 self .specular = specular
323305
324- def _repr_ (self ):
306+ def _repr_ (self ) -> str :
325307 """
326308 Return a string representation of the Texture object.
327309
@@ -338,7 +320,7 @@ def _repr_(self):
338320 else :
339321 return f"Texture({ self .id } , { self .hex_rgb ()} )"
340322
341- def hex_rgb (self ):
323+ def hex_rgb (self ) -> str :
342324 """
343325 EXAMPLES::
344326
@@ -350,7 +332,7 @@ def hex_rgb(self):
350332 """
351333 return "{:02x}{:02x}{:02x}" .format (* tuple (int (255 * s ) for s in self .color ))
352334
353- def tachyon_str (self ):
335+ def tachyon_str (self ) -> str :
354336 r"""
355337 Convert Texture object to string suitable for Tachyon ray tracer.
356338
@@ -383,7 +365,7 @@ def tachyon_str(self):
383365 diffuse = diffuse , specular = specular ,
384366 opacity = self .opacity , color = self .color )
385367
386- def x3d_str (self ):
368+ def x3d_str (self ) -> str :
387369 r"""
388370 Convert Texture object to string suitable for x3d.
389371
@@ -402,7 +384,7 @@ def x3d_str(self):
402384 "</Appearance>" ).format (color = self .color , shininess = self .shininess ,
403385 specular = self .specular [0 ])
404386
405- def mtl_str (self ):
387+ def mtl_str (self ) -> str :
406388 r"""
407389 Convert Texture object to string suitable for mtl output.
408390
@@ -426,7 +408,7 @@ def mtl_str(self):
426408 illumination = (2 if sum (self .specular ) > 0 else 1 ),
427409 shininess = self .shininess , opacity = self .opacity )
428410
429- def jmol_str (self , obj ):
411+ def jmol_str (self , obj ) -> str :
430412 r"""
431413 Convert Texture object to string suitable for Jmol applet.
432414
0 commit comments