vignettes/articles/simple_example_using_migration_and_fst.Rmd
simple_example_using_migration_and_fst.Rmd
library(slimr)
#> Welcome to the slimr package for forward population genetics simulation in SLiM. For more information on SLiM please visit https://messerlab.org/slim/ .
#>
#> Attaching package: 'slimr'
#> The following object is masked from 'package:methods':
#>
#> initialize
#> The following object is masked from 'package:base':
#>
#> interaction
library(adegenet)
#> Loading required package: ade4
#>
#> /// adegenet 2.1.10 is loaded ////////////
#>
#> > overview: '?adegenet'
#> > tutorials/doc/questions: 'adegenetWeb()'
#> > bug reports/feature requests: adegenetIssues()
library(dartR)
#> Loading required package: ggplot2
#> Loading required package: dplyr
#>
#> Attaching package: 'dplyr'
#> The following object is masked from 'package:slimr':
#>
#> first
#> The following objects are masked from 'package:stats':
#>
#> filter, lag
#> The following objects are masked from 'package:base':
#>
#> intersect, setdiff, setequal, union
#> Loading required package: dartR.data
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
initialize() {
initializeMutationRate(1e-7);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
}
1 {
for (i in 1:3)
sim.addSubpop(i, 1000);
subpops = sim.subpopulations;
lines = readFile("~/Desktop/migration.csv");
lines = lines[substr(lines, 0, 1) != "//"];
for (line in lines)
{
fields = strsplit(line, ",");
i = asInteger(fields[0]);
j = asInteger(fields[1]);
m = asFloat(fields[2]);
if (i != j)
{
p_i = subpops[subpops.id == i];
p_j = subpops[subpops.id == j];
p_j.setMigrationRates(p_i, m);
}
}
}
10000 late() { sim.outputFull(); }
slim_script(
slim_block(initialize(), {
initializeMutationRate(1e-7);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
}),
slim_block(1, {
for (i in 1:3) {
sim.addSubpop(i, 1000);
}
subpops = sim.subpopulations;
lines = readFile("~/Desktop/migration.csv");
lines = lines[substr(lines, 0, 1) != "//"];
for (line in lines) {
fields = strsplit(line, ",");
i = asInteger(fields[0]);
j = asInteger(fields[1]);
m = asFloat(fields[2]);
if (i != j) {
p_i = subpops[subpops.id == i];
p_j = subpops[subpops.id == j];
p_j.setMigrationRates(p_i, m);
}
}
}),
slim_block(10000, late(), {
sim.outputFull();
})
) -> script_1
script_1
#> <slimr_script[3]>
#> block_init:initialize() {
#> initializeMutationRate(1e-07);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> for (i in 1:3) {
#> sim.addSubpop(i, 1000);
#> }
#> subpops = sim.subpopulations;
#> lines = readFile("~/Desktop/migration.csv");
#> lines = lines[substr(lines, 0, 1) != "//"];
#> for (line in lines) {
#> fields = strsplit(line, ",");
#> i = asInteger(fields[0]);
#> j = asInteger(fields[1]);
#> m = asFloat(fields[2]);
#> if (i != j) {
#> p_i = subpops[subpops.id == i];
#> p_j = subpops[subpops.id == j];
#> p_j.setMigrationRates(p_i, m);
#> }
#> }
#> }
#>
#> block_3:10000 late() {
#> sim.outputFull();
#> }
disp_mat <- matrix(c(1, 1, 0.78,
1, 2, 0.10,
1, 3, 0.12,
2, 1, 0.01,
2, 2, 0.96,
2, 3, 0.03,
3, 1, 0.33,
3, 2, 0.17,
3, 3, 0.5),
ncol = 3, byrow = TRUE)
slim_script(
slim_block(initialize(), {
setSeed(123456);
initializeMutationRate(2e-6);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
}),
slim_block(1, {
for (i in 1:3) {
sim.addSubpop(i, 100);
}
subpops = sim.subpopulations;
disp_mat = slimr_inline(disp_mat)
for (line in seqLen(nrow(disp_mat))) {
i = asInteger(disp_mat[line, 0]);
j = asInteger(disp_mat[line, 1]);
m = asFloat(disp_mat[line, 2]);
if (i != j) {
p_i = subpops[subpops.id == i];
p_j = subpops[subpops.id == j];
p_j.setMigrationRates(p_i, m);
}
}
}),
slim_block(100000, late(), {
slimr_output(sim.outputFull(), "final_output");
})
) -> script_2
script_2
#> <slimr_script[3]>
#> block_init:initialize() {
#> setSeed(123456);
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> for (i in 1:3) {
#> sim.addSubpop(i, 100);
#> }
#> subpops = sim.subpopulations;
#> disp_mat = {. = matrix(c(1, 1, 1, 2, 2, 2, 3, 3, 3, 1, ...), nrow = 9, ncol = 3)}
#> for (line in seqLen(nrow(disp_mat))) {
#> i = asInteger(disp_mat[line, 0]);
#> j = asInteger(disp_mat[line, 1]);
#> m = asFloat(disp_mat[line, 2]);
#> if (i != j) {
#> p_i = subpops[subpops.id == i];
#> p_j = subpops[subpops.id == j];
#> p_j.setMigrationRates(p_i, m);
#> }
#> }
#> }
#>
#> block_3:1e+05 late() {
#> {sim.outputFull() -> final_output}
#> }
We can see that the whole matrix has been embedded in the SLiM script
by running as_slim_text
on this slimr_script
object. This is the script that will actually be run by SLiM.
cat(as_slim_text(script_2))
#> initialize() {
#> setSeed(123456);
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> 1 early() {
#> for (i in 1:3) {
#> sim.addSubpop(i, 100);
#> }
#> subpops = sim.subpopulations;
#> disp_mat = matrix(c(1, 1, 1, 2, 2, 2, 3, 3, 3, 1, 2, 3, 1, 2, 3, 1, 2, 3, 0.78, 0.1, 0.12, 0.01, 0.96, 0.03, 0.33, 0.17, 0.5), nrow = 9, ncol = 3);
#> for (line in seqLen(nrow(disp_mat))) {
#> i = asInteger(disp_mat[line, 0]);
#> j = asInteger(disp_mat[line, 1]);
#> m = asFloat(disp_mat[line, 2]);
#> if (i != j) {
#> p_i = subpops[subpops.id == i];
#> p_j = subpops[subpops.id == j];
#> p_j.setMigrationRates(p_i, m);
#> }
#> }
#> }
#>
#> 1e+05 late() {
#> if (community.tick%1 == 0) {
#> cat("\n<slimr_out:start>\n" + paste(community.tick) + ",'" + "final_output" + "','" + "sim.outputFull()" + "','" + "slim_output','");
#> sim.outputFull();
#> cat("'\n<slimr_out:end>\n");
#> }
#> }
Now let’s see if we can run it.
results <- slim_run(script_2, throw_error = TRUE)
#>
#>
#> Simulation finished with exit status: 0
#>
#> Success!
Looks like it worked. We can get the resulting genomic data from the
returned object and convert it into a genlight object using the
slim_extract_genlight()
function. Then we can plot the
results.
library(dartR)
inds <- slim_extract_genlight(results, "final_output")
ploidy(inds) <- 2
plot(inds)
Note that the SNPs are ordered by their mutation id, which should
roughly correspond to their order of origination, so the leftmost
mutations are the oldest, the rightmost the youngest. Using a genlight
object we can calculate a lot of population genetics metrics easily
using the package dartR
. Let’s calculate Fst for
example.
p_fst <- dartR::gl.fst.pop(inds, nboots = 1, verbose = 0)
p_fst
#> p2 p3 p1
#> p2 NA NA NA
#> p3 0.0005873432 NA NA
#> p1 0.0139928734 0.00888913 NA
So generally those Fst values are low, which we would expect since our populations are not experiencing differential selection and the effects of drift are counteracted by migration between the populations. Nevertheless the pairwise Fst’s measured here are inversely proportional to the overall strength of migration between the population in our simulation. We can see this like this:
## convert migration rates into pairwise matrix using igraph
library(igraph)
#>
#> Attaching package: 'igraph'
#> The following objects are masked from 'package:future':
#>
#> %->%, %<-%
#> The following objects are masked from 'package:purrr':
#>
#> compose, simplify
#> The following objects are masked from 'package:dplyr':
#>
#> as_data_frame, groups, union
#> The following objects are masked from 'package:stats':
#>
#> decompose, spectrum
#> The following object is masked from 'package:base':
#>
#> union
overall_mig_rates <- disp_mat %>%
as.data.frame() %>%
igraph::graph_from_data_frame() %>%
igraph::as.undirected(mode = "collapse", edge.attr.comb = "mean") %>%
igraph::as_adjacency_matrix(type = "lower", attr = "V3", sparse = FALSE)
diag(overall_mig_rates) <- NA
overall_mig_rates[upper.tri(overall_mig_rates)] <- NA
p_fst
#> p2 p3 p1
#> p2 NA NA NA
#> p3 0.0005873432 NA NA
#> p1 0.0139928734 0.00888913 NA
overall_mig_rates
#> 1 2 3
#> 1 NA NA NA
#> 2 0.055 NA NA
#> 3 0.225 0.1 NA
plot(as.vector(overall_mig_rates), as.vector(p_fst))
We can see generally the populations with the lowest migration rates
also has the highest pairwise Fst, suggesting population with low
migration have differentiated the most, which makes sense. In this
particular example, the Fst seems to reach a minimum soon after, such
that the two higher migration pairs don’t differ much in their pairwise
Fsts. This could be a result of stochasticity. if we really want to know
whether migration rate effects Fst under a simple neutral model of
evolution, we should run many simulations and look at the average
effect. slimr
makes this easy to do using templating. Let’s
simplify this model a little to just look at two populations at a time,
and then set it up to run many times with different migration rates
between them. Ww can also vary population size as it seems like this
should be an important mediator of any effects, given it will effect the
relative strength of drift in the populations.
slim_script(
slim_block(initialize(), {
initializeMutationRate(2e-6);
initializeMutationType("m1", 0.5, "f", 0.0);
initializeGenomicElementType("g1", m1, 1.0);
initializeGenomicElement(g1, 0, 99999);
initializeRecombinationRate(1e-8);
}),
slim_block(1, {
sim.addSubpop("p1", slimr_template("pop_size", default = 100));
sim.addSubpop("p2", ..pop_size..);
p1.setMigrationRates(p2, slimr_template("m", default = 0.1));
p2.setMigrationRates(p1, ..m..);
}),
slim_block(10000, late(), {
slimr_output(sim.outputFull(), "final_output");
})
) -> script_3
script_3
#> <slimr_script[3]>
#> block_init:initialize() {
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> sim.addSubpop("p1", ..pop_size..);
#> sim.addSubpop("p2", ..pop_size..);
#> p1.setMigrationRates(p2, ..m..);
#> p2.setMigrationRates(p1, ..m..);
#> }
#>
#> block_3:10000 late() {
#> {sim.outputFull() -> final_output}
#> }
#> This slimr_script has templating in block(s) block_2 for
#> variables pop_size and m.
So in the above script we now have a placemarker for a
pop_size
and a m
parameter. We specified this
using the slimr_template
function directly inserted into
the SLiM code. We also demonstrate a trick to reduce typing. We only
have to use the slimr_template
function once for a given
variable, subsequent references to the same variable can be specified
directly using the ..x..
notation. Now to generate a script
with the templated variables replaced with values of our choosing, we
use the slim_script_render
function. Here is an
example:
example_script <- slim_script_render(script_3, template = list(pop_size = 50, m = 0.05))
example_script
#> <slimr_script[3]>
#> block_init:initialize() {
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> sim.addSubpop("p1", 50);
#> sim.addSubpop("p2", 50);
#> p1.setMigrationRates(p2, 0.05);
#> p2.setMigrationRates(p1, 0.05);
#> }
#>
#> block_3:10000 late() {
#> {sim.outputFull() -> final_output}
#> }
We can also pass a data.frame
to
slim_script_render
which will allow us to generate many
scripts at once, let’s setup a large number of scripts to explore
different values of our two parameters.
n_reps <- 300
param_df <- data.frame(pop_size = sample(5:100, n_reps, replace = TRUE),
m = runif(n_reps, 0, 0.5))
script_list <- slim_script_render(script_3,
template = param_df)
script_list
#> <slimr_script_coll[300]>
#> <1>
#>
#> block_init:initialize() {
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> sim.addSubpop("p1", 85);
#> sim.addSubpop("p2", 85);
#> p1.setMigrationRates(p2, 0.379254172206856);
#> p2.setMigrationRates(p1, 0.379254172206856);
#> }
#>
#> block_3:10000 late() {
#> {sim.outputFull() -> final_output}
#> }
#>
#> <2>
#>
#> block_init:initialize() {
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> sim.addSubpop("p1", 41);
#> sim.addSubpop("p2", 41);
#> p1.setMigrationRates(p2, 0.26800632593222);
#> p2.setMigrationRates(p1, 0.26800632593222);
#> }
#>
#> block_3:10000 late() {
#> {sim.outputFull() -> final_output}
#> }
#>
#> <3>
#>
#> block_init:initialize() {
#> initializeMutationRate(2e-06);
#> initializeMutationType("m1", 0.5, "f", 0);
#> initializeGenomicElementType("g1", m1, 1);
#> initializeGenomicElement(g1, 0, 99999);
#> initializeRecombinationRate(1e-08);
#> }
#>
#> block_2:1 early() {
#> sim.addSubpop("p1", 37);
#> sim.addSubpop("p2", 37);
#> p1.setMigrationRates(p2, 0.0882677737390622);
#> p2.setMigrationRates(p1, 0.0882677737390622);
#> }
#>
#> block_3:10000 late() {
#> {sim.outputFull() -> final_output}
#> }
#>
#>
#> <...>
#>
#> and 297 more.
This function returns a slimr_script_coll
object, or a
slimr script collection. We can now use slim_run
on this
object, which will run every script in the collection, one after the
other, and collect the results. We can specify a
parallel = TRUE
argument to run the scripts in parallel.
slimr
uses the future
package for
parallelization. This means that the user must specify a future
plan
prior to running slim_run
which will
setup the workers to be used by slimr
. If you want to use
parallelization with slimr
, we recommend you familiarize
yourself with the future
package. If in doubt
future::plan(future::multisession)
is the most general
purpose specification which should work well on all platforms (and is
the recommended plan by future for best stability of parallelization).
You must also ensure the future
and furrr
packages are installed for this functionality to work. Let’s try running
these:
start_time <- Sys.time()
if(requireNamespace("furrr", quietly = TRUE)) {
future::plan(future::multisession)
all_results <- slim_run(script_list, parallel = TRUE, progress = TRUE, throw_error = TRUE)
}
Cool! First let’s check if all simulation completed without error:
Let’s extract all the genomic data into genlight objects so we can
easily calculate Fst. Since this might also take a little while we will
parallelize this extraction as well using furrr
(since we
already set a future
plan, and furrr
uses
future
under the hood). Just in case any simulations give
us trouble, we will wrap the extraction in try()
so that
the whole thing doesn’t fail for one error.
all_gl <- furrr::future_map(all_results,
~suppressWarnings(suppressMessages(try(slim_extract_genlight(.x, "final_output")))),
.progress = TRUE)
Any errors?
errored <- which(sapply(all_gl, function(x) class(x) == "try-error"))
errored
#> integer(0)
purrr::map(errored,
~all_results[[.x]]$output_data$data)
#> list()
We got ‘r length(errored)’ errors. Examining their data strings, we can see that they all essentially had no mutations, which is why we couldn’t construct a genlight object. Let’s just filter these out and continue with our analysis by calculating Fst.
if(length(errored) > 0) {
all_gl <- all_gl[-errored]
}
all_fsts <- furrr::future_map_dbl(all_gl,
~ {
ploidy(.x) <- 2
dartR::gl.fst.pop(.x, nboots = 1, verbose = 0)[2, 1]
},
.progress = TRUE)
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
#> Registered S3 method overwritten by 'pegas':
#> method from
#> print.amova ade4
#> Registered S3 method overwritten by 'GGally':
#> method from
#> +.gg ggplot2
#> The legacy packages maptools, rgdal, and rgeos, underpinning the sp package,
#> which was just loaded, will retire in October 2023.
#> Please refer to R-spatial evolution reports for details, especially
#> https://r-spatial.org/r/2023/05/15/evolution4.html.
#> It may be desirable to make the sf package available;
#> package maintainers should consider adding sf to Suggests:.
#> The sp package is now running under evolution status 2
#> (status 2 uses the sf package in place of rgdal)
#> Registered S3 method overwritten by 'genetics':
#> method from
#> [.haplotype pegas
#> Please note that rgdal will be retired during October 2023,
#> plan transition to sf/stars/terra functions using GDAL and PROJ
#> at your earliest convenience.
#> See https://r-spatial.org/r/2023/05/15/evolution4.html and https://github.com/r-spatial/evolution
#> rgdal: version: 1.6-7, (SVN revision 1203)
#> Geospatial Data Abstraction Library extensions to R successfully loaded
#> Loaded GDAL runtime: GDAL 3.6.2, released 2023/01/02
#> Path to GDAL shared files: C:/R/R-4.3.1/library/rgdal/gdal
#> GDAL does not use iconv for recoding strings.
#> GDAL binary built with GEOS: TRUE
#> Loaded PROJ runtime: Rel. 9.2.0, March 1st, 2023, [PJ_VERSION: 920]
#> Path to PROJ shared files: C:/R/R-4.3.1/library/rgdal/proj
#> PROJ CDN enabled: FALSE
#> Linking to sp version:2.0-0
#> To mute warnings of possible GDAL/OSR exportToProj4() degradation,
#> use options("rgdal_show_exportToProj4_warnings"="none") before loading sp or rgdal.
end_time <- Sys.time()
end_time - start_time
#> Time difference of 3.050072 mins
cat("Total Duration:", end_time - start_time)
#> Total Duration: 3.050072
Firstly, negative values of Fst are incorrect, and usually reflect numerical inaccuracy around zero, so we will set negative Fst values to zero. Then let’s look at the distribution.
all_fsts[all_fsts < 0] <- 0.0
hist(all_fsts, breaks = 100)
So how is Fst related to migration rate and population size? We can get an idea by running a simple linear model. Then we will do plots.
if(length(errored) > 0) {
param_df <- param_df[-errored, ]
}
fst_dat <- param_df %>%
dplyr::mutate(fst = all_fsts,
pop_size_st = (pop_size - mean(pop_size)) / sd(pop_size),
m_st = (m - mean(m)) / sd(m))
mod <- lm(fst ~ pop_size_st*m_st, data = fst_dat)
summary(mod)
#>
#> Call:
#> lm(formula = fst ~ pop_size_st * m_st, data = fst_dat)
#>
#> Residuals:
#> Min 1Q Median 3Q Max
#> -0.09117 -0.03810 -0.00932 0.01505 0.70214
#>
#> Coefficients:
#> Estimate Std. Error t value Pr(>|t|)
#> (Intercept) 0.029191 0.004567 6.391 6.38e-10 ***
#> pop_size_st -0.005577 0.004597 -1.213 0.226
#> m_st -0.036193 0.004599 -7.870 6.72e-14 ***
#> pop_size_st:m_st 0.005673 0.004513 1.257 0.210
#> ---
#> Signif. codes: 0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1
#>
#> Residual standard error: 0.07911 on 296 degrees of freedom
#> Multiple R-squared: 0.1775, Adjusted R-squared: 0.1692
#> F-statistic: 21.3 on 3 and 296 DF, p-value: 1.616e-12
So both migration rate
We can demonstrate the interaction by splitting our data into population size bins and plotting the migration rate relationship as separate lines for each bin.
fst_dat <- fst_dat %>%
dplyr::mutate(ps_bin = cut(pop_size, 5, ordered_result = TRUE))
ggplot(fst_dat, aes(m, fst)) +
geom_point(aes(colour = ps_bin)) +
geom_smooth(aes(colour = ps_bin, fill = ps_bin)) +
scale_x_sqrt() +
theme_minimal()


A nice Building
Door of a house
A lot of text here. Lots of text and more text and it keeps going. Need more text, look at me!


There is an example page of Notify+ plugin (version 1.0.1) by @mobaradev
Position:
Click, to show a message
or use function
NotifyPlus.addNotify(text, type, duration)
text is required
type is optional, default is 'success'; other types: 'info', 'warn', 'error'
duration is optional, default in plugin is 10s


Poker hands kata
Your job is to compare several pairs of poker hands
The cards
- A poker deck contains 52 cards
- Each card has a suit which is one of clubs (C), diamonds (D), hearts (H), or spades (S)
- Each card also has a value: 2, 3, 4, 5, 6, 7, 8, 9, 10 (T), jack (J), queen (Q), king (K), ace (A)
- The suits are unordered
- The values are ordered with 2 being the lowest and ace the highest
Hands
- High Card
- Pair
- Two Pairs
- Three of a Kind
- Straight
- Flush
- Full House
- Four of a kind
- Straight flush
Sample
Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C AH
Black: 2H 4S 4C 2D 4H White: 2S 8S AS QS 3S
Black: 2H 3D 5S 9C KD White: 2C 3H 4S 8C KH
Black: 2H 3D 5S 9C KD White: 2D 3H 5C 9S KH
Output
White wins. - with high card: Ace
White wins. - with flush
Black wins. - with high card: 9
Tie.
Dojo rules
- Try to pair with somebody new
- Try to be "perfect"
- Experiment
- Feel free to invest more time in places you often can't
Have fun!


Professionalism at its finest! Welcome to my webpage!! Please feel free to look around and learn about me.
About meI am currently an Applications Developer at UPS. I am an innovative problem-solver, technology enthusiast, and a lifelong learner. I am a collablorator and a team builder in a network of developers, engineers, and architects. My career philosophy is that opportunities are created, and never given. We must work hard to acheive what we set our minds to.
I am twenty-two years old and hold a Bachelors of Science in Computer Science with a minor in Mathematics from Indiana University Southeast as of May 2016. My career started while I was still in college as a part-time Student Web Developer at the university. It was there that I obtained a passion for web development, but still felt that I needed to learn more. After approximately a year, I moved to UPS as a co-op for eight months before moving into the Applications Development position that I currently hold.
Looking for a web developer to advance your marketing?? I am also on loan in my free time as a web developer. I am currently looking to pick up as many as 5 to 10 clients. I work quickly and utilize the breaking-edge technologies in order to ensure that your website is sleek, secure, and attracts the attention of your customers.
RésuméI write clean code and I am proud of it.
I work quickly, but don't sacrifice quality for speed.
Always reading about the latest and greatest.
I love the work I do! You will too.
Ready to start your next project with me? That's great! Give me a call or send me an email and I will get back to you as soon as possible!


Output Elements
+
sum =
0
Media Elements
Audio
Your Browser does not supports audio tag.
Video
Your Browser does not supports video tag.
Progess Elements
Progress 56%
iFrame


Item displaying allow users to configure a field that displays as dropdown items on dropdown to the end user. by
default ornamentum will set display track field as value. for dropdown selectTrackBy
attribute
usages please refer dropdown Events section.
Below example will demonstrate a sample usages of configuring displaying item(s) on dropdown.
According to the above example, displayTrackBy
field was set to productType and will be
displaying it's values on dropdown to the end user. for more details about display track by usages please refer display-track-items-usage.component.html
from the above code snippet.
To enable item displaying, provide a property name for displayTrackBy
attribute unless data will not
be displayed on dropdown.
{{demoSnippet.displayTrackBy}}


Blocks to points Ordinary Kriging interpolation - tutorial¶
Table of Contents:¶
Read areal data,
Detect and remove outliers,
Create semivariogram model,
Read point data canvas,
Build map of interpolated values,
Show map of interpolated values with choropleth map of breast cancer rates.
Level: Intermediate¶
Changelog¶
Date |
Change description |
Author |
|---|---|---|
2021-05-11 |
Refactored TheoreticalSemivariogram class |
@szymon-datalions |
2021-03-31 |
Update related to the change of semivariogram weighting. Updated cancer rates data. |
@szymon-datalions |
Introduction¶
This tutorial is based on the question of user @ikey from Discord channel of package (02/04/2021). Thank you @ikey for it!
In short:
Are we able to perform Semivariogram Regularization and Poisson Kriging if our point support represents only points without any values?
No, it’s not possible. But there is a hack which we can use - we are able to interpolate missing values from areal centroids with Ordinary and Simple Kriging just like we do it with regular points. Why is it not possible with unknown points?
The idea behind semivariogram regularization of areal aggregates is to use semivariogram of points (values). And not any points, they must reflect ongoing process. As example, in the case of epidemiology:
We have areal counts of infections divided by POPULATION over some area.
We take POPULATION blocks (points) with number of inhabitants per block and use those as a support of our map. Thus we transform choropleth map into point map, and only to the points, where someone is living ==> someone may be infected. We skip large parts of map where risk of infection is not present because no one is living there.
And we finally obtain population-at-risk map of points or smoothed choropleth map of infection risk without large visual bias where large/small areas seems to be more important.
This works when we have specific counts over area divided by other parameter (time, population, probability, volume etc.). In this scenario we can find function which links our areal counts with those underlying variables and/or processes. Without support values we are not able to perform semivariogram regularization.
What we want to achieve may be done with Ordinary Kriging (because our points are really unknown) and semivariogram regularization is not required (and not possible without any values).
In summary we will learn how to:
transform areal data into points,
detect and remove outliers from data,
create interpolated map from unknown points,
visualize and save created map.
We use:
for point canvas:
sample_data/point_data/regular_grid_points.shp
,for areal centroids: Breast cancer rates data is stored in the shapefile in folder
sample_data/areal_data/cancer_data.shp
.
This tutorial requires understanding of concepts presented in Semivariogram Estimation and Variogram Point Cloud tutorials along with Ordinary and Simple Kriging notebook and (optionally) Semivariogram Regularization tutorial.
Import packages¶
[1]:
import numpy as np
import pandas as pd
import geopandas as gpd
import matplotlib.pyplot as plt
from pyinterpolate.io_ops import prepare_areal_shapefile
from pyinterpolate.semivariance import build_variogram_point_cloud, show_variogram_cloud, remove_outliers
from pyinterpolate.semivariance import calc_semivariance_from_pt_cloud
from pyinterpolate.semivariance import TheoreticalSemivariogram
from pyinterpolate.kriging import Krige
1) Read areal data¶
[10]:
areal = '../sample_data/areal_data/cancer_data.shp'
id_col = 'FIPS'
val_col = 'rate'
dataset = prepare_areal_shapefile(areal, id_column_name=id_col, value_column_name=val_col)
dataset[0]
[10]:
array([25019,
<shapely.geometry.multipolygon.MultiPolygon object at 0x7f070c41d050>,
2132629.599151873,<PHONE_NUMBER>491967, 192.2], dtype=object)
[11]:
data_centroids = dataset[:, -3:]
data_centroids[0]
[11]:
array([2132629.599151873,<PHONE_NUMBER>491967, 192.2], dtype=object)
Clarification:¶
Prepared areal shapefile has five columns: [area id, geometry, centroid x, centroid y, value]
. We don’t need polygons’ geometry and areas’ id in the case of point kriging. Prepared array is sliced and in return we get array of centroids and their values. This is our base for modeling.
2) Detect and remove outliers¶
We check and clean data before semivariogram fit and Ordinary Kriging. Variogram Point Cloud is the best way to analyze data and detect outliers which may affect further analysis. We check and compare few different lags and step sizes and their respective point clouds. Then we will use those different number of ranges to create multiple semivariogram and Kriging models.
[12]:
# Create analysis parameters
maximum_range = 300000
number_of_lags = [4, 8, 16]
step_sizes = [maximum_range / x for x in number_of_lags]
variogram_clouds = []
for step_size in step_sizes:
variogram_cloud = build_variogram_point_cloud(data_centroids, step_size, maximum_range)
variogram_clouds.append(variogram_cloud)
[13]:
for idx, lag in enumerate(number_of_lags):
print(f'Lags per area: {lag}')
print('')
var_cloud = variogram_clouds[idx]
show_variogram_cloud(var_cloud, figsize=(12, 8))
print('\n###########\n')
Lags per area: 4
###########
Lags per area: 8
###########
Lags per area: 16
###########
[14]:
# Now remove outliers from each lag
clouds_without_outliers = [remove_outliers(x) for x in variogram_clouds]
[15]:
# And show data without outliers
for idx, lag in enumerate(number_of_lags):
print(f'Lags per area: {lag}')
print('')
var_cloud = clouds_without_outliers[idx]
show_variogram_cloud(var_cloud, figsize=(12, 8))
print('\n###########\n')
Lags per area: 4
###########
Lags per area: 8
###########
Lags per area: 16
###########
Clarification:¶
It could be not visible, but we got rid off outliers from dataset. Look into y axes of variogram clouds with and without outliers for each lag. You hopefully see that maximum values after data cleaning are two times smaller. We can test different lags now to create semivariogram models.
3. Create semivariogram model¶
Semivariogram may be fitted manually or automatically. In this case we fit it automatically - we test multiple models and it’s easier to use find_optimal_model()
method of TheoreticalSemivariogram
object.
[16]:
theoretical_semivariograms = []
for idx, cloud_model in enumerate(clouds_without_outliers):
print(f'Semivariance calculated for {number_of_lags[idx]} lag')
print('')
# Calculate experimental model
exp_model = calc_semivariance_from_pt_cloud(cloud_model)
# Assign experimental model and data to TheoreticalSemivariogram
theo_semi = TheoreticalSemivariogram(points_array=data_centroids,
empirical_semivariance=exp_model,
verbose=True)
theo_semi.find_optimal_model(weighted=False, number_of_ranges=number_of_lags[idx])
theoretical_semivariograms.append(theo_semi)
print('')
print('Model parameters:')
print('Nugget:', theo_semi.nugget)
print('Sill:', theo_semi.sill)
print('Range:', theo_semi.range)
print('')
print('#####')
Semivariance calculated for 4 lag
Model: spherical, error value: 47.46959781307264
Model: exponential, error value: 12.409730137628472
Model: linear, error value: 33.73740642254563
Chosen model: exponential, with value: 12.409730137628472.
Model parameters:
Nugget: 40.84634146341462
Sill:<PHONE_NUMBER>6056609
Range: 225000.0
#####
Semivariance calculated for 8 lag
Model: spherical, error value: 29.50306496934048
Model: exponential, error value: 18.445105479962933
Model: linear, error value: 31.969300956642797
Chosen model: exponential, with value: 18.445105479962933.
Model parameters:
Nugget: 1.6961373390557952
Sill:<PHONE_NUMBER>6056609
Range:<PHONE_NUMBER>2857142
#####
Semivariance calculated for 16 lag
Model: spherical, error value: 33.17075686586436
Model: exponential, error value: 22.57867885361459
Model: linear, error value: 36.236544305662264
Chosen model: exponential, with value of: 22.57867885361459.
Model parameters:
Nugget: 0.0
Sill:<PHONE_NUMBER>6056609
Range: 123750.0
#####
/home/szymon/miniconda3/envs/pyintpk/lib/python3.7/site-packages/numpy/core/fromnumeric.py:3335: RuntimeWarning: Mean of empty slice.
out=out, **kwargs)
/home/szymon/miniconda3/envs/pyintpk/lib/python3.7/site-packages/pyinterpolate/semivariance/semivariogram_fit/fit_semivariance.py:302: UserWarning: WARNING: linear model fitted to the experimental variogram is better than the core models!
warnings.warn(warning_msg)
Clarification:¶
Exponential model was chosen in each case. This model offers lowest error of fitting. If we look only into the error value then we may assume that the best model is for 4 lags… but when we compare different parameters of semivariogram model we see interesting things.
Nugget of four lags is large and it’s 30 cases per 100,000 inhabitants. Why is that? Model with only four lags catches large distance near the zero origin and it introduces bias. Other lags have nugget close to 0.
Range of the first model is very large compared to the areal bounds and it is a half of them. Range of 8 and 16 lags is closer to each other and more than two-three times smaller than range of 4 lags. It’s the same effect of large spacing for 4 lags.
Sill is the same because it describes variance in dataset (which is constant).
Summarizing: 4-lags model has lowest error of fit but largest nugget and range. 8- and 16-lags models have comparable nugget and range. Probably one of these models will be a better fit for Kriging.
4. Read point data canvas¶
Pyinterpolate doesn’t have function for read point data directly from shapefile (2021-02-07) but we can do it with GeoPandas package. Pyinterpolate uses GeoPandas under the hood so there is no problem with import of this package.
We read point file as the GeoDataFrame object which stores geometry column and data features as tables.
[17]:
points = '../sample_data/point_data/regular_grid_points.shp' # file with grid for analysis
gdf_pts = gpd.read_file(points)
gdf_pts.set_index('id', inplace=True)
gdf_pts.head()
[17]:
| geometry | |
|---|---|
| id | |
| 81.0 | POINT (1277277.671 441124.507) |
| 82.0 | POINT (1277277.671 431124.507) |
| 83.0 | POINT (1277277.671 421124.507) |
| 84.0 | POINT (1277277.671 411124.507) |
| 85.0 | POINT (1277277.671 401124.507) |
Now we interpolate value for each point with Kriging. We use apply()
on geometry column and create new columns of GeoDataFrame with interpolated results.
5. Build map of interpolated values¶
[18]:
# Set kriging models
def krige_point(pt, k_model, no_of_neighbors=8):
"""
Function predicts value at unknown location with 8 closest neighbors and given kriging model.
INPUT:
:param pt: (shapely Point),
:param k_model: (Krige),
:param no_of_neighbors: (int)
OUTPUT:
:return: (float)
"""
val = k_model.ordinary_kriging(unknown_location=[pt.x, pt.y], number_of_neighbours=no_of_neighbors)
return pd.Series([val[0], val[1]])
kriging_models = []
for idx, semi_model in enumerate(theoretical_semivariograms):
kriging_model = Krige(semivariogram_model=semi_model, known_points=data_centroids)
col_name = 'lags_' + str(number_of_lags[idx])
err_col_name = 'e_' + col_name
# Interpolate missing values and uncertainty
gdf_pts[[col_name, err_col_name]] = gdf_pts.geometry.apply(krige_point, args=[kriging_model])
# Append model
kriging_models.append(kriging_model)
[19]:
gdf_pts.head()
[19]:
| geometry | lags_4 | e_lags_4 | lags_8 | e_lags_8 | lags_16 | e_lags_16 | |
|---|---|---|---|---|---|---|---|
| id | |||||||
| 81.0 | POINT (1277277.671 441124.507) | 131.471425 | 6.302487 | 131.624497 | 4.819975 | 131.648728 | 4.855153 |
| 82.0 | POINT (1277277.671 431124.507) | 130.587922 | 5.862754 | 130.764126 | 4.568737 | 130.793961 | 4.606546 |
| 83.0 | POINT (1277277.671 421124.507) | 129.720084 | 5.415435 | 129.918570 | 4.211067 | 129.953698 | 4.251812 |
| 84.0 | POINT (1277277.671 411124.507) | 129.005726 | 5.557726 | 129.317708 | 4.287956 | 129.374854 | 4.328610 |
| 85.0 | POINT (1277277.671 401124.507) | 128.936991 | 5.466700 | 128.982976 | 4.266100 | 128.992189 | 4.309141 |
Clarification:¶
This is rather complicated function in which we interpolate missing values as a new columns of GeoDataFrame. Uncertainty is assigned to interpolated results for further analysis.
Now we can save our GeoDataFrame as a shapefile…
[20]:
# Save interpolation results
gdf_pts.to_file('interpolation_results_areal_to_point.shp')
or check results directly in a notebook!
6. Show map of interpolated values with choropleth map of breast cancer rates¶
[21]:
# First read areal shapefile
gdf = gpd.read_file(areal)
gdf.head()
[21]:
| rate | FIPS | rate_float | geometry | |
|---|---|---|---|---|
| 0 | 192.2 | 25019 | 192.2 | MULTIPOLYGON (((2115688.816 556471.240, 211569... |
| 1 | 166.8 | 36121 | 166.8 | POLYGON ((1419423.430 564830.379, 1419729.721 ... |
| 2 | 157.4 | 33001 | 157.4 | MULTIPOLYGON (((1937530.728 779787.978, 193751... |
| 3 | 156.7 | 25007 | 156.7 | MULTIPOLYGON (((2074073.532 539159.504, 207411... |
| 4 | 155.3 | 25001 | 155.3 | MULTIPOLYGON (((2095343.207 637424.961, 209528... |
[22]:
# Now compare results to choropleth maps
fs = (6, 8)
for lag in number_of_lags:
print('Lag', lag)
col_name = 'lags_' + str(lag)
plt.figure()
base = gdf.plot(figsize=fs, column='rate', cmap='Spectral_r', legend=True)
gdf_pts.plot(ax=base, column=col_name, cmap='Spectral_r')
plt.show()
print('######')
Lag 4
<Figure size 432x288 with 0 Axes>
######
Lag 8
<Figure size 432x288 with 0 Axes>
######
Lag 16
<Figure size 432x288 with 0 Axes>
######
Clarification:¶
Visual inspection shows that:
Interpolated results are more smoothed over area and in the most part of a map they are similar to the rate observed in specific county.
Difference between interpolated points is not visible. Is there any?
To answer second question we calculate the Mean Absolute Difference between each lag’s interpolated results.
[23]:
for lag1 in number_of_lags:
print('LAG:', lag1)
col_name1 = 'lags_' + str(lag1)
for lag2 in number_of_lags:
if lag1 == lag2:
pass
else:
col_name2 = 'lags_' + str(lag2)
mad = gdf_pts[col_name1] - gdf_pts[col_name2]
mad = np.abs(np.mean(mad))
print('')
print(f'Mean Absolute Difference between lag {lag1} and lag {lag2} is {mad:.6f}')
print('')
LAG: 4
Mean Absolute Difference between lag 4 and lag 8 is 0.043591
Mean Absolute Difference between lag 4 and lag 16 is 0.052167
LAG: 8
Mean Absolute Difference between lag 8 and lag 4 is 0.043591
Mean Absolute Difference between lag 8 and lag 16 is 0.008576
LAG: 16
Mean Absolute Difference between lag 16 and lag 4 is 0.052167
Mean Absolute Difference between lag 16 and lag 8 is 0.008576
Clarification:¶
As you see those differences are really small. Each semivariogram model is similar in this case. In this case we can use 4-lag model. It will be calculted faster than other models and it is still very similar to other models.


Marvel Heros Database website is a course project for INF 385M Database Management of School of Information at UT Austin. User can explore features through our database such as search heros by group, by justice or villian, find heros in your favorite city, find heros by creators and a list view of all heros.
The database is developed using PHP, MySQL, HTML and CSS. The website design is accomplished with Adobe Illustrator, Photoshop and Sketch.
The team members are Mengpin Dai, Xiangkun Dai, Xinqi You and Yang Zhang.
We would like to thank our professor Stan Gunn for his dedication of teaching and guidance to our project, we appreciate all the valuable suggestions.


Exposure, the effective laying open of the data to display the unanticipated, is to us a major portion of data analysis. Formal statistics has given almost no guidance to exposure; indeed, it is not clear how the informality and flexibility appropriate to the exploratory character of exposure can be fitted into any of the structures of formal statistics so far proposed.
Nothing—not the careful logic of mathematics, not statistical models and theories, not the awesome arithmetic power of modern computers—nothing can substitute here for the flexibility of the informed human mind. Accordingly, both approaches and techniques need to be structured so as to facilitate human involvement and intervention.
Wattenberg
A cornerstone in the EDA toolbox!
“Above all else show the data.” - Tufte


OTM Mumbai has the largest exhibiting space and the highest number of participants in any travel show in India. Mumbai is the largest travel market in the country, generating one-third (33%) of all India-outbound travellers.
India’s biggest hosted buyer program was introduced at OTM in 2015. Since then, hundreds of qualified buyers are hosted every year during the OTM.
India’s biggest hosted buyer program was introduced at OTM in 2015. Since then, hundreds of qualified buyers are hosted every year during the OTM.
Advertising in the Exhibition Directory is a very effective way to reach out and enhance your communication with the travel trade
The Exhibition Brochure gives you at a glance information for planning your participation in the OTM.
The Exhibitor Handbook has useful information, once you have decided to participate in the OTM.


Home
Data Analysis
Menu
Pie Chart
Line Plot
Box Plot
Scatter Plot
Pie chart
AD
Line plot
Box plot
Scatter plot


|
Jerasure
1.2
A Library in C/C++ Facilitating Erasure Coding for Storage Applications
|
#include "galois.h"
Go to the source code of this file.
Functions | |
| int * | jerasure_matrix_to_bitmatrix (int k, int m, int w, int *matrix) |
| int ** | jerasure_dumb_bitmatrix_to_schedule (int k, int m, int w, int *bitmatrix) |
| int ** | jerasure_smart_bitmatrix_to_schedule (int k, int m, int w, int *bitmatrix) |
| int *** | jerasure_generate_schedule_cache (int k, int m, int w, int *bitmatrix, int smart) |
| void | jerasure_free_schedule (int **schedule) |
| void | jerasure_free_schedule_cache (int k, int m, int ***cache) |
| void | jerasure_do_parity (int k, char **data_ptrs, char *parity_ptr, int size) |
| void | jerasure_matrix_encode (int k, int m, int w, int *matrix, char **data_ptrs, char **coding_ptrs, int size) |
| void | jerasure_bitmatrix_encode (int k, int m, int w, int *bitmatrix, char **data_ptrs, char **coding_ptrs, int size, int packetsize) |
| void | jerasure_schedule_encode (int k, int m, int w, int **schedule, char **data_ptrs, char **coding_ptrs, int size, int packetsize) |
| int | jerasure_matrix_decode (int k, int m, int w, int *matrix, int row_k_ones, int *erasures, char **data_ptrs, char **coding_ptrs, int size) |
| int | jerasure_bitmatrix_decode (int k, int m, int w, int *bitmatrix, int row_k_ones, int *erasures, char **data_ptrs, char **coding_ptrs, int size, int packetsize) |
| int | jerasure_schedule_decode_lazy (int k, int m, int w, int *bitmatrix, int *erasures, char **data_ptrs, char **coding_ptrs, int size, int packetsize, int smart) |
| int | jerasure_schedule_decode_cache (int k, int m, int w, int ***scache, int *erasures, char **data_ptrs, char **coding_ptrs, int size, int packetsize) |
| int | jerasure_make_decoding_matrix (int k, int m, int w, int *matrix, int *erased, int *decoding_matrix, int *dm_ids) |
| int | jerasure_make_decoding_bitmatrix (int k, int m, int w, int *matrix, int *erased, int *decoding_matrix, int *dm_ids) |
| int * | jerasure_erasures_to_erased (int k, int m, int *erasures) |
| void | jerasure_matrix_dotprod (int k, int w, int *matrix_row, int *src_ids, int dest_id, char **data_ptrs, char **coding_ptrs, int size) |
| void | jerasure_bitmatrix_dotprod (int k, int w, int *bitmatrix_row, int *src_ids, int dest_id, char **data_ptrs, char **coding_ptrs, int size, int packetsize) |
| void | jerasure_do_scheduled_operations (char **ptrs, int **schedule, int packetsize) |
| int | jerasure_invert_matrix (int *mat, int *inv, int rows, int w) |
| int | jerasure_invert_bitmatrix (int *mat, int *inv, int rows) |
| int | jerasure_invertible_matrix (int *mat, int rows, int w) |
| int | jerasure_invertible_bitmatrix (int *mat, int rows) |
| void | jerasure_print_matrix (int *matrix, int rows, int cols, int w) |
| void | jerasure_print_bitmatrix (int *matrix, int rows, int cols, int w) |
| int * | jerasure_matrix_multiply (int *m1, int *m2, int r1, int c1, int r2, int c2, int w) |
| void | jerasure_get_stats (double *fill_in) |
| int jerasure_bitmatrix_decode | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix, | ||
| int | row_k_ones, | ||
| int * | erasures, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize | ||
| ) |
This function
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
| erasures | Array of id's of erased devices. Id's are integers between 0 and k+m-1. Id's 0 to k-1 are id's of data devices. Id's k to k+m-1 are id's of coding devices: Coding device id = id-k. If there are e erasures, erasures[e] = -1. |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by coding_ptrs/data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
return data
formula
fix
example code
description
references
| void jerasure_bitmatrix_dotprod | ( | int | k, |
| int | w, | ||
| int * | bitmatrix_row, | ||
| int * | src_ids, | ||
| int | dest_id, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize | ||
| ) |
This function
| k | Number of data devices |
| w | Word size |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by coding_ptrs/data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
fix
example code
description
| void jerasure_bitmatrix_encode | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize | ||
| ) |
This function encodes a matrix with a bit-matrix in . my be any number between 1 and 32.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
| void jerasure_do_parity | ( | int | k, |
| char ** | data_ptrs, | ||
| char * | parity_ptr, | ||
| int | size | ||
| ) |
This function calculates the parity of size bytes of data from each of k regions of memory accessed by data_ptrs. It put the result into the size pointed to by parity_ptr.
| k | Number of data devices |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| size | Size of memory allocated by data_ptrs in bytes. |
fix
example code
| void jerasure_do_scheduled_operations | ( | char ** | ptrs, |
| int ** | schedule, | ||
| int | packetsize | ||
| ) |
This function executes the schedule on w*packetsize worth of bytes from each device. ptrs is an array of pointers which should have as many elements as the highest referenced device in the schedule.
| schedule | Array of schedule operations. If there are m operations, then schedule[m][0] = -1. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
fix
example code
| int** jerasure_dumb_bitmatrix_to_schedule | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix | ||
| ) |
This function turns a bitmatrix into a schedule using the straightforward algorithm -- just schedule the dot products defined by each row of the matrix.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
return (int**)
example code
| int* jerasure_erasures_to_erased | ( | int | k, |
| int | m, | ||
| int * | erasures | ||
| ) |
This function allocates and returns erased from erasures.
| k | Number of data devices |
| m | Number of coding devices |
| erasures | Array of id's of erased devices. Id's are integers between 0 and k+m-1. Id's 0 to k-1 are id's of data devices. Id's k to k+m-1 are id's of coding devices: Coding device id = id-k. If there are e erasures, erasures[e] = -1. |
return data
usage example
| void jerasure_free_schedule | ( | int ** | schedule | ) |
This function frees a schedule that was allocated with jerasure_XXX_bitmatrix_to_schedule.
| schedule | Array of schedule operations. If there are m operations, then schedule[m][0] = -1. |
| void jerasure_free_schedule_cache | ( | int | k, |
| int | m, | ||
| int *** | cache | ||
| ) |
This function reads a schedule cache that was created with jerasure_generate_schedule_cache.
| k | Number of data devices |
| m | Number of coding devices |
fix
example code
| int*** jerasure_generate_schedule_cache | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix, | ||
| int | smart | ||
| ) |
This function precalcalculate all the schedule for the given distribution bitmatrix. M must equal 2.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
return data
fix
example code
| void jerasure_get_stats | ( | double * | fill_in | ) |
This function fills in a vector of three doubles: fill_in[0] is the number of bytes that have been XOR'd, fill_in[1] is the number of bytes that have been copied, fill_in[2] is the number of bytes that have been multiplied by a constant in . When jerasure_get_stats() is called, it resets its values.
| fill_in | vector of three doubles to be filled jerasure_get_stats(); // reset all values |
| int jerasure_invert_bitmatrix | ( | int * | mat, |
| int * | inv, | ||
| int | rows | ||
| ) |
This function
fix
return data
description
| int jerasure_invert_matrix | ( | int * | mat, |
| int * | inv, | ||
| int | rows, | ||
| int | w | ||
| ) |
| int jerasure_invertible_bitmatrix | ( | int * | mat, |
| int | rows | ||
| ) |
This function
return data
fix
description
| int jerasure_invertible_matrix | ( | int * | mat, |
| int | rows, | ||
| int | w | ||
| ) |
| int jerasure_make_decoding_bitmatrix | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | matrix, | ||
| int * | erased, | ||
| int * | decoding_matrix, | ||
| int * | dm_ids | ||
| ) |
This function makes the k*k decoding matrix (or wk*wk bitmatrix) by taking the rows corresponding to k non-erased devices of the distribution matrix, and then inverting that matrix. You should already have allocated the decoding matrix and dm_ids, which is a vector of k integers. These will be filled in appropriately. dm_ids[i] is the id of element i of the survivors vector. I.e. row i of the decoding matrix times dm_ids equals data drive i. Both of these routines take "erased" instead of "erasures". Erased is a vector with k+m elements, which has 0 or 1 for each device's id, according to whether the device is erased.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
fix
example code
| int jerasure_make_decoding_matrix | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | matrix, | ||
| int * | erased, | ||
| int * | decoding_matrix, | ||
| int * | dm_ids | ||
| ) |
This function makes the k*k decoding matrix (or wk*wk bitmatrix) by taking the rows corresponding to k non-erased devices of the distribution matrix, and then inverting that matrix. You should already have allocated the decoding matrix and dm_ids, which is a vector of k integers. These will be filled in appropriately. dm_ids[i] is the id of element i of the survivors vector. I.e. row i of the decoding matrix times dm_ids equals data drive i. Both of these routines take "erased" instead of "erasures". Erased is a vector with k+m elements, which has 0 or 1 for each device's id, according to whether the device is erased.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
fix
return data
example code
| int jerasure_matrix_decode | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | matrix, | ||
| int | row_k_ones, | ||
| int * | erasures, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size | ||
| ) |
This function decodes unsing a matrix in , only when = 8|16|32.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
| erasures | Array of id's of erased devices. Id's are integers between 0 and k+m-1. Id's 0 to k-1 are id's of data devices. Id's k to k+m-1 are id's of coding devices: Coding device id = id-k. If there are e erasures, erasures[e] = -1. |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by data_ptrs/coding_ptrs in bytes. |
crossreferences
example code
| void jerasure_matrix_dotprod | ( | int | k, |
| int | w, | ||
| int * | matrix_row, | ||
| int * | src_ids, | ||
| int | dest_id, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size | ||
| ) |
This function only works when w = 8|16|32.
| k | Number of data devices |
| w | Word size |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
fix
sample code
description
| void jerasure_matrix_encode | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | matrix, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size | ||
| ) |
This function encodes a matrix in . must be either 8, 16 or 32.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by coding_ptrs in bytes. |
| int* jerasure_matrix_multiply | ( | int * | m1, |
| int * | m2, | ||
| int | r1, | ||
| int | c1, | ||
| int | r2, | ||
| int | c2, | ||
| int | w | ||
| ) |
| int* jerasure_matrix_to_bitmatrix | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | matrix | ||
| ) |
This function turns a matrix in into a bitmatrix (in ). For a detailed explanation see: J. Blomer, M. Kalfane, M. Karpinski, R. Karp, M. Luby and D. Zuckerman: An XOR-based erasure-resilinet coding scheme. Technical Report TR-95-048, International Computer Science Institute, August 1995
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
| void jerasure_print_bitmatrix | ( | int * | matrix, |
| int | rows, | ||
| int | cols, | ||
| int | w | ||
| ) |
This function
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
| w | Word size |
fix
description
| void jerasure_print_matrix | ( | int * | matrix, |
| int | rows, | ||
| int | cols, | ||
| int | w | ||
| ) |
This function
| matrix | Array of k*m integers. It represents an m by k matrix. Element i,j is in matrix[i*k+j] |
| w | Word size |
fix
description
| int jerasure_schedule_decode_cache | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int *** | scache, | ||
| int * | erasures, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize | ||
| ) |
This function
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| erasures | Array of id's of erased devices. Id's are integers between 0 and k+m-1. Id's 0 to k-1 are id's of data devices. Id's k to k+m-1 are id's of coding devices: Coding device id = id-k. If there are e erasures, erasures[e] = -1. |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by coding_ptrs/data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
return data
fix
example code
| int jerasure_schedule_decode_lazy | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix, | ||
| int * | erasures, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize, | ||
| int | smart | ||
| ) |
This function generates the schedule on the fly.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
| erasures | Array of id's of erased devices. Id's are integers between 0 and k+m-1. Id's 0 to k-1 are id's of data devices. Id's k to k+m-1 are id's of coding devices: Coding device id = id-k. If there are e erasures, erasures[e] = -1. |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by coding_ptrs/data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
return data
formula
fix
example code
| void jerasure_schedule_encode | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int ** | schedule, | ||
| char ** | data_ptrs, | ||
| char ** | coding_ptrs, | ||
| int | size, | ||
| int | packetsize | ||
| ) |
This function encodes with a previously created schedule.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| schedule | Array of schedule operations. If there are m operations, then schedule[m][0] = -1. |
| data_ptrs | Array of k pointers to data which is size bytes. Size must be a multiple of sizeof(long). Pointers must also be longword aligned. |
| coding_ptrs | Array of m pointers to coding data which is size bytes |
| size | Size of memory allocated by data_ptrs in bytes. |
| packetsize | The size of a coding block with bitmatrix coding. When you code with a bitmatrix, you will use w packets of size packetsize. |
| int** jerasure_smart_bitmatrix_to_schedule | ( | int | k, |
| int | m, | ||
| int | w, | ||
| int * | bitmatrix | ||
| ) |
This function turns a bitmatrix into a schedule, but tries to use previous dot products to calculate new ones. This is the optimization explained in the original Liberation code paper.
| k | Number of data devices |
| m | Number of coding devices |
| w | Word size |
| bitmatrix | Array of k*m*w*w integers. It represents an mw by kw matrix. Element i,j is in matrix[i*k*w+j] |
return data
example code


Auto-Bot Channel
Submit your video link bellow to share it over 25+ subreddit in single click!
Title
URL
Add more Subreddits if you want to share upon
Share
If we could save atleast few seconds of your life please subscribe to our channel


Mission Statement
Videos
Requests
YouTube
Requests
Have any questions regarding what we do or how we do it? Have a request for a video you want to make and edit? Send us an email and we will get back to you within a reasonable amount of time!


Your team must be added on teams page before you can add a project.
Team: Beaver Greats
Devpost: devpost.com/software/video_sync
Team: Cosmic Coders
Devpost: devpost.com/software/tomato-timer
Team: The Secs
Devpost: devpost.com/software/team-delicious-meal-planner


| {{ business.job_id }} |
{{ business.technician_id }} |
{{ business.date_serviced | date }} |
{{ business.vehicle_no }} |
{{ business.make }} |
{{ business.model }} |
{{ business.owner_name }} |
{{ business.mileage }} |
{{ business.lights_indicators }} |
{{ business.horn }} |
{{ business.wipers }} |
{{ business.side_mirror }} |
{{ business.power_windows }} |
{{ business.brake_fluid }} |
{{ business.engine_coolant }} |
{{ business.drive_belt }} |
{{ business.ac_filter }} |
{{ business.air_filter }} |
{{ business.front_brakes }} |
{{ business.rear_brakes }} |
{{ business.engine_oil }} |
{{ business.oil_filter }} |
{{ business.shocks }} |
{{ business.tyre_pressure }} |
{{ business.body_wash }} |
Edit |
Delete |


Play on our server. Sign Up Here.
Privileges of being a member:
[Member] tag in-game
[Member] tag in the forums
100 credits
Extra commands in-game
Go to our forums!
New Gamemodes Every Month.
We add 1 gamemode every month.
PC and PE
WonderNetwork supports Minecraft on PC, iOS, Windows Phone and Android devices.
PC: Download at http://minecraft.net
Android: Search Minecraft: Pocket Edition on Google Play Store
iOS: Search Minecraft: Pocket Edition on App Store
Windows Phone: Search Minecraft: Pocket Editon on Windows App Store
We develop minigames ourselves and install them on our server.
On our Minecraft PC server network, we offer gamemodes such as:
Vanilla... Survive with your friends on no lag at all.
Pixelmon... Build your own pokemons to be the very best!
On our Minecraft PE server network, we offer minigames such as:
Spleef... Break snow under you, and knock people off to lava!
Party Games... Enjoy our minigames in random order.
Hunger Games... Fight until you are the last one left!
Survival... Survive with your friends on no lag at all!
Creative... Build as much as you want... with creative mode!
Factions... Create factions and take over one!
TNTRun... Run until you are the only one left! Remember: The ground is falling beneath you!
Zombie Apocalypse... Kill all zombies in the haunted house within 5 minutes!
Rescue the Villagers... The villagers has been lost throughout the world! Use spectator
mode to try and bring them back to their home!
How to Join
Our server currently supports MC:PE on later than the 0.11.0 update, and Minecraft PC on update 1.8.3.
PE:
Press the external tab,
In server name type “WonderNetwork”
In IP/Address type “play.wonderlandpe.hol.es”
Press create
Tap on the server and play!
PC: Coming soon!
Keep Up To Date.
Follow the owner’s twitter account to keep up to date with latest server information!


credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card
credit_card


Cobb is clutch, Wagner tops Saint Peter’s 81-77 in OT
JERSEY CITY, N.J. (AP) - Curtis Cobb III scored 25 points and Wagner made 16 of 19 free throws in overtime to defeat Saint Peter’s 81-77 on Wednesday night.
Elijah Ford added 18 points and 13 rebounds for the Seahawks, who outscored the Peacocks 20-16 in the extra period and finished 39 of 48 from the foul line. Cobb made all 10 of his free throws in the last 43 seconds. Ford was 13 of 16 from the line but only had two in overtime.
Nazeer Bostick’s layup pulled Saint Peter’s into a tie at 65 but Wagner (2-3) scored the next eight points. Cobb’s first free throws made it 73-65.
Matthew Lee scored four quick baskets for the Peacocks, including two 3-pointers, but Cobb answered every time with two clutch free throws. Bostick scored at the buzzer.
KC Nedefo’s 3-point play with 21.9 seconds left tied the game at 61 and Cobb missed a 3-pointer to end regulation.
Doug Edert led Saint Peter’s (0-3) with 18 points and Lee had 16. The Peacocks, led by Edert’s five 3-pointers, went 12 of 25 from 3-point range and were outscored by 22 at the foul line.
More AP college basketball: https://apnews.com/Collegebasketball and https://twitter.com/AP_Top25
Sign up for Daily Newsletters
Copyright © 2019 The Washington Times, LLC.
Please read our comment policy before commenting.


We only made one quiz for now, but more may be added in the future.
0/15 Correct
When was The Catcher in the Rye published?
1951
1935
1926
1978
Which quote best demonstrates Holden's hypocritical/contradictory nature?
“I was only thirteen, and they were going to have me psychoanalyzed and all, because I broke all the windows in the garage. I don't blame them. I really don't. I slept in the garage the night he died, and I broke all the goddam windows with my fist, just for the hell of it. I even tried to break all the windows on the station wagon we had that summer…” (Salinger 39).
"What I did, I started talking, sort of out loud, to Allie. I do that sometimes when I get very depressed. I keep telling him to go home and get his bike and meet me in front of Bobby Fallon's house…" (Salinger 98)
"I had quite a bit of time to kill till ten o'clock, so what I did, I went to the movies at Radio City. It was probably the worst thing I could've done, but it was near, and I couldn't think of anything else."   I wouldn't've read it out loud to him if he'd written it--I really wouldn't. In the first place, I'd only written that damn note so that he wouldn't feel too bad about flunking me" (Salinger 12)
What does Holden say about money?
It makes people happy
It always ends up making people sad
It's hard to earn
It's useless
What kind of diction is used in the book out of these choices?
Colloquial
Formal
Informal
Both Colloquial and Informal
Which quote out of these shows Holden's desire to preserve innocence and childhood?
"'Anyway, I keep picturing all these little kids playing some game in this big field of rye and all. Thousands of little kids, and nobody's around--nobody big, I mean--except me.  What I have to do, I have to catch everybody if they start to go over the cliff--I mean if they're running and they don't look where they're going I have to come out from somewhere and catch them. That's all I'd do all day. I'd just be the catcher in the rye and all. I know it's crazy, but that's the only thing I'd really like to be.  'Listen. You got any dough, Phoeb? I'm practically broke.'... She put the dough in my hand... Then, all of a sudden, I started to cry. I couldn't help it. I did it so nobody could hear me, but I did it... Then I took my hunting hat out of my coat pocket and gave it to her. She likes those kind of crazy hats. She didn't want to take it, but I made her. I'll bet she slept with it on. She really likes those kind of hats." (Salinger 178-180)
"Then the carrousel started, and I watched her go around and around... All the kids kept trying to grab for the gold ring, and so was old Phoebe, and I was sort of afraid she'd fall off the goddam horse, but I didn't say anything or do anything. The thing with kids is, if they want to grab the gold ring, you have to let them do it, and not say anything.  (Salinger 211)
"'Life is a game, boy. Life is a game that one plays according to the rules.' 'Yes, sir. I know it is. I know it.'  Some game. If you get on the side where all the hot-shots are, then it's a game, all right--I'll admit that. But if you get on the other side, where there aren't any hot-shots, then what's a game about it? Nothing. No game." (Salinger 8)
Which choice best describes Holden as a narrator?
Objective and straight to the point, no digressions
Unreliable, biased, and digresses frequently
Holden is not the narrator of the book
Both objective and unreliable, it varies
Which quote shows Holden's denial towards Allie's death?
"I was only thirteen, and they were going to have me psychoanalyzed and all, because I broke all the windows in the garage. I don't blame them. I really don't. I slept in the garage the night he died, and I broke all the goddam windows with my fist, just for the hell of it. I even tried to break all the windows on the station wagon we had that summer…" (Salinger 39)
"When I finally got down off the radiator and went out to the hat-check room, I was crying and all. I don't know why, but I was.  It was even worse. And I think I was more depressed than I ever was in my whole life." (Salinger 194)
Which of these choices could be the symbolic meaning of the "Little Shirley Beans" record shattering?
Holden losing his grasp on his childhood and starting to grow up
The record shattering has no significance
Phoebe's life falling apart
Society breaking down
Where is Holden telling this story from and how did he get in that situation?
He's telling the story in present tense as it happens
He's telling this story for a school project
Some kind of mental institution or a place with a psychoanalyst on hand. He got there because he had some kind of a breakdown.
He's telling it from prison because he committed fraud
Pick the best answer: what's one thing about Holden that today's youth can identify with him for?
His constant smoking and drinking
His cursing, value of individualism, and independence
His overly positive attitude
His care for everyone around him
Which of these choices is something that Holden's red hunting hat probably DOES NOT represent?
His resistance to growing up and grasp on his childhood
His criticizing nature
His need for acceptance by others and conformity
His respect for society and its people
Which of these quotes is a criticism involving perception vs. reality?
"He just kept talking about Life being a game and all. You know. 'Life is a game, boy. Life is a game that one plays according to the rules.' 'Yes, sir. I know it is. I know it.'  Some game. If you get on the side where all the hot-shots are, then it's a game, all right--I'll admit that. But if you get on the other side, where there aren't any hot-shots, then what's a game about it? Nothing. No game." (Salinger 8)
“But the worst part was that you could tell they all wanted to go to the movies. I couldn't stand looking at them. I can understand somebody going to the movies because there's nothing else to do, but when somebody really wants to go, and even walks fast so as to get there quicker, then it depresses hell out of me. Especially if I see millions of people standing in one of those long, terrible lines, all the way down the block, waiting with this terrific patience for seats and all” (Salinger 116)
“Stradlater was more of a secret slob. He always looked all right, Stradlater, but for instance, you should've seen the razor he shaved himself with.  He never cleaned it or anything. He always looked good when he was finished fixing himself up, but he was a secret slob anyway, if you knew him the way I did” (Salinger 27).
"Then I tried to get them in a little intelligent conversation, but it was practically impossible. You had to twist their arms. You could hardly tell which was the stupidest of the three of them. And the whole three of them kept looking all around the goddam room, like as if they expected a flock of goddam movie stars to come in any minute. (Salinger 73)
Pick the best answer: Which of these is a trait of Phoebe?
She recognizes that growing up is necessary unlike Holden
Holden despises her
She is immature and negative about everything the way Holden is
She has a hard time talking to and understanding Holden. Holden can't confide in her.
Which one of these girls does Holden respect for not being a phony?
Sally Hayes
Jane Gallagher
Lillian Simmons
The 3 women from the Lavender Room
Pick the best answer that describes Holden's views on Stradlater and Ackley:
Holden respects and obeys Stradlater and thinks he's a great person. Holden despises Ackley for his disgusting behavior.
Holden respects both Stradlater and Ackley completely
Holden doesn't like Stradlater for his nasty habits, but respects and praises Ackley for his handsomeness and cleanliness.
 Holden doesn't like Ackley for his disgusting behavior and personality, but can respect that he is true to himself, doesn't care what others think of him, and has a strong sense of identity.


Digital Farm Animals
-
Touch The Sky
[by:__keepsmiling] 作曲 : C. D. Pasquale/N. Gale/D. Austin Touch the sky Cedric Gervais You get me so high I touch the sk...  -
All Falls Down
[by:hondoes] 作曲 : Alan Walker/Anders Froen/Pablo Bowman/Nick Gale/Rick Boardman/Sarah Blanchard 作词 : Pablo Bowman/Dani... -
Millionaire (Alan Walker Remix)
[by:NickyRomero] I feel like a millionaire I feel like a millionaire Whenever she comes around Whenever I hear her sound... -
Didn't Know
[by:OversG] [ti:] [ar:] [al:] [by:九九Lrc歌词网～www.99Lrc.net] "Didn't Know" All this was new to me Started so casually And I... -
Tokyo Nights
[by:hondoes] 作曲 : Martina Sorbara/Shaun Frank/Nicholas Gale 作词 : Martina Sorbara/Shaun Frank/Nicholas Gale I wanna go ... -
Back to You
[by:sssooooonnnn] I know you say you know me, know me well But these days I don't even know myself, no I always thought ... -
Lookin' For (R3HAB Remix)
[by:Trap_Girl] 作曲 : Danny Ocean/Nick Gale/Sam Roman/Will Vaughan In a plane, flying high, feeling lonely On the road tr... -
Next To You
[by:hondoes] 作曲 : Nick Gale/Chloe Latimer/Pip Kembo/Tarik "Rvssian" Johnston/Mario Dunwell/Richard McClashie/Luian Mala... -
Digital Love (Acoustic Version)
[by:丶Vince] [ti:Digital Love (Acoustic Version)] [ar:Digital Farm Animals&Hailee Steinfeld] [al:Digital Love (Acoustic V... -
Sleeping Beauty (Digital Farm Animals Remix)
作曲 : Fukase/Tablo/Antonina Armato/Tim James 作词 : Fukase The high that you're giving me is coming so strong (coming so ... -
Work It Out
[by:小陀螺Tony] [ti:Work It Out] [ar:Netsky Digital Farm Animals] [al:] [by:九九Lrc歌词网～www.99Lrc.net] Don't you walk away I'v... -
Summertime Love
[by:Trap_Girl] 作曲 : Benjamin Berger/Nicholas Gale/Ryan McMahon/Ryan Rabin 作词 : Benjamin Berger/Nicholas Gale/Ryan McMa... -
Say My Name
[by:hondoes] 作曲 : George Reid/Iman Conta Hultén/Nick Gale 作词 : George Reid/Iman Conta Hultén/Nick Gale I've been feeli... -
Empty Space (Remix)
[by:Trap_Girl] 作曲 : Richard Boardman/James Arthur/Pablo Bowman/Nick Gate 作词 : Richard Boardman/James Arthur/Pablo Bowm... -
Song About You (Digital Farm Animals & Franklin Remix)
[by:Trap_Girl] Put all your stuff in a box in my room I don't wanna write no song about you But you show up in everythin... -
Rio (Remix)
作曲 : Boris Daenen/Nicholas James Gale/Ben Haggerty 作词 : Boris Daenen/Nicholas James Gale/Ben Haggerty Wherever she goes,... -
Arms Around Me
[by:墨尔本bounce] 作曲 : Anthony Maniscalco/Nicholas Gale 作词 : Anthony Maniscalco/Nicholas Gale All I need, ooh-hey, is yo... -
Paranoia
[by:龙叔与Doc的旅行日记] [length: 03:31.461] [tool: 歌词滚动姬 https://lrc-maker.github.io] 作曲 : Alec King/Nicholas Gale/Samuel Elli... -
Wanna Know
[by:小陀螺Tony] [ti:Wanna Know] [ar:Digital Farm Animals R. Kelly =407088099] [al:] [by:九九Lrc歌词网～www.99Lrc.net] 作曲 : Rober... -
Good as You (Digital Farm Animals Remix)
[by:Trap_Girl] 作曲 : Kane Brown/Brock Berryhill/Shy Carter/Taylor Phillips/Will Weatherly 作词 : Kane Brown/Brock Berryhi... -
Drowning
[by:Trap_Girl] 作曲 : Nick Gale/Sorana Pacurar/Ben Duncombe I'm drowning Dam-dam-dam eh-ah eh Dam-dam-dam eh-ah eh Dam-da... -
All Falls Down (Steve Aoki Remix)
[by:Trap_Girl] What's the trick I wish I knew I'm so done with thinking through All the things I could've been And I kno... -
All Falls Down (K-391 Remix)
[by:Trap_Girl] What's the trick I wish I knew I'm so done with thinking through All the things I could've been And I kno...  -
Next To You Part II
[by:Trap_Girl] 作曲 : Nick Gale/Chloe Latimer/Pip Kembo/Tarik "Rvssian" Johnston/Mario Dunwell/Richard McClashie/Luian Ma...


BookRoom
Select Days to Book :
Select Days to Book :
1 Day
2 Days
3 Days
4 Days
5 Days
6 Days
7 Days
Payment Option :
BKash
You Have to Pay :
2500 BDT
Back To Hotel
Proceed


Password Sent
Your Password has been sent to your email address. Please open the email and follow the instructions.
It may take a few mintues for you to receive the emaill. Also, please make sure communications from mblistings.com are not considered spam by your email client. If you experience problems please you can try again or contact your systems administrator.


Lots of Tourist Attractions
Beyond The Return - Ghana 2020 - 2030.
Ghana prides itself in having diverse wildlife, beautiful waterfalls: Kintampo waterfalls and the biggest waterfall in west Africa, Wli waterfalls. It's a wonder to behold! You can also visit the largest man-made lake in the world by surface area, Lake Volta. We have nature reserves and national parks and historic slave castles that tell the gruesome story of how the slave trade unfolded centuries back.


Implements Magenta's Piano Genie model.
Piano Genie expands novice performances on a miniature piano keyboard (8 keys) to performances on full pianos (88 keys) in real-time.
Loading model weights...
Press keyboard keys 1-8 to hear sound.


- cancelUpdater() - Method in class me.bhop.bjdautilities.EditableMessage
-
Cancels the content updater, if it is running.
- clearClickListeners() - Method in class me.bhop.bjdautilities.ReactionMenu
-
Remove all click listeners from the menu.
- clearReactions() - Method in class me.bhop.bjdautilities.EditableMessage
-
- Command - Annotation Type in me.bhop.bjdautilities.command.annotation
-
The base command annotation, this must be attached to a class for it to be loadable as a command.
- CommandExecuteException - Exception in me.bhop.bjdautilities.exception
-
An exception thrown for exceptions within a command execution which would otherwise be suppressed.
- CommandExecuteException(String, Throwable) - Constructor for exception me.bhop.bjdautilities.exception.CommandExecuteException
-
- CommandHandler - Class in me.bhop.bjdautilities.command
-
- CommandHandler(JDA, boolean, CommandResponses, Set<LoadedCommand>, List<Object>, Map<Class<? extends CommandResult>, TriConsumer<CommandResult, LoadedCommand, Message>>, boolean, int, boolean) - Constructor for class me.bhop.bjdautilities.command.CommandHandler
-
- CommandHandler.Builder - Class in me.bhop.bjdautilities.command
-
- CommandInitException - Exception in me.bhop.bjdautilities.exception
-
Thrown during command registration / initialization if there are formatting issues.
- CommandInitException(Class<?>, String) - Constructor for exception me.bhop.bjdautilities.exception.CommandInitException
-
- CommandResponses - Interface in me.bhop.bjdautilities.command.response
-
A template for included command responses.
- CommandResult - Interface in me.bhop.bjdautilities.command.result
-
- CommandResult.InvalidArguments - Class in me.bhop.bjdautilities.command.result
-
The default invalid arguments result.
- CommandResult.NoPermission - Class in me.bhop.bjdautilities.command.result
-
The default no permission result.
- CommandResult.Success - Class in me.bhop.bjdautilities.command.result
-
The default command success result.
- commands - package commands
-
- commands.wahhs - package commands.wahhs
-
- CommandTemplate - Interface in me.bhop.bjdautilities.command
-
This is purely an example to show default formatting for the commands.
- coolResult(String) - Static method in interface CustomResults
-
- CoolResult(String) - Constructor for class CustomResults.CoolResult
-
- create(Class<?>, List<Object>) - Static method in class me.bhop.bjdautilities.command.LoadedCommand
-
Generate a new LoadedCommand given its type and a set of custom parameters.
- create(Object, List<Object>) - Static method in class me.bhop.bjdautilities.command.LoadedCommand
-
Generate a new LoadedCommand given an instance of it and a set of custom parameters.
- create(String, Method, Object[], boolean) - Static method in exception me.bhop.bjdautilities.exception.MethodInvocationException
-
Create a new exception instance.
- CustomResults - Interface in <Unnamed>
-
- CustomResults.CoolResult - Class in <Unnamed>
-


Class RequestContext
This class holds information regarding the request currently being processed. It is explicitly intended to be available to application code.
Inheritance
Namespace: Orleans.Runtime
Assembly: Orleans.Core.Abstractions.dll
Syntax
public static class RequestContext : object
Remarks
The request context is represented as a property bag. Some values are provided by default; others are derived from messages headers in the request that led to the current processing.
Information stored in RequestContext is propagated from Orleans clients to Orleans grains automatically by the Orleans runtime.
Properties
| Improve this Doc View SourceActivityId
Gets or sets an activity ID that can be used for correlation.
Declaration
public static Guid ActivityId { get; set; }
Property Value
| Type | Description |
|---|---|
| Guid |
PropagateActivityId
Whether Trace.CorrelationManager.ActivityId settings should be propagated into grain calls.
Declaration
public static bool PropagateActivityId { get; set; }
Property Value
| Type | Description |
|---|---|
| System.Boolean |
Methods
| Improve this Doc View SourceClear()
Declaration
public static void Clear()
Get(String)
Retrieve a value from the RequestContext key-value bag.
Declaration
public static object Get(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The key for the value to be retrieved. |
Returns
| Type | Description |
|---|---|
| System.Object | The value currently in the RequestContext for the specified key,
otherwise returns |
Remove(String)
Remove a value from the RequestContext key-value bag.
Declaration
public static bool Remove(string key)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The key for the value to be removed. |
Returns
| Type | Description |
|---|---|
| System.Boolean | Boolean |
Set(String, Object)
Sets a value into the RequestContext key-value bag.
Declaration
public static void Set(string key, object value)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | key | The key for the value to be updated / added. |
| System.Object | value | The value to be stored into RequestContext. |


class Rake::Application
Rake main application object. When invoking rake
from the
command line, a Rake::Application object is
created and run.
Constants
- DEFAULT_RAKEFILES
Attributes
The name of the application (typically 'rake')
The original directory where rake was invoked.
Name of the actual rakefile used.
Number of columns on the terminal
List of the top level task names (task names from the command line).
Override the detected TTY output state (mostly for testing)
Public Class Methods
Initialize a Rake::Application object.
# File lib/rake/application.rb, line 49 def initialize super @name = "rake" @rakefiles = DEFAULT_RAKEFILES.dup @rakefile = nil @pending_imports = [] @imported = [] @loaders = {} @default_loader = Rake::DefaultLoader.new @original_dir = Dir.pwd @top_level_tasks = [] add_loader("rb", DefaultLoader.new) add_loader("rf", DefaultLoader.new) add_loader("rake", DefaultLoader.new) @tty_output = STDOUT.tty? @terminal_columns = ENV["RAKE_COLUMNS"].to_i set_default_options end
Public Instance Methods
Add a loader to handle imported files ending in the extension
ext
.
# File lib/rake/application.rb, line 139 def add_loader(ext, loader) ext = ".#{ext}" unless ext =~ /^\./ @loaders[ext] = loader end
Initialize the command line parameters and app name.
# File lib/rake/application.rb, line 88 def init(app_name="rake", argv = ARGV) standard_exception_handling do @name = app_name begin args = handle_options argv rescue ArgumentError # Backward compatibility for capistrano args = handle_options end collect_command_line_tasks(args) end end
Find the rakefile and then load it and any pending imports.
# File lib/rake/application.rb, line 102 def load_rakefile standard_exception_handling do raw_load_rakefile end end
Application options from the command line
# File lib/rake/application.rb, line 145 def options @options ||= OpenStruct.new end
Run the Rake application. The run method performs the following three steps:
-
Initialize the command line options (
init
). -
Define the tasks (
load_rakefile
). -
Run the top level tasks (
top_level
).
If you wish to build a custom rake command, you should call
init
on your application. Then define any tasks. Finally,
call top_level
to run your top level tasks.
# File lib/rake/application.rb, line 79 def run(argv = ARGV) standard_exception_handling do init "rake", argv load_rakefile top_level end end
Run the given block with the thread startup and shutdown.
# File lib/rake/application.rb, line 122 def run_with_threads thread_pool.gather_history if options.job_stats == :history yield thread_pool.join if options.job_stats stats = thread_pool.statistics puts "Maximum active threads: #{stats[:max_active_threads]} + main" puts "Total threads in play: #{stats[:total_threads_in_play]} + main" end ThreadHistoryDisplay.new(thread_pool.history).show if options.job_stats == :history end
Run the top level tasks of a Rake application.
# File lib/rake/application.rb, line 109 def top_level run_with_threads do if options.show_tasks display_tasks_and_comments elsif options.show_prereqs display_prerequisites else top_level_tasks.each { |task_name| invoke_task(task_name) } end end end