Skip to content

Commit fe894f7

Browse files
cscherreroschulz
andauthored
Dev (#107)
* clean up `For` dispatch * simplify _logdensityof * optimize for Returns{True} case * rework basemeasure_depth * aggressive tests passing!! * drop type-level stuff * drop help * license * affero * copyright notice * merge * Drop Create Commons * cleanup after merge * update support computations * insupport(d::SuperpositionMeasure, x) * dorp ParamWeighted * insupport(d::FactoredBase, x) * export unsafe_logdensityof * call promote_type instead of promote_rule * logdensity_def for named tuple product measures * type annotation for now * debugging * drop shows * speed up mapped arrays * throw an error for `Union{}` types * MT tests passing * updates * get tests passing * MIT license for MeasureBase * bump version * cleanup * spacing * Move ConditionalMeasure to MeasureBase * add LogarithmicNumbers * export basemeasure_sequence * update superpose * fix logdensity_rel * remove FIXME (it's fixed!!) * logdensityof(d::Density, x) * simplify insupport(::Lebesgue, ::Real) * clean up * assume insupport yields Bool * change logdensity_rel fall-through to warning and return NaN * update logdensity_rel * drop old code * fix warning * export logdensity_rel * logdensity_def(μ::Dirac, ν::Dirac, x) * logdensity_def methods * drop `static` * ]add StatsFuns * Fixing up superposition * [compat] entries * trying to speed things up * bugfixes * logdensity_rel tests * logdensity_rel tests * drop qualifier, and add a test * more tests * type constraint in "logdensityof(μ::AbstractMeasure, x)" (was piracy, oops) * add some docs * docs * docs * typo * moar speed * don't export Test * some more updates * logdensity_rel for products * `kleisli` docs * update instance_type * instance_type => Core.Typeof * `powermeasure` bug fix * fix logdensity_rel bug * get `commonbase` to take x type into account * test powers * commonbase docstring * deprecate instance_type * avoid breakage * switch || terms * @ifelse macro * simplify logdensity_rel * give up on this @ifelse business * bump version * working on likelihoods * update likelihood * powerweightedmeasure * powerweighted update * more powerweighted methods * bugfix * dropFactoredBase * drop FactoredBase * (::ProductMeasure) | constraint * update conditional measure * update Dirac * move conditional.jl down in the `include`s * Kleisli => TransitionKernel * simplify logdensity_def(::PowerMeasure, x) * rename kleisli.jl to kernel.jl * update Dirac tests * update Half * get tests passing * update kernel * Update Project.toml * no call-site inlining * restrict single-arg `kernel` to <:ParameterizedMeasure * export log_likelihood_ratio * Drop DensityKind(::Likelihood), at least for now * isfinite(x) instead of x>-Inf * add `condition` constructor * EOF newline * simplify logdensity_def for power measures * finishing up * updates * kernel stuff * kernel stuff * update showe methods * ass a TODO * use `dot` instead of `sum` * drop old code * typo * formatting * cleanup * kernel updates * uncomment * bugfix * drop old code * pretty printing * exports, cleanup * drop old for.jl * Make DensityKind(::AbstractLikelihood) = IsDensity() * update Compat version * Make likelihoods work with Distributions * _map(f, x::MappedArrays.ReadonlyMappedArray) * export productmeasure * AbstractMeasure(::AbstractMeasure) * fixedrng * StdNormal * add SpecialFunctions * no need to qualify * update basemeasure * include stdnormal * include fixedrng * update tests * using SpecialFunctions * fixing transport_def * transport_def bugfix * StdMeasure(::typeof(randn)) * checked_arg for LebesgueMeasure * NoTransformOrigin => NoTransportOrigin * transport interface for pushforwards * transporting pushforwards * Use LebesgueMeasure for basemeasure * updates * make testvalue fall back on FixedRNG approach * un-break testvalue * CI for Juila 1.8 * fixes * `rand` on a pushforward calls rand on its parent * LebesgueMeasure => LebesgueBase CountingMeasure => CountingBase * tests passing! * change `invoke` type * Change `test_interface` to check for 2-arg testvalue * manually-specifed inverses * more pushfwd stuff * A little less wrong * add mass interface * pullback * mass interface * working on mass interface * add some `massof` methods * Maybe <:Number is better for invalidations? * float instead of Int * logmassof * transports for proxies * drop latent-joint.jl * drop exports * Drop `logmassof` for now * reorganize Lebesgue measure * IntervalSets * proxy(::Lebesgue{MeasureBase.RealNumbers}) = LebesgueBase() * calling a "useproxy" measure calls its proxy * StdUniform()(s::Interval) * typo * (m::AbstractMeasure)(s::Interval) * bugfix * comment * IntervalSets version constraint * update dynamic_basemeasure_depth * format * Calling a measure calls `massof` * work on massof * AbstractSuperpositionMeasure * fix typo * typo * format * docstrings * remove massof(::PowerWeightedMeasure) method * make `massof` better * update testvalue * formatting * update _massof * Update transports for weighted measures * add chain rules * invariant mass under transport * typo * bugfix * hasmethod => Tricks.static_hasmethod * `massof` methods * roll back tranports for WeightedMeasure * Improve transport implementation and add product support (#97) * Improve default transport implementation Increases type stability. * Rename NoTransformOrigin to NoTransportOrigin * Add rrule for _origin_depth * Fix ambiguities when forwarding NoTransportOrigin and NoTransportOrigin * Define getdof for product measures * Generalize test_transport to tuple-valued measures * Implement transport for tuple-based products Co-authored-by: Chad Scherrer <[email protected]> * `@useproxy` delegates `massof` * drop CI for nightly * callable densities (#85) * callable densities * separate `Density` and `LogDensity`, etc * bugfix * move some code around * format * updates * working on densities * update CI * bugfix * formatting * reorg * fix typos * Drop LogDensityMeasure and refactor * docstring * inner type constructor with assertion * type parameters * 2-arg density_rel and logdensity_rel * oops * properties * typo * fix ambiguity * bugfix * bugfix * updates * drop densityof and logdensityof for AbstractDensity * updates * update tests * update * formatting * bad calls throw errors * drop CI for nightly * Pushfwd-inverses (#98) * use InverseFunctions.setinverse * bug fixes * bugfix * bugfix * pushfwd of a pushfwd * format * drop old comment * drop CI for nightly * working on pushfwd * bugfix * inverse(f) => ν.finv * separate logdensity functions from transport API * format * don't unwrap FunctionWithInverse * drop redundant method * leave logdensityof alone, instead write unsafe_logdensityof * more tests * more work on tests * tests * tests * still messing with tests * tests passing * small edits * formatting * add some more failing tests * add atol to isapprox in test * getdof(μ::PushforwardMeasure) = getdof(transport_origin(μ)) * update atol * small fix * drop ((-) ∘ log1p ∘ (-), StdUniform(), StdExponential()) * remove duplicate method * remove duplicate `include` * simplify getdof(::PushforwardMeasure) * Stieltjes measure function (#100) * smf * more smf stuff * transport_to * Lebesgue smf * smf for std measures * format * transport_to * oops * smfinv * bugfix * more fixes * minor refactoring * formatting * change x to p * bugfix * smfinv(::StdLogistic, p) * add NoSMF and NoSMFInverse * roll back some changes * transport_def methods * formatting * another rollback * make transport_def depend on smf(inv) * update smf and transports for ::Half * change `include` order * test_smf * more tests * tests * add tests * formatting * Drop unneeded type parameters * smfinv => invsmf * add some inverses * Base.Fix1 versions * some more methods * drop redundant `transport_def`s * update `pushfwd` * change name * add type * formatting * fix docstring * depend on FunctinoChains * Use fchain * simplify transport_def for StdLogistic * simplify transport_def for StdNormal * drop redundant method * update test_interface * useproxy for smf * update test_smf * bump version Co-authored-by: Oliver Schulz <[email protected]>
1 parent f00ba92 commit fe894f7

File tree

3 files changed

+32
-24
lines changed

3 files changed

+32
-24
lines changed

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name = "MeasureBase"
22
uuid = "fa1605e6-acd5-459c-a1e6-7e635759db14"
33
authors = ["Chad Scherrer <[email protected]> and contributors"]
4-
version = "0.14.1"
4+
version = "0.14.2"
55

66
[deps]
77
ChainRulesCore = "d360d2e6-b24c-11e9-a2a3-2a2ae2dbcce4"

src/interface.jl

Lines changed: 28 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,10 @@ using Test
2727

2828
function dynamic_basemeasure_depth::M) where {M}
2929
if static_hasmethod(proxy, Tuple{M})
30-
return dynamic_basemeasure_depth(proxy(μ))
30+
π = proxy(μ)
31+
if static_hasmethod(basemeasure, Tuple{typeof(π)})
32+
basemeasure(π) == basemeasure(μ) && return dynamic_basemeasure_depth(π)
33+
end
3134
end
3235
β = basemeasure(μ)
3336
depth = 0
@@ -104,28 +107,30 @@ function test_transport(ν, μ)
104107
end
105108

106109
function test_smf(μ, n = 100)
107-
# Get `n` sorted uniforms in O(n) time
108-
p = rand(n)
109-
p .+= 0:n-1
110-
p .*= inv(n)
111-
112-
F(x) = smf(μ, x)
113-
Finv(p) = invsmf(μ, p)
114-
115-
@assert issorted(p)
116-
x = invsmf.(μ, p)
117-
@test issorted(x)
118-
@test all(insupport(μ), x)
119-
120-
@test all((Finv F).(x) .≈ x)
121-
122-
for j in 1:n
123-
a = rand()
124-
b = rand()
125-
a, b = minmax(a, b)
126-
x = Finv(a)
127-
y = Finv(b)
128-
@test μ(Interval{:open,:closed}(x, y)) (F(y) - F(x))
110+
@testset "smf()" begin
111+
# Get `n` sorted uniforms in O(n) time
112+
p = rand(n)
113+
p .+= 0:n-1
114+
p .*= inv(n)
115+
116+
F(x) = smf(μ, x)
117+
Finv(p) = invsmf(μ, p)
118+
119+
@assert issorted(p)
120+
x = invsmf.(μ, p)
121+
@test issorted(x)
122+
@test all(insupport(μ), x)
123+
124+
@test all((Finv F).(x) .≈ x)
125+
126+
for j in 1:n
127+
a = rand()
128+
b = rand()
129+
a, b = minmax(a, b)
130+
x = Finv(a)
131+
y = Finv(b)
132+
@test μ(Interval{:open,:closed}(x, y)) (F(y) - F(x))
133+
end
129134
end
130135
end
131136

src/proxies.jl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ macro useproxy(M)
2626

2727
@inline $MeasureBase.massof::$M) = massof(proxy(μ))
2828
@inline $MeasureBase.massof::$M, s) = massof(proxy(μ), s)
29+
30+
@inline $MeasureBase.smf::$M, x) = smf(proxy(μ), x)
31+
@inline $MeasureBase.invsmf::$M, x) = invsmf(proxy(μ), x)
2932
::$M)(s) = proxy(μ)(s)
3033
end
3134
end

0 commit comments

Comments
 (0)