Feature: New LayerFilter class #149
Replies: 1 comment 1 reply
-
|
Hey Rodrigo, thank you for the idea and detailed description. Designing Composites by Layer-DepthI previously proposed to use a NameMapComposite for your specific use-case, since when using the layer-depth as a rule-indicator, the Composite is made with a specific architecture in mind. While I gave you an example of how to map layers to names as a demonstration to how these LayerMapFilterThe vanilla However, instead of adding this functionality as a new layer of abstraction, I could imagine implementing an abstract LayerFilterComposite (there may be a better name), similar to LayerMapComposite, which instead of defining a single I asked myself this question when I implemented the core So actually, I think it may be a cleaner approach to directly implement a Conclusion
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Circling back on the thread about assigning LRP rules by layer index, I have implemented a
LayerFilterclass to reduce the boilerplate code required to specify LRP rules by layer index.This class would be particularly useful for users taking advantage of
NameMapComposite.@chr5tphr Concretely, let me know if you consider this class interesting for zennit and I would be happy to submit a proper PR. Before putting in the work, I wanted to check with you first.
TL;DR
Instead of this:
I propose:
Demo
Here's an example of how the new
LayerFilterclass would improve the user-friendliness when usingNameMapCompositeby using theLayerFilterclass to elegantly filter layers by index and type:Before
The definition of the
name_mapvariable might be cumbersome and requires boilerplate code in this first snippet.Without LayerFilter class
After
LayerFilter class definition
The definition of the
name_mapvariable is improved in this snippet by reducing the noise around the actual content.With LayerFilter class
Beta Was this translation helpful? Give feedback.
All reactions