ggplot2
package
ggplot2
packageggplot
packageThe ggplot
package is a part of the core of tidyverse
.
ggplot2
is a plotting system for R, based on the grammar of graphics. It takes care of many of the fiddly details that make plotting a hassle (like drawing legends) as well as providing a powerful model of graphics that makes it easy to produce complex multi-layered graphics 1.
It is the most elegant and versatile tool for graphically visualizing data in R, offering a coherent system (or grammar) for building graphs.
It is a concept coined by Leland Wilkinson in 2005.
An abstraction which facilitates reasoning and communicating graphics.
ggplot2
is a layered grammar of graphics which allow users to: independently specify the building blocks of a plot and combine them to create just about any kind of graphical display.
ggplot2
characteristicsAdvantages of ggplot2
:
ggplot2
has a large user base => it’s easy find to help.Weaknesses of ggplot2
rgl
or ggplot2
+ plotly
instead,igraph
insteadggplot2
graphical objectsdata
aesthetic mapping
geometric objects
statistical transformations
facets
scales
coordinate system
ggplot(data = <DATA>) +
GEOM_FUNCTION(
mapping = aes(<mappings>),
stat = <statistic transformation>,
position = <position options>,
color = <fixed color>,
<other arguments>) +
FACET_FUNCTION(<facet options>) +
SCALE_FUNCTION(<scale options>) +
theme(<theme elements>)
ggplot()
functionggplot()
function is initializes a basic graph structure.
It cannot produce a plot alone by itself.
You need to add extra components to generate a graph.
Different parts of a plot can be added together using +
. Note similarity with the %>%
operator.
Any data or arguments you supply to ggplot()
function, can later be used by added functions without repeated specification.
ggplot2
compared to base graphicsis more verbose for simple/out of the box graphics,
is less verbose for complex/custom graphics,
generates graphs by adding building blocks, instead of calling different functions to draw new layers on top,
makes it easier to edit and tweak elements of a plot,
more details on advantages of ggplot2
over base plot are in this blog.
ggplot2
has a built-in economics
dataset, which inclides time series data on US unemployment from 1967 to 2015.
economics
## # A tibble: 574 x 6
## date pce pop psavert uempmed unemploy
## <date> <dbl> <int> <dbl> <dbl> <int>
## 1 1967-07-01 507. 198712 12.5 4.5 2944
## 2 1967-08-01 510. 198911 12.5 4.7 2945
## 3 1967-09-01 516. 199113 11.7 4.6 2958
## 4 1967-10-01 513. 199311 12.5 4.9 3143
## 5 1967-11-01 518. 199498 12.5 4.7 3066
## 6 1967-12-01 526. 199657 12.1 4.8 3018
## 7 1968-01-01 532. 199808 11.7 5.1 2878
## 8 1968-02-01 534. 199920 12.2 4.5 3001
## 9 1968-03-01 545. 200056 11.6 4.1 2877
## 10 1968-04-01 545. 200208 12.2 4.6 2709
## # ... with 564 more rows
economics <- mutate(economics, unemp_rate = unemploy/pop)
plot(unemp_rate ~ date, data = economics, type = "l")
ggplot2
packagelibrary(tidyverse)
ggplot(data = economics, aes(x = date, y = unemp_rate)) + geom_line()
ggplot(data = economics, aes(x = date, y = unemp_rate))
ggplot(data = economics, aes(x = date, y = unemp_rate)) + geom_line()
ggplot(data = economics, aes(x = date, y = unemp_rate)) +
geom_line() + theme_bw()
# Add new variables for plotting
economics <- economics %>%
mutate(month = as.numeric(format(date, format="%m")),
year = as.factor(format(date, format="%Y")))
economics %>%
select(date, month, year, unemp_rate)
## # A tibble: 574 x 4
## date month year unemp_rate
## <date> <dbl> <fct> <dbl>
## 1 1967-07-01 7 1967 0.0148
## 2 1967-08-01 8 1967 0.0148
## 3 1967-09-01 9 1967 0.0149
## 4 1967-10-01 10 1967 0.0158
## 5 1967-11-01 11 1967 0.0154
## 6 1967-12-01 12 1967 0.0151
## 7 1968-01-01 1 1968 0.0144
## 8 1968-02-01 2 1968 0.0150
## 9 1968-03-01 3 1968 0.0144
## 10 1968-04-01 4 1968 0.0135
## # ... with 564 more rows
data09 <- subset(economics, year == "2009")
data14 <- subset(economics, year == "2014")
plot(unemp_rate ~ month, data = data09, ylim = c(0.02, 0.05), type = "l")
lines(unemp_rate ~ month, data = data14, col = "red")
legend("topleft", c("2009", "2014"), col = c("black", "red"), lty = c(1,1))
There is no need of specifing a legend:
ggplot(data = economics %>% filter(year %in% c(2014, 2009)),
aes(x = month, y = unemp_rate)) +
geom_line(aes(group = year, color = year))
ggplot(data = economics, aes(x = month, y = unemp_rate)) +
geom_line(aes(color = year)) +
theme(axis.text.x = element_text(angle = 45))
ggplot(data = economics, aes(x = month, y = unemp_rate)) +
geom_line(aes(group = year, color = pop)) +
theme(axis.text.x = element_text(angle = 45))
diamond
datasetdiamond
is a built-in dataset, included in tidyverse
. It contains prices and other attributes of almost 54,000 diamonds. We will use this dataset to illustrate how to use functions in ggplot2
.
data(diamonds)
diamonds
## # A tibble: 53,940 x 10
## carat cut color clarity depth table price x y z
## <dbl> <ord> <ord> <ord> <dbl> <dbl> <int> <dbl> <dbl> <dbl>
## 1 0.23 Ideal E SI2 61.5 55 326 3.95 3.98 2.43
## 2 0.21 Premium E SI1 59.8 61 326 3.89 3.84 2.31
## 3 0.23 Good E VS1 56.9 65 327 4.05 4.07 2.31
## 4 0.290 Premium I VS2 62.4 58 334 4.2 4.23 2.63
## 5 0.31 Good J SI2 63.3 58 335 4.34 4.35 2.75
## 6 0.24 Very Good J VVS2 62.8 57 336 3.94 3.96 2.48
## 7 0.24 Very Good I VVS1 62.3 57 336 3.95 3.98 2.47
## 8 0.26 Very Good H SI1 61.9 55 337 4.07 4.11 2.53
## 9 0.22 Fair E VS2 65.1 61 337 3.87 3.78 2.49
## 10 0.23 Very Good H VS1 59.4 61 338 4 4.05 2.39
## # ... with 53,930 more rows
More information with ?diamonds
. Spreadsheet view in RStudio with View(diamonds)
.
Geometric objects are the actual elements you put on the plot. Examples include:
geom_point()
, used for scatter plots)geom_text()
, geom_label()
, used for text labels)geom_line()
, used for time series, trend lines, etc.)geom_boxplot()
used for, well, boxplots!)There is no upper limit to how many geom objects you can use. You can add a geom objects to a plot using an +
operator.
To get a list of available geometric objects use the following:
help.search("geom_", package = "ggplot2")
# Note that we can save `ggplot` as an object
p <- ggplot(diamonds, aes(x = carat, y = price))
p + geom_point()
plog <- ggplot(
sample_n(diamonds, 100),
aes(x = log10(carat), y = log10(price)))
plog + geom_text(aes(label = clarity))
plog + geom_label(aes(label = clarity))
ggrepel
package for annotationggrepel
helps annotating overlapping labels.
# Uncomment the line below if you don't have 'ggrepel'
# install.packages("ggrepel")
library(ggrepel)
plog + geom_point() + geom_text_repel(aes(label = clarity), size = 3)
In ggplot an aesthetic mapping, defined with aes()
, describes how variables are mapped to visual properties or aesthetics.
The details of mapping can be described by using scale functions.
You can convey information about your data by mapping the aesthetics in your plot to the variables in your dataset.
Each type of geom
objects accepts only a subset of aesthetics; refer to the geom
help pages for details.
# We first generate a subset of 'diamnonds' dataset
dsmall <- sample_n(diamonds, 500)
p1 <- ggplot(dsmall, aes(x = carat, y = price))
# set shape by diamond cut
p1 + geom_point(aes(shape = cut))
## Warning: Using shapes for an ordinal variable is not advised
ggplot(data.frame(x = 1:5 , y = 1:25, z = 1:25), aes(x = x, y = y)) +
geom_point(aes(shape = z), size = 5, colour = "darkgreen", fill = "orange") +
scale_shape_identity()
# color by diamonds color
p1 + geom_point(aes(color = color))
p1 + geom_point(aes(shape = cut, color = color))
## Warning: Using shapes for an ordinal variable is not advised
p1 + geom_point(aes(color = color))
p1 + geom_point(color = "darkgreen")
p1 + geom_point(aes(fill = cut), size = 3, color = "black", shape = 25)
a1 <- p + geom_point(alpha = 1/5)
a2 <- p + geom_point(alpha = 1/50)
a3 <- p + geom_point(alpha = 1/500)
# We use grid.arrange from gridExtra to display multiple plots
library(gridExtra)
grid.arrange(a1, a2, a3, ncol = 3)
aes()
assign an aesthetic to a variable; it doesn’t determine how mapping should be done.
For example, aes(shape = x)
or aes(color = z)
do not specify what shapes or what colors should be used.
To choose colors/shapes/sizes etc. you need to modify the corresponding scale.
ggplot2
includes scales for:
Scales can be modified with functions of the form: scale_<aesthetic>_<type>()
, e.g. scale_color_discrete()
.
Try typing scale_<tab>()
to see a list of scale modification functions.
Common Scale Arguments:
# Square root y-axis transformation
p1 <- ggplot(dsmall, aes(x = carat, y = price))
psqrt <- p1 + geom_point() + scale_y_sqrt()
# Log base 10 y-axis transformation
plog10 <- p1 + geom_point() + scale_y_log10()
grid.arrange(psqrt, plog10, ncol = 2)
Log base 10 transformation of x and y axes. Note the differences.
ploglog1 <- p1 + geom_point() + scale_y_log10() + scale_x_log10()
ploglog2 <- ggplot(dsmall, aes(x = log(carat), y = log(price))) + geom_point()
grid.arrange(ploglog1, ploglog2, ncol = 2)
p11 <- p1 + geom_point(aes(shape = cut), size = 3)
p12 <- p1 + geom_point(aes(shape = cut), size = 3) +
scale_shape_manual(values = c(1:5))
grid.arrange(p11, p12, ncol = 2)
## Warning: Using shapes for an ordinal variable is not advised
To choose specific colors for discrete variables we use scale_color_manual
.
p1 + geom_point(aes(color = cut), size = 3) +
scale_color_manual(values = c("red", "orange", "yellow", "green", "blue"))
For continuous variables we use scale_color_gradient
, and specify the ends of the color spectrum.
p1 + geom_point(aes(color = price), size = 3) +
scale_color_gradient(low = "blue", high = "red")
You can also scale the values of the variable corresponding to color.
p1 + geom_point(aes(color = price), size = 3) +
scale_color_gradient(low = "blue", high = "red", trans = "log10")
Or and add your own breaks
p1 + geom_point(aes(color = price), size = 3) +
scale_color_gradient(low = "blue", high = "red", trans = "log10",
breaks = c(1000, 2000, 5000, 10000),
labels = c(" 1000", " 2000", " 5000", "10000"))
scale_color_brewer
lets you choose nice color palettes for discrete variables.
p1 + geom_point(aes(color = cut), size = 3) +
scale_color_brewer(palette = "Set2")
Unfortunately, scale_color_brewer
doesn’t work for continuous variables:
# This will result in an error
p1 + geom_point(aes(shape = price), size = 3) +
scale_color_brewer(palette = "Spectral")
## Error: A continuous variable can not be mapped to shape
We can get around this issue using the RColorBrewer
package and scale_color_gradientn
function, which interpolates colors from the brewer palettes.
# install.packages("RColorBrewer")
library(RColorBrewer)
p1 + geom_point(aes(color = price), size = 3) +
scale_color_gradientn(colours = brewer.pal(name = "Spectral", n = 10))
Another popular color scheme package, viridis
, supports both discrete and continuous variables:
# install.packages("viridis")
library(viridis)
p1 + geom_point(aes(color = price), size = 3) + scale_color_viridis()
p1 + geom_point(aes(color = cut), size = 3) +
scale_color_viridis(discrete = TRUE, option = "magma")
… there are also other unconventional schemes such as, one based on Wes Anderson movies :
#install.packages("wesanderson")
library(wesanderson)
names(wes_palettes)
## [1] "BottleRocket1" "BottleRocket2" "Rushmore1" "Rushmore"
## [5] "Royal1" "Royal2" "Zissou1" "Darjeeling1"
## [9] "Darjeeling2" "Chevalier1" "FantasticFox1" "Moonrise1"
## [13] "Moonrise2" "Moonrise3" "Cavalcanti1" "GrandBudapest1"
## [17] "GrandBudapest2" "IsleofDogs1" "IsleofDogs2"
# For discrete variables
p1 + geom_point(aes(color = cut), size = 3) +
scale_color_manual(values = wes_palette("Darjeeling1", n = 5))
# For continuous variables:
p1 + geom_point(aes(color = price), size = 3) +
scale_color_gradientn(colours = wes_palette("Darjeeling1", 100, type = "continuous"))
Facettng allows you to split up your data by one or more variables and plot the subsets of data together.
dsmall <- diamonds[sample(nrow(diamonds), 1000), ]
p0 <- ggplot(data = dsmall, aes(x = carat, y = price)) +geom_point(size = 1) +
geom_smooth(aes(colour = cut, fill = cut))
p1 <- p0 + facet_wrap(~ cut)
grid.arrange(p0, p1, ncol = 2)
ggplot(diamonds, aes(x = carat)) +
geom_density() +
facet_grid(color ~ cut)
Go to “Lec4_Exercises.Rmd” on the class website.
Complete Exercise 1.
Plots often require some statistical data transformation or computation
before they can be plotted. Examples include:
boxplots: the the median, lower and upper quartiles,
histograms: group the values into bins,
bar charts: number of class occurrences.
smoothers: prediction lines / predicted y-values,
Plotting a summary (less data) can be more insightful.
ggplot(data = diamonds, aes(x = cut, y =carat)) +
geom_boxplot()
# Distribution of the carats (weights) of the diamonds.
h <- ggplot(data = diamonds, aes(x = carat)) + geom_histogram()
d <- ggplot(data = diamonds, aes(x = carat)) + geom_density()
grid.arrange(h, d, ncol = 2)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
In histograms, the smoothness is controlled with bins
and binwidth
arguments. (or by specifying using the breaks
explicitly).
p <- ggplot(data = diamonds, aes(x = carat)) + xlim(0, 3)
h1 <- p + geom_histogram(binwidth = 0.5)
h2 <- p + geom_histogram(binwidth = 0.1)
h3 <- p + geom_histogram(binwidth = 0.05)
grid.arrange(h1, h2, h3, ncol = 3)
In density plots, the bw
(the smoothing bandwidth) and adjust
arguments control the smoothness.
d1 <- p + geom_density(adjust = 5)
d2 <- p + geom_density(adjust = 1)
d3 <- p + geom_density(adjust = 1/5)
grid.arrange(d1, d2, d3, ncol = 3)
# Here we show grouping by diamonds cut.
h <- p + geom_histogram(aes(fill = cut), position = "dodge", bins = 10)
d <- p + geom_density(aes(color = cut))
grid.arrange(h, d, ncol = 2)
Instead of marginal distributions, we can plot distribution of components stacked on top of each other to see the contribution from each of group.
h <- p + geom_histogram(aes(fill = cut), position = "stack")
d <- p + geom_density(aes(fill = cut), position = "stack")
grid.arrange(h, d, ncol = 2)
## `stat_bin()` using `bins = 30`. Pick better value with `binwidth`.
Position adjustments are used to adjust the position of each geom
. The following position adjustments are available:
position_identity
: default of most geomsposition_jitter
: adds a small amount of random variationposition_dodge
: default of geom_boxplot
position_stack
: default of geom_bar
, geom_histogram
position_fill
: useful for geom_bar
, geom_histogram
The position parameter can be set as follows:
geom_point(..., position="jitter")
Overplotting: many points overlap each other. Here variables are categorical, but sometimes rounding causes overplotting.
plt <- ggplot(diamonds, aes(x = cut, y = depth))
plt + geom_point()
plt + geom_point(position = "jitter")
A discrete analogue of a histogram is the bar chart, geom_bar()
.
Instead of partitioning the values into bins like histograms, the bar geom counts the number of instances of each discrete class. The counts are then plotted as columns for each distinct class.
If you’d like include unequal weights for different observations, you can use the weight
aesthetic.
b1 <- ggplot(diamonds, aes(x = clarity)) + geom_bar()
b2 <- ggplot(diamonds, aes(x = clarity)) + geom_bar(aes(weight = carat)) + ylab("carat")
grid.arrange(b1, b2, ncol = 2)
The left plot shows the number of diamonds in each clarity group, and the right plot shows the count weighted by carat, which is equivalent to showing the total weight of diamonds in clarity color group.
As you see, in ggplot2
(unlike base graphics) it is not necessary tabulate the values, i.e. compute the counts of each category beforehand. The computation is done automatically for you.
However, if you have already summarized data, you can still use geom_bar
but you need to specify an identity transformation, stat = "identity
rather than the default stat = "count"
.
diamond.counts <- diamonds %>%
group_by(color) %>%
summarise(count = n())
diamond.counts
## # A tibble: 7 x 2
## color count
## <ord> <int>
## 1 D 6775
## 2 E 9797
## 3 F 9542
## 4 G 11292
## 5 H 8304
## 6 I 5422
## 7 J 2808
With the frequency counts already computed, the default options of the barplot generates an error:
diamond.counts
## # A tibble: 7 x 2
## color count
## <ord> <int>
## 1 D 6775
## 2 E 9797
## 3 F 9542
## 4 G 11292
## 5 H 8304
## 6 I 5422
## 7 J 2808
ggplot(diamond.counts, aes(x=color, y=count)) + geom_bar()
## Error: stat_count() must not be used with a y aesthetic.
# You need to do the following:
ggplot(diamond.counts, aes(x=color, y=count)) + geom_bar(stat="identity")
# Smoothers help discern patterns in the data
set.seed(438756)
dsmall <- diamonds %>% sample_frac(0.1)
ggplot(dsmall, aes(x = carat, y = price)) +
geom_point(aes(color = color)) + geom_smooth()
## `geom_smooth()` using method = 'gam' and formula 'y ~ s(x, bs = "cs")'
ggplot(dsmall, aes(x = carat, y = price)) +
geom_point(aes(color = color)) + geom_smooth(method = "lm")
Now that you have your beautiful plot, you may want to save it as an image.
ggsave()
is a convenient function for saving a plot.
By default, it saves the last plot that you displayed, using the size of the current graphics device. It also guesses the type of graphics device from the extension.
ggsave(filename, plot = last_plot(), device = NULL, path = NULL,
scale = 1, width = NA, height = NA, units = c("in", "cm", "mm"),
dpi = 300, limitsize = TRUE, ...)
“Device” can be either be a device function (e.g. png), or one of “eps”, “ps”, “tex” (pictex), “pdf”, “jpeg”, “tiff”, “png”, “bmp”, “svg” or “wmf” (windows only).
Go back to “Lec4_Exercises.Rmd”
Complete the exercise 2 and 3


Rewards
Whew! I don’t know about you, but that was rough digging through all that grit. Looking at what can go wrong in life is never a fun exercise but I think it is the prudent and mature thing to do if I am asking for your money.
Now for the good part. Let’s talk about how your donation would contribute to the world.
 It’s easily the greatest invention out of MSFT during it’s grand and enduring history. It’s been around for nearly 20 years and MSFT continues to put the brightest talent into its gears and it has continued to adapt and improve over the years.
.
As the addition of F# shows, it has been designed to consider improvements or different ways of thinking about expressing CPU instructions, and has incorporated these new paradigms successfully. Meaning, future languages can also be incorporated as our field evolves.
You Support Efficient Business Practices
Super.NET is meant to improve and streamline how .NET client applications are made, reducing the amount of code and complexity as opposed to today’s guidance. Read this for more details.
You Support The Artists
Technically, I would classify myself as a hungry artist – not quite starving (of which I am very thankful and lucky), but incredibly hungry to be of value, as well as to find and provide meaning back into the world.
At my core, I consider myself an artist. Maybe not a great one, but one nonetheless who appreciates other art and would like to find a way to contribute back to it. I hope my articles on my underlying beliefs help demonstrate this.
Further, I hope the efforts here attract those other artists who believe and feel like me about art, and that contributions can also go to them if necessary during this time at the very least. At the very most we are able to build a digital art exchange that might change the way art is bought and sold online.
You Support Innovation
I would like to think that some of the ideas that I have are innovative. Some are indeed a little crazy, but that is what disruption looks like at times – and it is also part of the creative process, I would say.
I cannot promise anything – because a lot can happen in a few years and making promises is a dangerous activity that is just begging for trouble, in my experience – but I have a few ideas that I have been percolating upon and I would like to think that they could be built and actualized on this foundation that is being built here with Super.NET.
Some of them, if executed properly, are what I would classify as “disruptive.” That is all I will say for now.
You Support Cryptocurrency
Along with innovation, you get to see in action and partake of a positive use of cryptocurrency. Additionally, others may start thinking in this positive way as well.
You Support Michigan
In my view, Michigan is going through a bit of a down time, compared to its glory days. I would like to see innovation return Michigan, especially along the lines of cryptocurrency. That is all I will say for now.
 That is kind of bold, but very noble of you. I will do everything I can to ensure that your act of charity is handled appropriately and further still to see that value is returned to you in some way. Do know that this is the first time I have ever asked for donations in my life and I truly hope it is the last.
Summary
If you are still with me, let’s now check out how to donate».


Do you really want to In-Active this member from the group ?
Do you really want Write Only Access to this Member?
Do you really want Read Only Access to this Member?
Do you really want to Active this member from the group ?
Do you really want to make this member as a Admin of the group?


slither
- isPhallictasticgrep
- search for contents in filesvi
- open fiel in vi editorpwd
- display current directory namecat
- display contents of filecd
- change directorytouch
- create empty file or update modification timegit add
- tells the tracker to care about the filegit commit
-tells git to save the files that are being tracked locallygit pull
- pulls changes from remote repository to the local onesgit push
- pushes your local changes to the remote repositorygit status
- tells you about the current state of the tracked files


Username:
Full Name:
City:
State:
Address:
Full Name:
City:
State:
Address:
<%= title[0]%>
<%= title[1]%>
<%= title[2]%>
<%= title[3]%>
<%= title[4]%>
<%= title[1]%>
<%= title[2]%>
<%= title[3]%>
<%= title[4]%>


 UPE at
BU will help prepare members for the industry through professional
development, meaningful and thought-provoking projects, and a
supportive professional network.
Our main objective is to bridge the gap between theory and practical
experience at Boston University. We will provide career advice on
how to get fruitful internships and jobs, give a sense of community,
develop a professional network, and provide opportunities for
relevant and practical experience.
We will adhere to the following core values to maintain an inclusive
and innovative environment to achieve our goals.
-
Make Computer Science fun
by fostering a cooperative and productive environment.
-
Innovate Across Technical Sectors
while utilizing and contributing to new disruptive technologies.
We will mentor one another and create impactful and relevant
projects.
-
Ensure Diversity of Thought
for successful and consistent innovation by modeling authentic
work environments with many different kinds of people.
-
Utilize and Provide New Resources
by cooperating with existing organizations on campus,
contributing to free and highly relevant public events, and
forming mutually beneficial relationships with companies.
-
Promote Transparency in
how we evaluate applicants to create an atmosphere of trust and
inclusivity while learning from any mistakes we make.
Check Out Our Website
Check Us Out on GitHub
DIRECTOR OF RECRUITMENT
I currently serve as the Director of Recruitment for the BU UPE
Chapter. My term will last through the 2021 - 2022 Academic Year at
Boston University, and I am a member of the Epsilon Class.
As the Director of Recruitment, I am responsible for the execution
of UPE's recruitment process. More specifically, my responsibilities
are as follows.
-
Planning events for new potential members. These events can be
informative, professional, or social and occur throughout the
recruitment season to ensure all interested students can attend.
-
Facilitating the application process for potential new members.
This includes creating the general application form, devising
and selecting programming and logic-based questions for
applicant interviews, and organizing the logistics, from various
perspectives, for the interviews.
-
Running deliberation as current UPE members vote for the
acceptance or denial of various applicants based on their
performance during the conducted interviews.
-
Overseeing the trial period for provisional members. During the
trial period, I ensure all necessary fees are collected and
forms completed. Additionally, new members are required to
contribute to UPE. This can be a new project, involvement in an
ongoing project, or something decided upon between a provisional
member and myself.


Data Abstraction¶
This application is built with future scalability in mind. With that, we chose to implement our back-end interface with sqlalchemy’s ORM features giving us flexibility as we move forward.
- Note: Although the __init__ functions are not defined for each ORM mapping object below, you may initialize any attribute using standard constructor-argument initialization.
address = Address(city='Seattle', state='WA', zip='98112', ...) prediction = Prediction()
Module for mapping the ORM context to Python classes.
- Classes:
- Context: generates a database engine and contains a mangaged database connection through the Session object.
A connection string must be provided and in the following format:
- DATABASE = {
- ‘drivername’: ‘postgres’, ‘host’: <host name or ip>, ‘port’: ‘5432’, ‘username’: <db username>’, ‘password’: <db password>, ‘database’: <db name>
}
Any table not present or not matching the definitions below will be created or updated during context initialization.
ORM Classes: map objects their respective type to their associated database tables. See the design specification for more detailed information. Mapped objects defined below are: Address, Measurement, Metric, Prediction, RiverRun, State, Station, StationRiverDistance, and TmpMeasurement.
-
class
riverrunner.context.
Address
(**kwargs)[source]¶ ORM mapping for addresses
-
address
¶ str – street address limited to 255 characters
-
city
¶ str – city name limited to 255 characters
-
county
¶ str – county name limited to 255 characters
-
latitude
¶ float – geographical latitude in decimal date format (DD)
-
longitude
¶ float – geographical longit ude in decimal date format (DD)
-
state
¶ str – two character state identifier
-
zip
¶ str – zip code limited to 10 characters
-
-
class
riverrunner.context.
Measurement
(**kwargs)[source]¶ ORM mapping for measurements
-
date_time
¶ DateTime – timestamp for when the measurement was taken
-
metric_id
¶ int – reference to the metric gathered
-
station_id
¶ str – reference to the weather station that gathered the measurement
-
value
¶ float – the value recorded
-
dict
¶ dictionary representation of the measurement
-
-
class
riverrunner.context.
Metric
(**kwargs)[source]¶ ORM mapping for metrics
-
metric_id
¶ int – metric id
-
description
¶ str – a short description of the metric
-
units
¶ str – units the metric is gathered in
-
-
class
riverrunner.context.
Prediction
(**kwargs)[source]¶ ORM mapping for predictions
-
run_id
¶ int – reference to the river run this prediction is referencing
-
timestamp
¶ DateTime – timestamp for the prediction
-
fr_lb
¶ float – the lower bound of a confidence interval surrounding the prediction
-
fr
¶ float – the predicted flow rate
-
fr_ub
¶ float – the upper bound of a confidence interval surrounding the prediction
-
-
class
riverrunner.context.
RiverRun
(**kwargs)[source]¶ ORM mapping for a river run
-
run_id
¶ int – id
-
class_rating
¶ str – the run’s white-water class rating
-
distance
¶ float – the physical length of the run in miles
-
max_level
¶ int – maximum recommended flow rate
-
min_level
¶ int – minimum recommended flow rate
-
put_in_latitude
¶ float – geographical latitude in decimal degree format (DD) representing where the run begins
-
put_in_longitude
¶ float – geographical longitude (DD) representing where the run begins
-
river_name
¶ str – the name of the river
-
run_name
¶ str – the name of the run
-
take_out_latitude
¶ float) geographical latitude (DD
-
take_out_longitude
¶ float) geographical longitdue (DD
-
dict
¶ dictionary representation of the river run
-
-
class
riverrunner.context.
State
(**kwargs)[source]¶ ORM mapping for a state
-
short_name
¶ str – two letter state identification
-
long_name
¶ str – full state name
-
-
class
riverrunner.context.
Station
(**kwargs)[source]¶ ORM mapping for a weather station
-
station_id
¶ string – id
-
source
¶ string – the weather station’s controlling authority {USGS, NOAA}
-
name
¶ string – name
-
latitude
¶ float – geographical latitude (DD)
-
longitude
¶ float – geographical longitude (DD)
-
-
class
riverrunner.context.
StationRiverDistance
(**kwargs)[source]¶ ORM mapping describing distances between runs and stations
-
station_id
¶ str – weather station id
-
run_id
¶ int – river run id
-
put_in_distance
¶ float – distance in miles from put-in to station
-
take_out_distance
¶ float – distance in miles from take out-to station
-
source
¶ weather station source
This property is not stored in the backend. It is eager-loaded using a join on Station when StationRiverDistance objects are returned from the database
-
-
class
riverrunner.context.
TmpMeasurement
(**kwargs)[source]¶ ORM mapping for temporary measurements
-
date_time
¶ DateTime – timestamp for when the measurement was taken
-
metric_id
¶ int – reference to the metric gathered
-
station_id
¶ str – reference to the weather station that gathered the measurement
-
value
¶ float – the value recorded
-


Monitor
Controls
f(3.2, 1.5)
=
5.331
+
Display
Quad size
Line
Mesh
Grid
Area
Mesh
Grid
Line Width
Line Color
Area Color
Opacity
Grid scale (x,y,z)
Boundaries
-
X-Axis
Z-Axis
Plot Type
-
Real
Complex
f(x,z)
In
x = x axis
In
z = z axis
Out
y = value
Out
color = height
f(x,z) or f(c)
In
x = real axis
In
z = imaginary axis
In
c = (x+z)
Out
y = real part
Out
color = imaginary part
Out
y = imaginary part
Out
color = real part
Flip Outputs
Plot it!


StormLib API Reference
SFileVerifyFile
DWORD WINAPI SFileVerifyFile( HANDLE hMpq, // Handle to a file or archive const char * szFileName, // Name of the file to verify DWORD dwFlags // What to verify );
Function SFileVerifyFile verifies the file by its CRC and MD5. The (attributes) file must exist in the MPQ and must have been open by SFileOpenArchive or created by SFileCreateArchive. The entire file is always checked for readability. Additional flags in dwFlags turn on extra checks on the file.
| Value | Meaning |
|---|---|
| SFILE_VERIFY_SECTOR_CRC (0x0001) |
Also verify CRC of each file sector. |
| SFILE_VERIFY_FILE_CRC (0x0002) |
Also verify the file by its CRC32. |
| SFILE_VERIFY_FILE_MD5 (0x0004) |
Also verify the file by its MD5. |
| SFILE_VERIFY_RAW_MD5 (0x0008) |
Also verify the file by the raw data MD5. |
Return value is zero when no problerms were found. Otherwise, return value is a bit mask consisting of the following possible found problems:
| Value | Meaning |
|---|---|
| VERIFY_OPEN_ERROR (0x00000001) |
Failed to open the file. GetLastError() returns more information. |
| VERIFY_READ_ERROR (0x00000002) |
Could not read all the data from the file. |
| VERIFY_FILE_HAS_SECTOR_CRC (0x00000004) |
The checked file has been tested for sector checksum integrity. |
| VERIFY_FILE_SECTOR_CRC_ERROR (0x00000008) |
Sector checksum verification failed during reading the file. This flag may only be set on files with MPQ_FILE_SECTOR_CRC flag set and with sector checksum available. |
| VERIFY_FILE_HAS_CHECKSUM (0x00000010) |
The file has valid file CRC32 and was tested using it. |
| VERIFY_FILE_CHECKSUM_ERROR (0x00000020) |
CRC32 checksum for the entire file doesn't match. This flag may only be set when the MPQ has the "(attributes)" file, and the verified file has a valid CRC32 value there. Note that this check may fail on WAVE files stored using a lossy compression. |
| VERIFY_FILE_HAS_MD5 (0x00000040) |
The file has valid file MD5 and was tested using it. |
| VERIFY_FILE_MD5_ERROR (0x00000080) |
MD5 for the entire file doesn't match. This flag may only be set when the MPQ has the "(attributes)" file, and the verified file has a valid MD5 hash there. |
| VERIFY_FILE_HAS_RAW_MD5 (0x00000040) |
The file has valid raw MD5 hash was tested using it. |
| VERIFY_FILE_RAW_MD5_ERROR (0x00000040) |
MD5 for the raw file data doesn't match. |
| Available in Storm.dll | No |
| Ordinal number in Storm.dll 1.00 | N/A |
| Ordinal number in Storm.dll 1.09 | N/A |
Copyright (c) Ladislav Zezula 2003 - 2010


Amazon’s Echo Flex plug-in smart speaker is now available in Canada
Unfortunately the Flex is already sold out
by Dean DaleyAmazon’s Echo Flex plug-in smart speaker with Alexa is now available in Canada.
Though the Flex is now available, unfortunately, it’s already sold out and won’t be back in stock until November 21st. The Flex costs $34.99 CAD and you can buy two for $55.
The Flex’s speaker isn’t optimal for blasting music but brings a small speaker assistant to a variety of places in your home.
You can use it to control your smart home products, including lights, thermostats and door locks. Additionally, you can have it set an alarm or timer and contact other rooms in your house with compatible Echo products.
The Flex is one of the cheapest ways to get Alexa into your home and it barely takes up any room.
The flex is available on Amazon.ca.


Rent a place
In Chicago
Search Places
Rent places
Rentables in Chicago
Rentables near University
Department of Computer Science – University of Illinois, Chicago
.


This is some test data with various links spread throughout
This is some link with various links spread throughout
This is some test data with various links spread throughout
This is some test data with various links spread throughout
This is some test data with various links spread throughout


Seek and destroy
There are two solutions:
- (app2.js) The first one with N*M complexity.
- (app2.js) The second onw I belive with some kind of O(N+K) complexity, if we supose that check the index of array is O(1).
Free code camp seek and destroy algorithm. Should search and remove from an array some indexes, that should be passed through "arguments" variable.


Test touch slide on Mobile!
some text
some text
some text
some text
some text
some text
This page should be able to scroll when sliding on pie!
some text
some text
some text
some text
some text
some text
some text
Tooltip should be move smoothly when sliding in grid!
This page should be able to scroll when sliding out of grid!
some text
some text
some text
some text
some text
some text
some text
some text
some text
some text
DataZoom should be smooth when sliding or pinching on line!
This page should be able to scroll when sliding out of grid!
some text
some text
some text
some text
some text
some text
some text
some text
some text


In practice, less brute-force would be used to calculate k-nucleotide frequencies, for example Virus Classification using k-nucleotide Frequencies and [pdf 105KB] A Fast Algorithm for the Exhaustive Analysis of 12-Nucleotide-Long DNA Sequences.
We ask that contributed programs not only give the correct result, but also use the same algorithm to calculate that result.
Each program should:
read line-by-line a redirected FASTA format file from stdin
extract DNA sequence THREE
define a procedure/function to update a hashtable of k-nucleotide keys and count values, for a particular reading-frame — even though we'll combine k-nucleotide counts for all reading-frames (grow the hashtable from a small default size)
use that procedure/function and hashtable to
count all the 1-nucleotide and 2-nucleotide sequences, and write the code and percentage frequency, sorted by descending frequency and then ascending k-nucleotide key
count all the 3- 4- 6- 12- and 18-nucleotide sequences, and write the count and code for the specific sequences GGT GGTA GGTATT GGTATTTTAATT GGTATTTTAATTTATAGT
diff program output for this 250KB input file (generated with the fasta program N = 25000) with this output file to check your program is correct, before you contribute your program.


>
Enter Additional Info
View Colleges
Log Out
About
Contact
College Finder
Find the right college for you
silvestarbistrovic.from.hr


Add a new User: Add User User Name
There was a problem loading the users. Possibly the server is down or perhaps there are network issues.
Please wait a bit and try again or start the server.


Hurricane Harvey has already impacted millions of lives, we are here to provide assistance.
Our team will hit the streets on September 4th.
First of its kind ICO
I wish I could write a whitepaper and outline everything that we are going to do, but it is not that simple. This is not about technology, it is about humans. What I can tell you is that we're going to help people.
'
Might be secure, definitely not audited
I learned all about Ethereum smart contracts and Solidity over a weekend so I could launch this ICO. Most of the smart contract contract code is copied from GitHub and Stack Overflow posts, so it should be pretty much right… right?
Also, I definitely didn't have any smart contract experts look at the contract before I launched it. I mean, why bother? All the other ICOs go through weeks of auditing and they still end up with bugs and vulnerabilities in their contracts.
Guaranteed token value
Unlike with every other token sale on the market, I can guarantee here and now that the value of UET will not (in fact, can not) reduce during or after the ICO. Since these tokens aren't worth anything to start with, there's nowhere to go but up!
But remember—this is a completely honest ICO, which means I don't want anyone to mistakenly expect the value of the tokens to go up, either. They're called Useless Ethereum Tokens for a reason.
The crowdsale begins on:
July 4th, 2017 at 2:00 P.M. UTC
(don't worry, I set a reminder on my iPhone)
and will run until:
July 11th, 2017 at 2:00 P.M. UTC
(or until I feel like ending it)
To participate in the UET ICO, just send as much Ether as you want to the UET token/crowdsale contract. Make sure you provide enough gas for the transaction—100,000 or so ought to do it.
0x27f706edde3aD952EF647Dd67E24e38CD0803DD6
The more Ether everyone contributes, the more tokens you get.
The base token distribution formula is very simple: for every 1 ETH you contribute, you'll receive 100 UET, and if you contribute at least 0.01 ETH, you'll also receive an additional 1 UET for every Ether that's been contributed in total. Like this:
| Transaction | Ether sent | Total Ether sent | UET received |
|---|---|---|---|
| #1 | 1.000 ETH | 1.000 ETH | 101.000 UET |
| #2 | 3.000 ETH | 4.000 ETH | 304.000 UET |
| #3 | 0.005 ETH | 4.005 ETH | 0.500 UET |
| #4 | 0.500 ETH | 4.505 ETH | 54.505 UET |
Every block has a 1 in 256 chance of issuing bonus tokens.
When purchasing UET, the smart contract will take a hash of the current block's coinbase, number, and timestamp. If the first byte of the hash is 0x00, the block becomes a bonus block. During a bonus block, the smart contract counts the number of bits set in the second byte of the hash and uses that number as a bonus multiplier.
Every UET purchase of at least 0.01 ETH worth during the bonus block will receive, in addition to the base distribution, an additional 100 UET per Ether multiplied by the bonus multiplier. That means that contributors have a chance of receiving a total of nine times the number of tokens they expected!
Wait… is this a joke? Is it a scam?
Neither! This is real—and it's 100% transparent. You're literally giving your money to someone on the internet and getting completely useless tokens in return.
There are no “whitepapers,” no “products,” and no “experts.”
Why are you doing this?
Who knows? Maybe it's because I lost money in the GDAX flash crash. Maybe I got inspired by the guy who crowdfunded the potato salad. Maybe I'm just way too bored and need a better hobby.
What can I do with UET?
UET is a standard ERC20 token, so you can hold it and transfer it.
Other than that… nothing. Absolutely nothing.
(Seriously, don't buy this. Why are you even still reading these?)
Will UET be traded on any exchanges?
I hope so. You have no idea how much I hope so.
In fact, if it does get picked up by any of the major exchanges, I promise to use some of the ICO proceeds to constantly and incessantly manipulate the market.
Will there be more chances to buy UET?
That's a great question! It totally depends on how the ICO performs in the beginning. If I don't make enough money to buy at least one flat-screen television, I'll probably keep the ICO open longer than initially stated.
How do I get a refund for the tokens I bought?
You're kidding, right?


Low Deficiency Approach¶
Now that we have constructed the SBML file using the guidelines of CellDesigner Walkthrough, we will proceed by
testing the Deficiency Zero and One Theorems of [Fei79]. We will complete this test for
Fig1Ci.xml
. The first step we must
take is importing crnt4sbml. To do this open up a python script and add the following line:
import crnt4sbml
Next, we will take the SBML file created using CellDesigner and import it into the code. This is done by instantiating CRNT with a string representation of the path to the SBML file. An example of this instantiation is as follows:
network = crnt4sbml.CRNT("/path/to/Fig1Ci.xml")
Once this line is ran the class CRNT takes the SBML file and parses it into a Python
NetworkX object which is then used to
identify the basic Chemical Reaction Network Theory properties of the network. To obtain a full list of what is provided
by this instantiation, please see the getter methods of crnt4sbml.CRNT()
. To obtain a print out of the
number of species, complexes, reactions and deficiency of the network complete the following command:
network.basic_report()
For the closed portion of the C-graph the output should be as follows:
Number of species: 7
Number of complexes: 9
Number of reactions: 9
Network deficiency: 2
It is important for the user to verify that the number of species, complexes, reactions, and if possible deficiency values are correct at this stage. To provide another check to make sure the parsing and CellDesigner model were constructed correctly, one is encouraged to print the network constructed. To do this, add the following command to the script:
network.print_c_graph()
After running this command for the constructed SBML file, the following output is obtained.
Reaction graph of the form
reaction -- reaction label:
s1+s2 -> s3 -- re1
s3 -> s1+s2 -- re1r
s3 -> s6+s2 -- re2
s6+s7 -> s16 -- re3
s16 -> s6+s7 -- re3r
s16 -> s7+s1 -- re4
s1+s6 -> s15 -- re5
s15 -> s1+s6 -- re5r
s15 -> 2*s6 -- re6
Notice that this output describes the reactions in terms of the species’ id and not the species’ name. Along with the
reactions, the reaction labels constructed during parsing are also returned. For this example the first reaction
s1+s2 -> s3 has a reaction label of ‘re1’ and the reaction s15 -> s1+s6 has a reaction label of ‘re5r’. Please note
that the species id and reaction labels may be different if the user has constructed the SBML file themselves. Further
information of the network can be found by analyzing the getter methods of crnt4sbml.Cgraph()
.
Once one has verified that the network and CellDesigner model were created correctly, we can begin to check the properties of the network. If one is only interested in whether or not the network precludes bistability, it is best to first check the Deficiency Zero and One Theorems of Chemical Reaction Network Theory. To do this add the following lines to the script:
ldt = network.get_low_deficiency_approach()
ldt.report_deficiency_zero_theorem()
ldt.report_deficiency_one_theorem()
This provides the following output for the closed portion of the C-graph:
The network does not satisfy the Deficiency Zero Theorem, multistability cannot be excluded.
The network does not satisfy the Deficiency One Theorem, multistability cannot be excluded.
For information on the possible output for this run, please see crnt4sbml.LowDeficiencyApproach.report_deficiency_one_theorem()
and crnt4sbml.LowDeficiencyApproach.report_deficiency_zero_theorem()
.


V_LEARN
C
Quiz
Course Material
Course Videos
Complier
Logout
Course Material
copyright saravanan0298@gmail.com


Akane Names
Akan names are derived from Ghanian culture.Frequently in Ghana,
children are given their first name as a 'day name' which
corresponds to the day in the week they were born.
This application will assist you calculate your birthday.
Male
- Sunday: Kwasi
- Monday: Kwadwo
- Tuesday: Kwabena
- Wednesday: Kwaku
- Thursday: Yaw
- Friday: Kofi
- Saturday: Kwame
Female
- Sunday: Akosua
- Monday:Adwoa
- Tuesday: Abenaa
- Wednesday: Akua
- Thursday: Yaa
- Friday: Afua
- Saturday: Ama
submit


%- include common/head.html %>
<%- include common/top.html %>
<%=__('edit')%> <%=__('timeline')%>
<%=__("save")%>
<%- include ../common/footer.html%>


University returns nine human skulls to Sri Lankan tribe
Wanniya Uruwarige, chief of the jungle-dwelling Vedda people, attended a special ceremony in Edinburgh for the handover.
An elder from an ancient Sri Lankan tribe has visited Scotland to collect human remains that will be returned to his homeland.
Wanniya Uruwarige, chief of the jungle-dwelling Vedda people, attended the special ceremony in traditional dress and received the nine human skulls at the University of Edinburgh’s Playfair Library.
The skulls were acquired by the university more than 100 years ago, were kept in the anatomical collection and used to show how the tribe previously lived as isolated tropical rainforest foragers.
They are thought to be more than 200 years old.
“Even though these remains have been in Edinburgh for many years, their spirits have remained with us in Sri Lanka.
“This reuniting of spirits and physical remains – for which I thank the university – is a very special moment for my people.”
It comes after a study by researchers at the Max Planck Institute for Science of Human History in Germany, conducted with colleagues in Edinburgh, which confirmed the Vedda’s claim as some of Sri Lanka’s earliest inhabitants.
Researchers have suggested the traditional life of the group could become extinct within two generations.
Professor Tom Gillingwater, chairman of anatomy at the university, said: “We are delighted to welcome the Vedda tribespeople to Edinburgh and mark the return of their ancestral remains.
“Our vast and diverse collection is often used in research breakthroughs and teaching.
“We are pleased to be able to return these culturally-important artefacts to help ensure the Vedda’s legacy endures for generations to come.”


ai4cr
Artificial Intelligence for Crystal (based on https://github.com/SergioFierens/ai4r)
Installation
Add this to your application's shard.yml
:
dependencies:
ai4cr:
github: drhuffman12/ai4cr
Usage
require "ai4cr"
So far, only Ai4cr::NeuralNetwork::Backpropagation and related tests have been ported.
If you'd like another class of Ai4r ported, feel free to submit a new issue.
Development
See docs at: https://drhuffman12.github.io/ai4cr/
See the specs and https://github.com/SergioFierens/ai4r for more info.
Contributing
- Fork it ( https://github.com/drhuffman12/ai4cr/fork )
- Create your feature branch (git checkout -b my-new-feature)
- Commit your changes (git commit -am 'Add some feature')
- Push to the branch (git push origin my-new-feature)
- Create a new Pull Request
Contributors
- drhuffman12 Daniel Huffman - creator, maintainer
Testing
Example Spec Results (running on a Lenovo Ideapad y700 w/ i7-6700HQ)
I included the triangle-square-cross training example as test cases.
As expected, the net sometimes correctly guesses all of the examples, more or less, depending on how many times it is trained and various other (random) factors.
Below is an example of the net successfully recognizing all nine test cases.
$ cd $MY_DEV_FOLDER
$ git clone https://github.com/drhuffman12/ai4cr.git
$ cd ai4cr
$ crystal -v
Crystal 0.23.1 [e2a1389] (2017-07-13) LLVM 3.8.1
$ crystal deps
$ time crystal spec --release --no-debug --time --verbose
Ai4cr::NeuralNetwork::Backpropagation
#init_network
when given a net with structure of [4, 2]
sets @activation_nodes to expected nested array
sets @weights to expected size
sets @weights.first to expected size
sets each sub-array w/in @weights.first to expected size
when given a net with structure of [2, 2, 1]
sets @activation_nodes to expected nested array
sets @weights to expected size
sets @weights.first to expected size
sets each sub-array w/in @weights.first to expected size
when given a net with structure of [2, 2, 1] with bias disabled
sets @activation_nodes to expected nested array
sets @weights to expected size
sets @weights.first to expected size
sets each sub-array w/in @weights.first to expected size
#eval
when given a net with structure of [3, 2]
returns output nodes of expected size
when given a net with structure of [2, 4, 8, 10, 7]
returns output nodes of expected size
#dump
when given a net with structure of [3, 2]
@structure of the dumped net matches @structure of the loaded net
@bias_disabled on the dumped net matches @bias_disabled of the loaded net
@learning_rate of the dumped net approximately matches @learning_rate of the loaded net
@momentum of the dumped net approximately matches @momentum of the loaded net
@weights of the dumped net approximately matches @weights of the loaded net
@last_changes of the dumped net approximately matches @last_changes of the loaded net
@activation_nodes of the dumped net approximately matches @activation_nodes of the loaded net
#train
when given a net with structure of [3, 2]
returns an error of type Float64
Finished in 634 microseconds
22 examples, 0 failures, 0 errors, 0 pending
Execute: 00:00:00.0049940
real 0m0.646s
user 0m0.644s
sys 0m0.088s
$ time crystal spec --release --no-debug --time --verbose spec_examples/
Ai4cr::NeuralNetwork::Backpropagation
#train
using image data (input) and shape flags (output) for triangle, square, and cross
and training 101 times each at a learning rate of 0.697045
error_averages
decrease (i.e.: first > last)
should end up close to 0.1 +/- 0.1
should end up close to 0.01 +/- 0.01
should end up close to 0.001 +/- 0.001
#eval correctly guesses shape flags (output) when given image data (input) of
original input data for
TRIANGLE
SQUARE
CROSS
noisy input data for
TRIANGLE
SQUARE
CROSS
base noisy input data for
TRIANGLE
SQUARE
CROSS
Finished in 6.37 milliseconds
13 examples, 0 failures, 0 errors, 0 pending
Execute: 00:00:00.0107670
real 0m0.617s
user 0m0.680s
sys 0m0.060s
NOTE That time, it took less than a second to build. I did notice that it took about 10 seconds to build the first run and only less than a second each successive run.


The following rules specify the latest time at which an operation must complete at the origin or the target. The update performed by a get call in the origin process memory is visible when the get operation is complete at the origin (or earlier); the update performed by a put or accumulate call in the public copy of the target window is visible when the put or accumulate has completed at the target (or earlier). The rules also specify the latest time at which an update of one window copy becomes visible in another overlapping copy.
6. An update by a put or accumulate call to a public window copy becomes
visible in the private copy in process memory at latest when an ensuing
call to MPI_WIN_WAIT, MPI_WIN_FENCE, MPI_WIN_LOCK,
MPI_WIN_LOCK_ALL, or MPI_WIN_SYNC is executed on that window by the
window owner. In the RMA unified memory model, an update by a put or
accumulate call to a public window copy eventually becomes visible in the private
copy in process memory without additional RMA calls.
The rules above also define, by implication, when an update to a public window copy becomes visible in another overlapping public window copy. Consider, for example, two overlapping windows, win1 and win2. A call to MPI_WIN_FENCE(0, win1) by the window owner makes visible in the process memory previous updates to window win1 by remote processes. A subsequent call to MPI_WIN_FENCE(0, win2) makes these updates visible in the public copy of win2.
The behavior of some MPI RMA operations may be
undefined in certain situations. For example, the result of
several origin processes performing concurrent MPI_PUT
operations to the same target location is undefined. In addition, the
result of a single origin process performing multiple
MPI_PUT operations to the same target location within the
same access epoch is also undefined.
The result at the target may have all of the
data from one of the MPI_PUT operations (the ``last'' one,
in some sense), bytes from some of each of the operations, or
something else. In MPI-2, such operations were erroneous.
That meant that an MPI implementation was permitted to signal an MPI
exception. Thus, user programs or tools that used MPI RMA could not
portably permit such operations, even if the application code could
function correctly with such an undefined result. In MPI-3, these
operations are not erroneous, but do not have a defined behavior.
Rationale.
As discussed in [6], requiring
operations such as
overlapping puts to be erroneous makes it difficult to use MPI
RMA to implement programming models---such as Unified Parallel C (UPC) or SHMEM---that permit
these operations. Further, while MPI-2 defined these operations as
erroneous, the MPI Forum is unaware of any implementation that enforces
this rule, as it would require significant overhead. Thus, relaxing
this condition does not impact existing implementations or applications.
( End of rationale.)
Advice
to implementors.
Overlapping accesses are undefined. However, to assist users in
debugging code, implementations may wish to provide a mode in which such
operations are detected and reported to the user. Note, however, that in MPI-3, such operations must
not generate an MPI exception.
( End of advice to implementors.)
A program with a well-defined outcome in the MPI_WIN_SEPARATE memory model
must obey the following rules.
The last constraint on correct RMA accesses may seem unduly
restrictive, as it forbids concurrent accesses to nonoverlapping
locations in a window. The reason for this constraint is that, on
some architectures, explicit coherence restoring operations may be
needed at synchronization points.
A different operation may be needed for locations that were
updated by stores and for locations that were remotely
updated by put or accumulate operations. Without this constraint,
the MPI library would have to track
precisely which locations in a window were updated by a put or
accumulate call. The additional overhead of maintaining such
information is considered prohibitive.
( End of rationale.)
Note that MPI_WIN_SYNC may be used within a passive
target epoch to synchronize the private and public window copies
(that is, updates to one are made visible to the other).
In the MPI_WIN_UNIFIED memory model, the rules are simpler because the public and private windows are the same. However, there are restrictions to avoid concurrent access to the same memory locations by different processes. The rules that a program with a well-defined outcome must obey in this case are:
Advice to users.
Some compiler optimizations can result in code that
maintains the sequential semantics of the program, but violates
this rule
by introducing temporary values into locations in memory. Most
compilers only apply such transformations under very high levels of
optimization and users should be aware that such aggressive optimization
may produce unexpected results.
( End of advice to users.)
3.
Updating a location in the
window with a store operation
that is also the target of a remote read (but not update) is valid
(not erroneous) but the precise result will depend on the behavior
of the implementation. Store
updates will appear in
memory, but there are no atomicity or ordering guarantees if
more than one byte is updated. Updates are stable in the sense that
once data appears in memory, the data remains until replaced by
another update. This permits
updates to memory
with store operations
without requiring an RMA epoch. Users are cautioned that remote accesses to
a window that is updated by the local process has defined
behavior only if the other rules given here and
elsewhere in this chapter
are followed.
4.
A location in a window must not be accessed as a
target of an RMA
operation once an update to that location has started and until the
update completes at the target. There is one
exception to this rule: in the case where the same location is updated
by two concurrent accumulates with the same
predefined datatype on the same window. Additional restrictions on the
operation apply; see the info key accumulate_ops in
Section Window Creation
.
5.
A put or accumulate must not access a target
window once a store, put, or
accumulate update to another (overlapping) target window
has started on the same location in the target window and until the update
completes at the target window.
Conversely, a store operation
to a location in a window must not start once a put or
accumulate update to the same location in that target window has started
and until the put or accumulate
update completes at the target.
In the unified memory model, in the case where
the window is in shared memory, MPI_WIN_SYNC can be used to order
store operations and make store updates to the window visible to
other processes and threads. Use of this routine is necessary to
ensure portable behavior when point-to-point, collective, or
shared memory synchronization is used in place of an RMA
synchronization routine. MPI_WIN_SYNC should be called by the
writer before the non-RMA synchronization operation and by the
reader after the non-RMA synchronization, as shown in
Example Examples
.
( End of advice to users.)
A program that violates these rules has undefined behavior.
Advice to users.
A user can write correct programs by following the following rules:
With the post-start synchronization, the target process can tell the origin process that its window is now ready for RMA access; with the complete-wait synchronization, the origin process can tell the target process that it has finished its RMA accesses to the window.
The RMA synchronization operations define when updates are guaranteed
to become visible in public and private windows. Updates may become
visible earlier, but such behavior is implementation dependent.
( End of advice to users.)
The semantics are illustrated by the following examples:
Example
The following example demonstrates updating a memory location inside a
window for the separate memory model, according to
Rule Semantics and Correctness
. The MPI_WIN_LOCK and
MPI_WIN_UNLOCK calls around the store to X in
process B are necessary
to ensure consistency between the public and private copies of the
window.
Process A: Process B: window location X MPI_Win_lock(EXCLUSIVE,B) store X /* local update to private copy of B */ MPI_Win_unlock(B) /* now visible in public window copy */ MPI_Barrier MPI_Barrier MPI_Win_lock(EXCLUSIVE,B) MPI_Get(X) /* ok, read from public window */ MPI_Win_unlock(B)
Example
In the RMA unified model, although the public and private copies
of the windows are synchronized, caution must be used when
combining load/stores and multi-process synchronization.
Although the following example appears correct, the compiler or
hardware may delay the store to X after the barrier, possibly
resulting in the MPI_GET returning
an incorrect value
of X.
Process A: Process B: window location X store X /* update to private & public copy of B */ MPI_Barrier MPI_Barrier MPI_Win_lock_all MPI_Get(X) /* ok, read from window */ MPI_Win_flush_local(B) /* read value in X */ MPI_Win_unlock_allMPI_BARRIER provides process synchronization, but not memory synchronization. The example could potentially be made safe through the use of compiler- and hardware-specific notations to ensure the store to X occurs before process B enters the MPI_BARRIER. The use of one-sided synchronization calls, as shown in Example Semantics and Correctness , also ensures the correct result.
Example
The following example demonstrates the reading of a memory location
updated by a remote process (Rule Semantics and Correctness
) in
the RMA separate memory model. Although the
MPI_WIN_UNLOCK on process A and the MPI_BARRIER
ensure that the public copy on process B reflects the updated value of X,
the call to MPI_WIN_LOCK by process B is necessary to
synchronize the private copy with the public copy.
Process A: Process B: window location X MPI_Win_lock(EXCLUSIVE,B) MPI_Put(X) /* update to public window */ MPI_Win_unlock(B) MPI_Barrier MPI_Barrier MPI_Win_lock(EXCLUSIVE,B) /* now visible in private copy of B */ load X MPI_Win_unlock(B)Note that in this example, the barrier is not critical to the semantic correctness. The use of exclusive locks guarantees a remote process will not modify the public copy after MPI_WIN_LOCK synchronizes the private and public copies. A polling implementation looking for changes in X on process B would be semantically correct. The barrier is required to ensure that process A performs the put operation before process B performs the load of X.
Example
Similar to Example Semantics and Correctness
, the following example
is unsafe even in the unified model, because the load of X can not be
guaranteed to occur after the MPI_BARRIER. While Process B
does not need to explicitly synchronize the public and private copies
through MPI_WIN_LOCK as the MPI_PUT will update
both the public and private copies of the window, the scheduling of
the load could result in old values of X being returned. Compiler and hardware
specific notations could ensure the load occurs after the data is updated, or
explicit one-sided synchronization calls can be used to ensure the proper result.
Process A: Process B: window location X MPI_Win_lock_all MPI_Put(X) /* update to window */ MPI_Win_flush(B) MPI_Barrier MPI_Barrier load X MPI_Win_unlock_all
Example
The following example further clarifies
Rule Semantics and Correctness
. MPI_WIN_LOCK and
MPI_WIN_LOCK_ALL do not update the public copy of
a window with changes to the private copy. Therefore, there is no
guarantee that process A in the
following sequence will see the value of X as updated by the local
store by process B before the lock.
Process A: Process B: window location X store X /* update to private copy of B */ MPI_Win_lock(SHARED,B) MPI_Barrier MPI_Barrier MPI_Win_lock(SHARED,B) MPI_Get(X) /* X may be the X before the store */ MPI_Win_unlock(B) MPI_Win_unlock(B) /* update on X now visible in public window */The addition of an MPI_WIN_SYNC before the call to MPI_BARRIER by process B would guarantee process A would see the updated value of X, as the public copy of the window would be explicitly synchronized with the private copy.
Example
Similar to the previous example, Rule Semantics and Correctness
can
have unexpected implications for general active target synchronization
with the RMA separate memory model. It is not guaranteed
that process B reads the value of X as per the local update by process
A, because neither MPI_WIN_WAIT nor
MPI_WIN_COMPLETE calls by process A ensure visibility in
the public window copy.
Process A: Process B: window location X window location Y store Y MPI_Win_post(A,B) /* Y visible in public window */ MPI_Win_start(A) MPI_Win_start(A) store X /* update to private window */ MPI_Win_complete MPI_Win_complete MPI_Win_wait /* update on X may not yet visible in public window */ MPI_Barrier MPI_Barrier MPI_Win_lock(EXCLUSIVE,A) MPI_Get(X) /* may return an obsolete value */ MPI_Get(Y) MPI_Win_unlock(A)To allow process B to read the value of X stored by A the local store must be replaced by a local MPI_PUT that updates the public window copy. Note that by this replacement X may become visible in the private copy of process A only after the MPI_WIN_WAIT call in process A. The update to Y made before the MPI_WIN_POST call is visible in the public window after the MPI_WIN_POST call and therefore process B will read the proper value of Y. The MPI_GET(Y) call could be moved to the epoch started by the MPI_WIN_START operation, and process B would still get the value stored by process A.
Example
The following example demonstrates the interaction of general
active target synchronization with local read operations with the
RMA separate memory model. Rules Semantics and Correctness
and Semantics and Correctness
do not guarantee that the
private copy of X at process B has been updated before the load takes place.
Process A: Process B: window location X MPI_Win_lock(EXCLUSIVE,B) MPI_Put(X) /* update to public window */ MPI_Win_unlock(B) MPI_Barrier MPI_Barrier MPI_Win_post(B) MPI_Win_start(B) load X /* access to private window */ /* may return an obsolete value */ MPI_Win_complete MPI_Win_waitTo ensure that the value put by process A is read, the local load must be replaced with a local MPI_GET operation, or must be placed after the call to MPI_WIN_WAIT.


[§460J-28] Administrative penalties. Any person who violates this chapter or the rules adopted pursuant thereto may be fined not more than $2,500 for each violation. [L 1986, c 126, pt of §7]


Toggle navigation
Players
Sorted by Rating
Sorted by Name
Statistics
Pairings
Standing
Tables
Schedule
Cross table by ID
Cross table by score
Reports
McGill Explosive Chess I


Fortran Compiler
About
Contact
PROGRAM GOKE IMPLICIT NONE WRITE(*,*)"HELLO wORLD" STOP END PROGRAM GOKE
Compile & Run
Clear


influenza health Yes pandemic willing willingness comply population face public {border-style Health compliance likely px;} #ffffff;} <. reported behaviors protective event wear SARS levels questions data psychological threat A$–k NSW associated general status Australian Hong high perception receive response vaccination factors Australia High Kong analysis anticipated avian higher mask responses risk English Extremely/very Pandemic age certificate extremely/very isolate language px; vaccination, value very/extremely {font-family Infect behaviors. concern font-size module outbreak research respondents study survey using Data Dis Survey communication distress double; formal household indicated logistic married number perceived quarantine self-rated use wearing (OR) Gender JTF Lau School Tsui University adjusted behavior border-color border-width care changes comply. concerned future increased influence key lower masks measures odds pandemic. people possibility question report seasonal significant social solid; unadjusted {font-style {font-weight >A$k (before (defined (paid Adjusted Age BMC Born Children Employed Factors Female Good Highest Household Independent Kim Life Living Location Male Management Marital Married Rural Seperated/divorced Speak Studies TAFE Table Unadjusted Urban Widowed addition, bold certificate/Diploma coded collab: courier; degree/equivalent em; factors, income influenza, mask, measure modelling need perceptions pt;} qualification ratios region) related reporting respiratory school self/family spread state tax) unpaid) used variable willing,’