Skip to content

Conversation

@max-vassili3v
Copy link
Collaborator

@max-vassili3v max-vassili3v commented Nov 17, 2025

This pull request adds generalised broadcasting for DualVectors based on ChainRules.jl for:

  • single-argument functions that operate on reals
  • binary operations broadcasted between a Real and a DualVector
  • binary operations broadcasted between a Dual and a DualVector

As well as this, some other changes have been made:

  • Split into many files for maintainability
  • Add a more descriptive readme
  • Fix a bug with vcat
  • Organise existing unit tests as well as add more for broadcasting

@codecov
Copy link

codecov bot commented Nov 17, 2025

Codecov Report

❌ Patch coverage is 82.14286% with 20 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (main@e30580e). Learn more about missing BASE report.

Files with missing lines Patch % Lines
src/utilities.jl 50.00% 14 Missing ⚠️
src/arithmetic.jl 95.16% 3 Missing ⚠️
src/indexing.jl 72.72% 3 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main      #17   +/-   ##
=======================================
  Coverage        ?   82.14%           
=======================================
  Files           ?        5           
  Lines           ?      112           
  Branches        ?        0           
=======================================
  Hits            ?       92           
  Misses          ?       20           
  Partials        ?        0           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

end

# Define a lookup table typeof(function) => function
function_lookup = Dict{DataType, Function}()
Copy link
Owner

Choose a reason for hiding this comment

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

Is this a standard pattern? I haven't seen this before

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think so, I wasn't able to find another way in Julia to get the function from the typeof(function) provided in the frule signature. I've seen/used a similar pattern in various LeetCode problems for example

Copy link
Owner

Choose a reason for hiding this comment

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

Can you add a citation as a comment to where you saw this pattern?

I'm wary of using obscure patterns. I would look at the packages that depend on ChainRules.jl to see if there's an established pattern. But if you can't find anything, it's fine: I tend to use a "test-driven development" point of view the unit tests are more important than the details of the implementation (which can be modified freely as long as tests pass).

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I had another look at the implementation and realised the lookup table was unnecessary

@dlfivefifty dlfivefifty merged commit 7dbaa53 into dlfivefifty:main Nov 25, 2025
5 checks passed
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.

2 participants