Skip to content

Commit

Permalink
Site appearance changes, new masthead border, blog groundwork.
Browse files Browse the repository at this point in the history
  • Loading branch information
cpfiffer committed Jan 17, 2019
1 parent c09aeb2 commit 8a55ff8
Show file tree
Hide file tree
Showing 14 changed files with 303 additions and 85 deletions.
4 changes: 2 additions & 2 deletions docs/site/_data/navigation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ main:
# - title: "About"
# url: /about/
#
# - title: "News"
# url: /news/
# - title: "Blog"
# url: /blog/

- title: "GitHub"
url: https://github.com/TuringLang/Turing.jl
Expand Down
17 changes: 1 addition & 16 deletions docs/site/_includes/footer.html
Original file line number Diff line number Diff line change
@@ -1,17 +1,2 @@
<div class="page__footer-follow">
<ul class="social-icons">
{% if site.data.ui-text[site.locale].follow_label %}
<li><strong>{{ site.data.ui-text[site.locale].follow_label }}</strong></li>
{% endif %}

{% if site.footer.links %}
{% for link in site.footer.links %}
{% if link.label and link.url %}
<li><a href="{{ link.url }}"><i class="{{ link.icon | default: 'fas fa-link' }}" aria-hidden="true"></i> {{ link.label }}</a></li>
{% endif %}
{% endfor %}
{% endif %}
</ul>
</div>

<div class="page__footer-copyright">&copy; {{ site.time | date: '%Y' }} {{ site.name | default: site.title }}. {{ site.data.ui-text[site.locale].powered_by | default: "Powered by" }} <a href="https://jekyllrb.com" rel="nofollow">Jekyll</a> &amp; <a href="https://mademistakes.com/work/minimal-mistakes-jekyll-theme/" rel="nofollow">Minimal Mistakes</a>.</div>
<div class="page__footer-copyright">&copy; {{ site.time | date: '%Y' }} {{ site.name | default: site.title }}
3 changes: 2 additions & 1 deletion docs/site/_includes/masthead.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
<div class="masthead__inner-wrap">
<div class="masthead__menu">
<nav id="site-nav" class="greedy-nav">
<a class="site-title" href="{{ '/' | relative_url }}"><img src="{{site.baseurl}}/assets/turing-logo.svg" width=50>{{ site.title }} </a>
<a class="site-title" href="{{ '/' | relative_url }}">{{ site.title }} </a>
<!-- {{ site.title }} -->
<ul class="visible-links">
{%- for link in site.data.navigation.main -%}
{%- if link.url contains '://' -%}
Expand Down
11 changes: 8 additions & 3 deletions docs/site/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,12 @@
<body class="layout--{{ page.layout | default: layout.layout }}{% if page.classes or layout.classes %}{{ page.classes | default: layout.classes | join: ' ' | prepend: ' ' }}{% endif %}">

{% include browser-upgrade.html %}
{% include masthead.html %}

{% if page.hide_masthead %}
<!-- -->
{% else %}
{% include masthead.html %}
{% endif %}

<div class="initial-content">
{{ content }}
Expand All @@ -32,11 +37,11 @@
<div class="page__footer">
<footer>
{% include footer/custom.html %}
{% include footer.html %}
<!-- {% include footer.html %} -->
</footer>
</div>

{% include scripts.html %}

</body>
</html>
</html>
5 changes: 5 additions & 0 deletions docs/site/_posts/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Posts
permalink: /blog/
toc: false
---
6 changes: 3 additions & 3 deletions docs/site/_sass/minimal-mistakes/_footer.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

.page__footer {
@include clearfix;
float: left;
margin-left: 0;
margin-right: 0;
width: 100%;
Expand All @@ -20,7 +19,7 @@
animation: $intro-transition;
-webkit-animation-delay: 0.45s;
animation-delay: 0.45s;
background-color: $footer-background-color;
background-color: $background-color;

footer {
@include clearfix;
Expand All @@ -29,7 +28,8 @@
margin-top: 2em;
max-width: 100%;
padding: 0 1em 2em;

text-align: center;

@include breakpoint($x-large) {
max-width: $x-large;
}
Expand Down
7 changes: 6 additions & 1 deletion docs/site/_sass/minimal-mistakes/_masthead.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,17 @@

.masthead {
position: relative;
border-bottom: 1px solid $border-color;
// border: 20px solid;
// border-bottom: 1px solid $border-color;
-webkit-animation: $intro-transition;
animation: $intro-transition;
-webkit-animation-delay: 0.15s;
animation-delay: 0.15s;
z-index: 20;
background-image: url(/assets/turing-logo-border.svg);
background-position: left;
background-size: cover;
background-repeat: no-repeat;

&__inner-wrap {
@include clearfix;
Expand Down
3 changes: 2 additions & 1 deletion docs/site/_sass/minimal-mistakes/_navigation.scss
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@
-ms-flex-align: center;
align-items: center;
min-height: $nav-height;
background: $background-color;
// background: $background-color;
padding-left: 5em;

a {
display: block;
Expand Down
16 changes: 13 additions & 3 deletions docs/site/_sass/minimal-mistakes/_page.scss
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,8 @@
&--overlay {
position: relative;
margin-bottom: 2em;
padding-top: 4em;
padding-bottom: 4em;
padding-top: 1%;
padding-bottom: 1%;
@include clearfix;
background-size: 130% 40%;
background-repeat: no-repeat;
Expand All @@ -153,12 +153,22 @@

@include breakpoint($large) {
background-size: 125% 90%;
padding-left: 9em;
padding-right: 9em;
padding-top: 3em;
padding-bottom: 1em;
}

.wrapper {
padding-left: 1em;
padding-right: 1em;
text-align: right;
display: flex;
flex-direction: column;
align-items: end;

@include breakpoint($large) {
padding-left: 50%;
}

@include breakpoint($x-large) {
max-width: $x-large;
Expand Down
5 changes: 5 additions & 0 deletions docs/src/_posts/index.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
title: Posts
permalink: /blog/
toc: false
---
91 changes: 44 additions & 47 deletions docs/src/assets/3dplot.jl
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
using Plots
using StatPlots
using Turing
using ORCA
using Bijectors
using Random

Random.seed!(0)

gr()

# Define the simple gdemo model.
# Define a strange model.
@model gdemo(x, y) = begin
s ~ InverseGamma(2,3)
m ~ Normal(0,sqrt(s))
Expand All @@ -29,55 +26,55 @@ vi = Turing.VarInfo()
model(vi, Turing.SampleFromPrior())
vi.flags["trans"] = [true, false]

# Noise distribution.
noise = Normal(0,15)

# Define a function to optimize.
function evaluate(m1, m2)
vi.vals .= [m1, m2]
model(vi, Turing.SampleFromPrior())
-vi.logp
end

# Sample
smodel = gdemo(x, y)
# c = sample(smodel, HMC(10000, 0.01, 7))
c = sample(smodel, NUTS(1000, 1.0))
# c = sample(smodel, MH(1000))

# Extract values, plot sampler path.
ss = link.(Ref(InverseGamma(2, 3)), c[:s])
ms = c[:m]
lps = c[:lp]

# How many surface points to sample.
granularity = 500

# Range start/stop points.
spread = 0
σ_start = minimum(ss) - spread * std(ss);
σ_stop = maximum(ss) + spread * std(ss);
μ_start = minimum(ms) - spread * std(ms);
μ_stop = maximum(ms) + spread * std(ms);

σ_rng = collect(range(σ_start, stop=σ_stop, length=granularity))
μ_rng = collect(range(μ_start, stop=μ_stop, length=granularity))

surface(σ_rng, μ_rng, evaluate,
camera=(25, 65),
ticks=nothing,
colorbar=false,
color=:inferno)

line_range = 1:length(ms)

scatter3d!(ss[line_range], ms[line_range], -lps[line_range],
color =:viridis, zcolor=collect(line_range),
legend=false, colorbar=false,
m=(2, 1, Plots.stroke(0)))
function plot_sampler(chain)
# Extract values from chain.
ss = link.(Ref(InverseGamma(2, 3)), chain[:s])
ms = chain[:m]
lps = chain[:lp]

# How many surface points to sample.
granularity = 500

# Range start/stop points.
spread = 0.5
σ_start = minimum(ss) - spread * std(ss); σ_stop = maximum(ss) + spread * std(ss);
μ_start = minimum(ms) - spread * std(ms); μ_stop = maximum(ms) + spread * std(ms);
σ_rng = collect(range(σ_start, stop=σ_stop, length=granularity))
μ_rng = collect(range(μ_start, stop=μ_stop, length=granularity))

# Make surface plot.
p = surface(σ_rng, μ_rng, evaluate,
camera=(25, 65),
ticks=nothing,
colorbar=false,
color=:inferno)

line_range = 1:length(ms)

# Add sampler plot.
# scatter3d!(p, ss[line_range], ms[line_range], -lps[line_range],
# color =:viridis, zcolor=collect(line_range),
# legend=false, colorbar=false,
# m=(2, 1, Plots.stroke(0)))

plot3d!(ss[line_range], ms[line_range], -lps[line_range],
lc =:viridis, line_z=collect(line_range),
legend=false, colorbar=false, alpha=0.5)

# Plots.svg(joinpath(@__DIR__, "sampler")
return p
end

# plot3d!(ss[line_range], ms[line_range], -lps[line_range],
# lc =:viridis, line_z=collect(line_range),
# legend=false, colorbar=false, alpha=0.5)

Plots.svg(joinpath(@__DIR__, "sampler")
# Sample
smodel = gdemo(x, y)
# c = sample(smodel, NUTS(1000, 1.0))
c = sample(smodel, MH(1000))
plot_sampler(c)
Loading

0 comments on commit 8a55ff8

Please sign in to comment.