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

Vectorized linear function #3303

Closed
wants to merge 9 commits into from
Closed

Conversation

antonmarsden
Copy link
Contributor

@lovell This looked easy enough to implement, and adds some good value. This pull request is not really production quality and my knowledge of the code base is very limited. A few things to consider:

  • do the additional variables make sense (linearVecA/linearVecB) or could linearA/linearB be both number & number[]?
  • are there other functions that can be generalised in a similar fashion?
  • probably needs a good test case :)
  • unclear what the behaviour is (or should be) if the arrays are different lengths or if only one array is defined

@lovell
Copy link
Owner

lovell commented Jul 23, 2022

Hi, thanks for the PR.

How about we switch the (internal) this.options so linearA and linearB are always arrays, and if someone provides a single value (the current behaviour) we convert to a single element array.

.linear(a, b)
// would be equivalent to
.linear([a], [b])
// but now we would also support
.linear([a1, a2, a3], [b1, b2, b3])

This should make the C++ code path a bit simpler as it will only deal with arrays of doubles.

@antonmarsden
Copy link
Contributor Author

@lovell Great suggestion, I have implemented it. Added some fancy logic for dealing with the alpha channel that you may wish to review. Only outstanding thing is test cases, which I can hopefully make some progress on shortly.

@antonmarsden antonmarsden marked this pull request as ready for review July 24, 2022 02:30
@antonmarsden
Copy link
Contributor Author

Handling the multi-band expansion for linear() looked tricky in the context of sharp's colourspace handling.

Copy link
Owner

@lovell lovell left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. I've left a couple of small comments/questions inline but otherwise this is good to go.

Please can you rebase against the upstream/eagle branch.

src/pipeline.cc Outdated Show resolved Hide resolved
lib/constructor.js Outdated Show resolved Hide resolved
lib/operation.js Show resolved Hide resolved
@antonmarsden
Copy link
Contributor Author

@lovell Done, all yours.

@coveralls
Copy link

coveralls commented Jul 26, 2022

Coverage Status

Coverage remained the same at 100.0% when pulling 0c55d0e on antonmarsden:main into dd56a96 on lovell:eagle.

@lovell
Copy link
Owner

lovell commented Jul 27, 2022

Please can you add unit test(s) to ensure all the new logic is fully-covered - see https://coveralls.io/builds/51160601

@lovell lovell added this to the v0.31.0 milestone Aug 18, 2022
lovell added a commit that referenced this pull request Aug 20, 2022
@lovell
Copy link
Owner

lovell commented Aug 20, 2022

Landed via commit 74e3f73 - this will be in v0.31.0, thanks again for working on this.

@lovell lovell closed this Aug 20, 2022
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.

None yet

3 participants