:mod:`neuron_morphology.feature_extractor.marked_feature` ========================================================= .. py:module:: neuron_morphology.feature_extractor.marked_feature Module Contents --------------- Classes ~~~~~~~ .. autoapisummary:: neuron_morphology.feature_extractor.marked_feature.MarkedFeature Functions ~~~~~~~~~ .. autoapisummary:: neuron_morphology.feature_extractor.marked_feature.specialize neuron_morphology.feature_extractor.marked_feature.nested_specialize neuron_morphology.feature_extractor.marked_feature.marked .. data:: FeatureFn .. data:: M .. py:class:: MarkedFeature(marks: Set[Type[Mark]], feature: Feature, name: Optional[str] = None, preserve_marks: bool = True) .. attribute:: __slots__ :annotation: = ['marks', 'feature', 'name'] .. attribute:: __name__ .. method:: __repr__(self) Return repr(self). .. !! processed by numpydoc !! .. method:: __hash__(self) Return hash(self). .. !! processed by numpydoc !! .. method:: add_mark(self, mark: Type[Mark]) Assign an additional mark to this feature .. !! processed by numpydoc !! .. method:: __call__(self, *args, **kwargs) Execute the underlying feature, passing along all arguments .. !! processed by numpydoc !! .. method:: deepcopy(self, **kwargs) Make a deep copy of this marked feature .. !! processed by numpydoc !! .. method:: partial(self, *args, **kwargs) Fix one or more parameters on this feature's callable .. !! processed by numpydoc !! .. method:: specialize(self, option: SpecializationOption) Apply a specialization option to this feature. This binds parameters on the feature's __call__ method, sets 0 or more additional marks, and namespaces the feature's name. :Parameters: **option** : The specialization option with which to specialize this feature. :Returns: a deep copy of this feature with updated callable, marks and name .. .. !! processed by numpydoc !! .. classmethod:: ensure(cls: Type[M], feature: Feature) If a function is not a MarkedFeature, convert it. :Parameters: **feature** : the feature to be converted .. :Returns: Either a marked feature generated from the input, or the input marked feature. .. !! processed by numpydoc !! .. data:: Feature .. function:: specialize(feature: Feature, specialization_set: SpecializationSet) -> Dict[str, MarkedFeature] Bind some of a feature's keyword arguments, using provided specialization options. :Parameters: **feature** : will be used as a basis for specialization .. **specialization_set** : each element defines a particular specialization (i.e a set of keyword argument values and marks) to be applied to the feature :Returns: A dictionary mapping (namespaced) feature names to specialized features. .. Note that names are formatted as "specialization_name.base_feature_name" .. .. !! processed by numpydoc !! .. function:: nested_specialize(feature: Feature, specialization_sets: SpecializationSets) -> Dict[str, MarkedFeature] Apply specializations hierarchically to a base feature. Generating a new collection of specialized features. :Parameters: **feature** : will be used as a basis for specialization .. **specialization_sets** : each element describes a set of specialization options. The output will have one specialization for each element of the cartesian product of these sets. :Returns: A dictionary mapping namespaced feature names to specialized features. .. .. rubric:: Notes Specializations are applied from the start of the specialization_sets to the end. This means that the generated names are structures like: "last_spec.middle_spec.first_spec.base_feature_name" .. !! processed by numpydoc !! .. function:: marked(mark: Type[Mark]) Decorator for adding a mark to a function. :Parameters: **mark** : the mark to be applied .. .. rubric:: Examples @marked(RequiresA) @marked(RequiresB) def some_feature_requiring_a_and_b(...): ... .. !! processed by numpydoc !!