Skip to content

Conversation

@AleksMat
Copy link
Contributor

@AleksMat AleksMat commented Jul 27, 2022

There are a few minor changes in the functionality:

  • In case all timestamps are filtered the old version raised an error but the new version returns empty numpy arrays (i.e. shape (0, height, width, bands)) and empty GeoDataFrames.
  • The new version returns a shallow copy of an input EOPatch. That is because otherwise we would have a mismatch in time dimension.
  • I removed _update_other_data method because it was useless. Instead, any such update can be performed in a separate task.
  • The new version now also supports filtering vector features.

Note: I'm not sure if I correctly handled type of filter_func but it is a bit tricky because it depends on feature type of feature parameter.

@AleksMat AleksMat requested a review from zigaLuksic July 27, 2022 08:55
Copy link
Collaborator

@zigaLuksic zigaLuksic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure i understand the 'returns a shallow copy'
what exactly is shallowly copied here?

@AleksMat
Copy link
Contributor Author

I am not sure i understand the 'returns a shallow copy'
what exactly is shallowly copied here?

We return a new instance of an EOPatch and by default all features are filtered and moved into it. So it's basically a shallow copy.

@zigaLuksic
Copy link
Collaborator

I am not sure i understand the 'returns a shallow copy'
what exactly is shallowly copied here?

We return a new instance of an EOPatch and by default all features are filtered and moved into it. So it's basically a shallow copy.

Not entirely sure I would call it a copy, it's more of a view (since we are returning views of numpy features), but I see your reasoning now.



class SimpleFilterTask(EOTask):
class SimpleFilterTask(EOTask, Generic[_T]):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wouldnt it be possible to omit all the generic stuff by using

FilterFuncType = Union[Callable[[np.ndarray], bool], Callable[[dt.datetime], bool]]

While i'm a big fan of using advanced type theory, I'm worried that this migh class with future improvements to EOTasks since they would need to be generics (and i'm not sure how generics clash in python).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, too bad. Ok, I removed Generic and TypeVar and used the normal union. Then I had to set a type Iterable to the parameter in _get_filtered_indices method and mypy is also fine with that.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

well to be entirely precise this would also depend on what the user inputs as the feature right? So technically overload would work best here. But perhaps let's not go there :)

@codecov-commenter
Copy link

Codecov Report

Merging #438 (2ea5e97) into develop (2f035d1) will increase coverage by 0.01%.
The diff coverage is 100.00%.

@@             Coverage Diff             @@
##           develop     #438      +/-   ##
===========================================
+ Coverage    82.71%   82.72%   +0.01%     
===========================================
  Files           59       59              
  Lines         5530     5535       +5     
===========================================
+ Hits          4574     4579       +5     
  Misses         956      956              
Impacted Files Coverage Δ
features/eolearn/features/feature_manipulation.py 95.95% <100.00%> (+1.27%) ⬆️
core/eolearn/core/constants.py 97.26% <0.00%> (-1.37%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2f035d1...2ea5e97. Read the comment docs.

@zigaLuksic zigaLuksic merged commit f69b86f into develop Jul 27, 2022
@zigaLuksic zigaLuksic deleted the feat/simple-filter-task branch July 27, 2022 10:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants