MCPcopy
hub / github.com/python-visualization/folium / _validate_function

Method _validate_function

folium/features.py:802–817  ·  view source on GitHub ↗

Tests `self.style_function` and `self.highlight_function` to ensure they are functions returning dictionaries.

(self, func: Callable, name: str)

Source from the content-addressed store, hash-verified

800 self.data = {"type": "FeatureCollection", "features": [self.data]}
801
802 def _validate_function(self, func: Callable, name: str) -> None:
803 """
804 Tests `self.style_function` and `self.highlight_function` to ensure
805 they are functions returning dictionaries.
806 """
807 # If for some reason there are no features (e.g., empty API response)
808 # don't attempt validation
809 if not self.data["features"]:
810 return
811
812 test_feature = self.data["features"][0]
813 if not callable(func) or not isinstance(func(test_feature), dict):
814 raise ValueError(
815 f"{name} should be a function that accepts items from "
816 "data['features'] and returns a dictionary."
817 )
818
819 def find_identifier(self) -> str:
820 """Find a unique identifier for each feature, create it if needed.

Callers 1

__init__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected