neuron_morphology.feature_extractor.marked_feature

Module Contents

Classes

MarkedFeature

Functions

specialize(feature: Feature, specialization_set: SpecializationSet) → Dict[str, MarkedFeature] Bind some of a feature’s keyword arguments, using provided
nested_specialize(feature: Feature, specialization_sets: SpecializationSets) → Dict[str, MarkedFeature] Apply specializations hierarchically to a base feature. Generating a
marked(mark: Type[Mark]) Decorator for adding a mark to a function.
neuron_morphology.feature_extractor.marked_feature.FeatureFn
neuron_morphology.feature_extractor.marked_feature.M
class neuron_morphology.feature_extractor.marked_feature.MarkedFeature(marks: Set[Type[Mark]], feature: Feature, name: Optional[str] = None, preserve_marks: bool = True)
__slots__ = ['marks', 'feature', 'name']
__name__
__repr__(self)

Return repr(self).

__hash__(self)

Return hash(self).

add_mark(self, mark: Type[Mark])

Assign an additional mark to this feature

__call__(self, *args, **kwargs)

Execute the underlying feature, passing along all arguments

deepcopy(self, **kwargs)

Make a deep copy of this marked feature

partial(self, *args, **kwargs)

Fix one or more parameters on this feature’s callable

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
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.

neuron_morphology.feature_extractor.marked_feature.Feature
neuron_morphology.feature_extractor.marked_feature.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”
neuron_morphology.feature_extractor.marked_feature.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.

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”
neuron_morphology.feature_extractor.marked_feature.marked(mark: Type[Mark])

Decorator for adding a mark to a function.

Parameters:
mark : the mark to be applied

Examples

@marked(RequiresA) @marked(RequiresB) def some_feature_requiring_a_and_b(…):