-
Notifications
You must be signed in to change notification settings - Fork 54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic operations #75
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. A few minor comments
self._registered_operations[image_class][operation_name] = func | ||
|
||
def register_generic_operation(self, dependencies, operation_name, func): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
an "operation_name, func, dependencies" order makes more sense to me.
I realise you are modelling this on register_operation
above, but the distinction is that the image_class is in the right place as it defines where the operation takes place...
@@ -1,6 +1,13 @@ | |||
from collections import defaultdict | |||
|
|||
|
|||
class OperationNameConflict(Exception): | |||
""" | |||
Raised when an operation is registered that clashes with an existing generic operation's name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Raised when the registered operation clashes with an existing operation" ?
a3bc873
to
ca7b023
Compare
This PR implements a new feature called "generic operations". This allows third party apps to register operations that only interact with other operations and not the image directly, which means the operation could be called using any image class that supports those operations it depends on.
The first generic operation is
get_pixel_count
which callsget_size
andget_frame_count
and multiplies the results together. This operation gets automatically added on to the Pillow, Wand and OpenCV image classes as they all support theget_size
andget_frame_count
operations.This will be really nice once we have the Affine Transformations API as this would allow us to implement the higher-level operations (eg, rotate, scale, etc) for all backends that support that API generically.