MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / validate_cycler

Function validate_cycler

lib/matplotlib/rcsetup.py:921–963  ·  view source on GitHub ↗

Return a Cycler object from a string repr or the object itself.

(s)

Source from the content-addressed store, hash-verified

919
920
921def validate_cycler(s):
922 """Return a Cycler object from a string repr or the object itself."""
923 if isinstance(s, str):
924 try:
925 s = _parse_cycler_string(s)
926 except Exception as e:
927 raise ValueError(f"{s!r} is not a valid cycler construction: {e}"
928 ) from e
929 if isinstance(s, Cycler):
930 cycler_inst = s
931 else:
932 raise ValueError(f"Object is not a string or Cycler instance: {s!r}")
933
934 unknowns = cycler_inst.keys - (set(_prop_validators) | set(_prop_aliases))
935 if unknowns:
936 raise ValueError("Unknown artist properties: %s" % unknowns)
937
938 # Not a full validation, but it'll at least normalize property names
939 # A fuller validation would require v0.10 of cycler.
940 checker = set()
941 for prop in cycler_inst.keys:
942 norm_prop = _prop_aliases.get(prop, prop)
943 if norm_prop != prop and norm_prop in cycler_inst.keys:
944 raise ValueError(f"Cannot specify both {norm_prop!r} and alias "
945 f"{prop!r} in the same prop_cycle")
946 if norm_prop in checker:
947 raise ValueError(f"Another property was already aliased to "
948 f"{norm_prop!r}. Collision normalizing {prop!r}.")
949 checker.update([norm_prop])
950
951 # This is just an extra-careful check, just in case there is some
952 # edge-case I haven't thought of.
953 assert len(checker) == len(cycler_inst.keys)
954
955 # Now, it should be safe to mutate this cycler
956 for prop in cycler_inst.keys:
957 norm_prop = _prop_aliases.get(prop, prop)
958 cycler_inst.change_key(prop, norm_prop)
959
960 for key, vals in cycler_inst.by_key().items():
961 _prop_validators[key](vals)
962
963 return cycler_inst
964
965
966def validate_hist_bins(s):

Callers 2

cyclerFunction · 0.85

Calls 3

_parse_cycler_stringFunction · 0.85
getMethod · 0.45
updateMethod · 0.45

Tested by 1

Used in the wild real call sites across dependent graphs

searching dependent graphs…