-
Notifications
You must be signed in to change notification settings - Fork 294
feat: expose image attribute as expression #4848
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
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #4848 +/- ##
==========================================
+ Coverage 73.81% 74.29% +0.47%
==========================================
Files 957 959 +2
Lines 124278 123335 -943
==========================================
- Hits 91740 91635 -105
+ Misses 32538 31700 -838
🚀 New features to boost your workflow:
|
daft/expressions/expressions.py
Outdated
@@ -5154,6 +5154,18 @@ def to_mode(self, mode: str | ImageMode) -> Expression: | |||
f = native.get_function_from_registry("to_mode") | |||
return Expression._from_pyexpr(f(self._expr, mode=image_mode)) | |||
|
|||
def attribute(self, name: str) -> Expression: |
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.
since we know what attributes are available, use a Literal['width', 'height', 'channel', 'mode']
for better typings
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.
sounds good
src/daft-image/src/ops.rs
Outdated
@@ -194,6 +195,31 @@ impl ImageOps for ImageArray { | |||
.collect(); | |||
image_array_from_img_buffers(self.name(), &buffers, Some(mode)) | |||
} | |||
|
|||
fn attribute(&self, attr: &str) -> DaftResult<DataArray<UInt32Type>> { |
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.
Can we use an Enum to model the attributes instead of the &str
@Jay-ju what's the status on this PR? I think once those two small changes are implemented, we could merge this one in! |
a72a431
to
367bfd9
Compare
@universalmind303 so sorry, I've been busy with other matters these few weeks. Some updates have been made here. Please take a look when you have time. |
367bfd9
to
07ea9c5
Compare
@Jay-ju how are you running pre-commit locally? |
![]() @srilman If simply executing |
07ea9c5
to
338f55b
Compare
Ok I think there is some slight difference in mypy rules between local and CI. Could you make the change you suggested to fix CI for now, even if it fails locally? |
7cff310
to
6d53c36
Compare
f49d4bf
to
a4b303f
Compare
@srilman My current local version has run successfully. The currently failing unit test is an unstable unit test, and I have fixed it. Could you please check it again when you have time? |
a4b303f
to
7891081
Compare
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.
Overall, this looks good to me, but rather than an .image.attribute
expression, wouldn't it make more sense to have expressions for each of the attributes themselves, like .image.width
, .image.height
, etc?
@srilman |
@Jay-ju my main concern is that when looking at the list of available functions, via IDE tools, properties like the width, height, etc won't show up because they are potential arguments to |
256fe15
to
ac5885b
Compare
@srilman That sounds reasonable; it has been revised. |
@universalmind303 Can this be merged?? |
@Jay-ju can you fix the style issue on CI? |
1816465
to
f901f26
Compare
Changes Made
Related Issues
Checklist
docs/mkdocs.yml
navigation