Skip to content

Feature: support modf #304

Description

@bdrhill

Summary

modf fails with MissingPrimalError because it internally calls isinf which requires primal values.

MWE

using SparseConnectivityTracer

jacobian_sparsity(x -> first.(modf.(x)), rand(2), TracerSparsityDetector())
# ERROR: MissingPrimalError(isinf, GradientTracer{Int64, BitSet}(...))

Root cause

Julia's modf implementation calls isinf internally. Since isinf is a predicate that returns Bool, it needs primal values to evaluate.

Expected behavior

modf(x) returns (fractional_part, integer_part). Both parts depend on x, so the sparsity pattern should show dependencies.

Workaround

Use TracerLocalSparsityDetector (untested - may also fail).

Metadata

Metadata

Assignees

No one assigned

    Labels

    agent 🤖Agentically generated issuenew overloadsA new method on tracers is required by a user.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions