Development workflow for Bijectors.jl - Julia package for probability distribution transformations and normalizing flows used in Turing.jl
Development workflow and guidelines for Bijectors.jl, a Julia package implementing normalizing flows and constrained random variable transformations for probability distributions.
Bijectors.jl provides an interface for transforming probability distributions from Distributions.jl, implementing many transformations needed for probabilistic programming. It is heavily used in the Turing.jl probabilistic programming language.
Before starting development, install dependencies:
```bash
julia --project=. -e "using Pkg; Pkg.instantiate()"
```
Verify package loads correctly:
```bash
julia --project=. -e "using Bijectors; println(\"Package loaded successfully\")"
```
**IMPORTANT**: Installation takes approximately 30 seconds. Never cancel this process.
#### Interface Tests (Core Functionality)
Run interface tests to verify core functionality:
```bash
julia --project=. -e "ENV[\"GROUP\"] = \"Interface\"; using Pkg; Pkg.test()"
```
#### Automatic Differentiation Tests
Test specific AD backend:
```bash
julia --project=. -e "ENV[\"GROUP\"] = \"AD\"; ENV[\"AD\"] = \"ForwardDiff\"; using Pkg; Pkg.test()"
```
#### Full Test Suite
Run all tests:
```bash
julia --project=. -e "using Pkg; Pkg.test()"
```
Install formatter (one-time):
```bash
julia --project=. -e "using Pkg; Pkg.add(\"JuliaFormatter\")"
```
Format code before committing:
```bash
julia --project=. -e "using JuliaFormatter; format(\".\")"
```
Generate documentation:
```bash
julia --project=docs -e "using Pkg; Pkg.develop(PackageSpec(path=pwd())); Pkg.instantiate(); include(\"docs/make.jl\")"
```
After making changes, always test basic functionality:
```julia
using Bijectors, Distributions
d = LogNormal()
b = bijector(d)
x = 1.0
y = b(x) # Should return 0.0
x_reconstructed = inverse(b)(y) # Should return 1.0
logjac = logabsdetjac(b, x)
z, logabsdet = with_logabsdet_jacobian(b, x)
```
Before committing changes:
1. **Run Interface tests**: Required for all changes
2. **Run code formatter**: Ensure consistent style
3. **Test basic functionality**: Run validation scenarios above
4. **Test AD changes**: If modifying AD-related code, run specific AD backend tests
Key directories and files:
```
src/
├── Bijectors.jl # Main module
├── interface.jl # Core interface definitions
├── chainrules.jl # AD integration
└── bijectors/ # Individual bijector implementations
test/
├── runtests.jl # Main test runner
├── ad/ # AD-specific tests
└── bijectors/ # Bijector-specific tests
docs/ # Documentation
ext/ # Package extensions for AD backends
```
The repository uses GitHub Actions for:
```julia
using Bijectors, Distributions
d = LogNormal(0, 1)
b = bijector(d)
x = 0.5
y = b(x)
x_back = inverse(b)(y)
logdet = logabsdetjac(b, x)
```
```julia
struct MyBijector <: Bijector end
(b::MyBijector)(x) = exp(x)
inverse(b::MyBijector) = InverseBijector(b)
logabsdetjac(b::MyBijector, x) = x
b = MyBijector()
@assert b(0.0) ≈ 1.0
@assert inverse(b)(1.0) ≈ 0.0
```
Leave a review
No reviews yet. Be the first to review this skill!
# Download SKILL.md from killerskills.ai/api/skills/bijectorsjl-development/raw