@@ -534,7 +534,54 @@ def validate_ps_distiller(s):
534534_validate_negative_linestyle = ValidateInStrings ('negative_linestyle' ,
535535 ['solid' , 'dashed' ],
536536 ignorecase = True )
537+ def validate_markevery (s ):
538+ """
539+ Validate the markevery property of a Line2D object.
540+
541+ Parameters
542+ ----------
543+ s : None, int, float, slice, length-2 tuple of ints,
544+ length-2 tuple of floats, list of ints
545+
546+ Returns
547+ -------
548+ s : None, int, float, slice, length-2 tuple of ints,
549+ length-2 tuple of floats, list of ints
550+
551+ """
552+ # Validate s against type slice
553+ if isinstance (s , slice ):
554+ return s
555+ # Validate s against type tuple
556+ if isinstance (s , tuple ):
557+ tupMaxLength = 2
558+ tupType = type (s [0 ])
559+ if len (s ) != tupMaxLength :
560+ raise TypeError ("'markevery' tuple must have a length of "
561+ "%d" % (tupMaxLength ))
562+ if tupType is int and not all (isinstance (e , int ) for e in s ):
563+ raise TypeError ("'markevery' tuple with first element of "
564+ "type int must have all elements of type "
565+ "int" )
566+ if tupType is float and not all (isinstance (e , float ) for e in s ):
567+ raise TypeError ("'markevery' tuple with first element of "
568+ "type float must have all elements of type "
569+ "float" )
570+ if tupType is not float and tupType is not int :
571+ raise TypeError ("'markevery' tuple contains an invalid type" )
572+ # Validate s against type list
573+ elif isinstance (s , list ):
574+ if not all (isinstance (e , int ) for e in s ):
575+ raise TypeError ("'markevery' list must have all elements of "
576+ "type int" )
577+ # Validate s against type float int and None
578+ elif not isinstance (s , (float , int )):
579+ if s is not None :
580+ raise TypeError ("'markevery' is of an invalid type" )
581+
582+ return s
537583
584+ validate_markeverylist = _listify_validator (validate_markevery )
538585
539586validate_legend_loc = ValidateInStrings (
540587 'legend_loc' ,
@@ -676,6 +723,7 @@ def validate_hatch(s):
676723 'markersize' : validate_floatlist ,
677724 'markeredgewidth' : validate_floatlist ,
678725 'markeredgecolor' : validate_colorlist ,
726+ 'markevery' : validate_markeverylist ,
679727 'alpha' : validate_floatlist ,
680728 'marker' : validate_stringlist ,
681729 'hatch' : validate_hatchlist ,
0 commit comments