Skip to content
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

Unify FunctionSource in Map and Reduce #1540

Merged
merged 1 commit into from
Oct 9, 2019
Merged

Conversation

ttung
Copy link
Collaborator

@ttung ttung commented Sep 6, 2019

This is needed to enable #1539, as that imports FunctionSource from ImageStack (and Map/Reduce import ImageStack).

Note that this is not entirely for free. The function aliases (example: where we alias 'max' to 'amax' for FunctionSource.np) now come from one source, which may or may not be desirable.

Test plan: travis yo

@codecov-io
Copy link

codecov-io commented Sep 7, 2019

Codecov Report

Merging #1540 into master will increase coverage by <.01%.
The diff coverage is 89.28%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #1540      +/-   ##
==========================================
+ Coverage   87.48%   87.49%   +<.01%     
==========================================
  Files         145      146       +1     
  Lines        5058     5036      -22     
==========================================
- Hits         4425     4406      -19     
+ Misses        633      630       -3
Impacted Files Coverage Δ
starfish/types.py 100% <ø> (ø) ⬆️
starfish/core/image/Filter/reduce.py 96.42% <100%> (+4.12%) ⬆️
starfish/core/types/__init__.py 100% <100%> (ø) ⬆️
starfish/core/image/Filter/map.py 100% <100%> (+7.31%) ⬆️
starfish/core/types/_functionsource.py 88% <88%> (ø)

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 505f73c...bc1c1ec. Read the comment docs.

Copy link
Collaborator

@shanaxel42 shanaxel42 left a comment

Choose a reason for hiding this comment

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

general question, and sorry if this has already been discussed. But what's the advantage of having the function source logic over just have a function parameter passed into reduce? Like func=np.max

@ttung ttung force-pushed the tonytung-unify-function-source branch 2 times, most recently from beaad60 to 95bd2d1 Compare September 16, 2019 20:51
@ttung ttung force-pushed the tonytung-unify-function-source branch from 95bd2d1 to ab3545d Compare September 16, 2019 20:53
@ttung ttung changed the base branch from tonytung-map to master September 16, 2019 20:55
@ttung ttung force-pushed the tonytung-unify-function-source branch from ab3545d to 079358f Compare September 16, 2019 20:57
@ttung
Copy link
Collaborator Author

ttung commented Sep 17, 2019

general question, and sorry if this has already been discussed. But what's the advantage of having the function source logic over just have a function parameter passed into reduce? Like func=np.max

as discussed offline, allowing arbitrary callables to be passed in makes provenance tracking extremely challenging. However, we could plausibly use code inspection to solve that problem.

@ttung ttung force-pushed the tonytung-unify-function-source branch 7 times, most recently from e1857ac to 947124f Compare September 18, 2019 22:53
@ambrosejcarr
Copy link
Member

as discussed offline, allowing arbitrary callables to be passed in makes provenance tracking extremely challenging. However, we could plausibly use code inspection to solve that problem.

If you see a path where this is achievable, I believe usability benefits strongly from just passing in the function.

@ttung
Copy link
Collaborator Author

ttung commented Sep 19, 2019

If you see a path where this is achievable, I believe usability benefits strongly from just passing in the function.

It's somewhat achievable. I'll look into it.

@ambrosejcarr
Copy link
Member

It's somewhat achievable. I'll look into it.

After PR is merged is OK with me, if this blocks.

@ttung ttung force-pushed the tonytung-unify-function-source branch 4 times, most recently from ed418fe to eb15634 Compare September 20, 2019 01:47
@ttung
Copy link
Collaborator Author

ttung commented Sep 20, 2019

After PR is merged is OK with me, if this blocks.

#1568

@ttung ttung force-pushed the tonytung-unify-function-source branch 4 times, most recently from 14d935b to 1b51899 Compare September 24, 2019 18:04
@ttung ttung force-pushed the master branch 2 times, most recently from 67a6870 to 849058e Compare September 24, 2019 18:10
@ttung ttung force-pushed the tonytung-unify-function-source branch 4 times, most recently from bdb0129 to c647b6d Compare October 1, 2019 05:06
@ttung ttung force-pushed the tonytung-unify-function-source branch 2 times, most recently from 93cbd18 to 1cd0b80 Compare October 4, 2019 17:53
@ttung ttung requested a review from shanaxel42 October 4, 2019 22:09
@ttung ttung force-pushed the tonytung-unify-function-source branch 2 times, most recently from bc1c1ec to c193ef5 Compare October 9, 2019 21:01
Note that this is not entirely for free.  The function aliases (example: where we alias 'max' to 'amax' for `FunctionSource.np`) now come from one source, which may or may not be desirable.
@ttung ttung force-pushed the tonytung-unify-function-source branch from c193ef5 to b042e2d Compare October 9, 2019 21:14
@ttung ttung merged commit 9592539 into master Oct 9, 2019
@ttung ttung mentioned this pull request Oct 9, 2019
ttung pushed a commit that referenced this pull request Oct 9, 2019
In #1540, I missed a conversion from Reduce.FunctionSource to types.FunctionSource.
ttung pushed a commit that referenced this pull request Oct 9, 2019
In #1540, I missed a conversion from Reduce.FunctionSource to types.FunctionSource.
ttung pushed a commit that referenced this pull request Oct 10, 2019
This is syntactic sugar to simplify single map / reduce operations.  Right now, we would need to instantiate the filter and then run it against the stack, e.g.,

```
max_projector = Filter.Reduce((Axes.CH, Axes.ROUND, Axes.ZPLANE))
max_projected = max_projector.run(stack)
```

With this, it simplifies to:

```
max_projected = stack.reduce((Axes.CH, Axes.ROUND, Axes.ZPLANE), "max")
```

Test plan: Converted imagestack/test/test_max_proj.py to use this idiom.
Depends on #1540
@ttung ttung deleted the tonytung-unify-function-source branch October 10, 2019 06:21
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