Where DI comes into play - For example, now in sort algorithm we are using BubbleSort, and if we want to change to QuickSort it can be done with very little code change in spring framework.
"When you annotate (@Configuration, @Component, @Controller, @RestController etc..)the classes in spring it creates the beans and stored in application context. Using @Autowired, spring injects references of the objects in the class with @Autowired annotation. "
if BubbleSort implements Sort, QuickSort implements Sort and we have used
@Autowired Sort s; then spring doesn't know which bean to inject then use (solution 1) Sort s; public void methodName(Sort quickSort){ this.s = quickSort;} (solution 2) use @Primary on class level. (solution 3) use @Qualifier annotation.
lets say in application.properties file there is app.value.username = "Velma". use @Value(${app.value.username}") private String username; Spring will inject the username - Velma into username attribute.
Using annotations @Controller, @Service, @Repository, @Configuration, @SpringBootApplication on classes - spring creates objects(beans) and put in to application context.
"If we don't want to create beans using annotations or if we don't have source code to annotate then we should/ can create a configuration class." for example @Configuration public class RestConfig{ @Bean public Sort quickSort(){ return new QuickSort(); - lets say value = 10001 } @Bean public Sort bubbleSort(){ quicksort(); value is also 10001 return new BubbleSort(); } NOTE: "Return value of bean in configuration class is cache", where as for others like component it is not cached value is different for Component classes.


Skill Sync
{{i.title}}
{{ data.item.name }}
Public Feed
See what others are thinking about
2019 CodeU Team48


--- layout: archive title: Zulip Chat Archive permalink: /stream/113489-new-members/topic/simp.20and.20nats.html ---
So it used to be that you could use simp and unfold to simplify expresions like "succ n + (succ m * 2) ^ 2" then type classes made it so you had to use unfold to get it to work, and now it just seems immposible and you have to use exposed lemmas, which seems really ..tedious? low level? Am I missing something like "omega" in coq?
Nah. You could get lucky and see if linarith
will close your goal. Otherwise, port of Presburger arithmetic solver welcome.
I don't think omega
would handle this, because it involves multiplication.
When you say "simplify", what would you like the simplified expression to look like?
ring
may well help
Is this the omega
that @Seul Baek has been working on?
omega
will unfold small multiplications up to some small number, like 10 * n = n + n + n + n + n + ...
Whatever the OP wants to do, surely ring
will do it.
oh, right. you could add https://github.com/skbaek/omega to your leanpkg and see if it works
import tactic.ring open nat example (m n : ℕ) : succ n + (succ m * 2) ^ 2 = n + 4 * m ^ 2 + 8 * m + 5 := by simp [succ_eq_add_one]; ring
ring
apparently won't deal with succ m
so we have to change it to m + 1
first
Thanks!
How does one use ring? It doesn't seem to ever work.
If you are proving an equality involving *
and +
and -
and powers then ring
works
if there is stuff like nat.succ
or other domain specific things then you have to get rid of them first
I think we could afford to add support specifically for nat.succ
because it comes up so often.
Ring proves equalities. https://xenaproject.wordpress.com/2018/06/13/ab3/
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


{% extends 'management/base.html' %} {% load static %} {% load crispy_forms_filters %} {% block head %} {% endblock %} {% block content %}
Dear,This is a reminder that the {title} election has just began. So you can now start voting for your favourite candidates on {url}. The access code can be found in the invitation email. Please be reminded that you can only vote until {end_time_en} on the {end_date_en}. Best regards, Your awesome Organizers
{{ form.remind_text|as_crispy_field }}


--- layout: post authors: ["Roman Valls Guimera"] title: "Software and Data Carpentry Workshop in Stockholm" date: 2015-12-09 time: "19:00:00" tags: ["Workshops"] ---
On April 14, three Software Carpentry Instructors from Stockholm, Radovan Bast, Olav Vahtras and myself got an email from Greg Wilson:
Subject: Any interest in putting together a workshop for Stockholm this summer?
After getting the green light from my current employer, it did not take long to add Oxana Sachenkova to the team and start planning the logistics, lessons, and official PhD-level university credits and to raise some money to support the event.
Since we recently received our instructor training and had some experience with a past scientific Python workshop and a previous edition of Software Carpentry, we decided to go for a two day workshop:
That is how the idea to do Carpentry with Software and Data came into fruition by the end of November 2015. After innumerable emails, talks, and commits the event was on the forge. Also the national Swedish bioinformatics communities BILS and WABI supported us. We would like to thank both of the organisations for their financial support.
For day one, Olav had some interactive Python console sessions showing basic Python data structures and control mechanisms. Following up, Radovan prepared some excellent TDD lessons inspired by three sources:
The Python Koans.
Some ideas borrowed from BioPython's comprehensive testsuite.
A late addition from an upcoming SWC TDD lesson, released just a few days before our workshop.
Teaching basic Git, GitHub, TravisCI and Coveralls in such a short time was challenging for the instructors but had a very good reception from the students side.
While the infamous installation problem is still an issue, students managed to follow through the lessons; their typical Python installation issues were mostly solved by a proper installation of Miniconda.
The SWC installation tests mostly distracted students since packages not being used in the workshop where flagged as uninstalled/failed (i.e., EasyMercurial). In general I perceived that students were getting overwhelmed by too much information from SWC default guides and stopped following up and reading the instructions early. We need more TL;DR's in Software and Data Carpentry, perhaps starting with the workshop template.
The morning was dedicated to briefing students on the Pandas dataframe with Ethan White's python-ecology dataset. Due to time constraints the merging and concatenation of dataframes was not covered but was pointed out in the lesson. After that, the students ha enough knowledge to followup on Oxana's Gene Expression dataset, for which there are exercises for those students willing to earn Swedish university credits. After some glitches with Python 2 vs Python 3 Jupyter notebooks, students got to know how to analyze data from the FANTOM5 consortium.
After getting some expression heatmaps and good insight from Oxana, Ahmed KachKach, currently interning at Spotify AB machine learning division, delighted the audience with a detailed analysis of a toy dataset on breast cancer by using an extremely well documented introduction to machine learning notebook. In order to explain PCA graphically to students, Ahmed used an excellent web visualization to illustrate how variable decomposition/projection works in PCA.
Right after that machine learning introduction, I showed how one can enact reproducible (and interactive!) notebooks via the mybinder.org service by exploring a small scikit-allel dataset. More visualization techniques were shown via my current explorations of HivePlots as an alternative way of visualizing structural genomic variations in cancer samples. I also had a talk prepared about structural variations processed with bcbio, but in the interest of time, I saved it for another event :)
Last but not least, Mikael Huss went through a fantastic notebook showing some gene expression prediction techniques and clever feature engineering from his current efforts at WABI.
A surprising early realization of this workshop is how high demand those courses could be: only a few minutes after announcing the event, we got around 40 individuals interested and signed up. The retention changed over time due to cancellations, but we managed to **run the workshop with 35+ participants. Regarding attendance, thanks to link shorteners on our announcement emails and twitter we could track the “funnel” of students that showed interest all the way down to those that were commited to actually show up and complete the courses.
In our post-assessment polls we got an average rating of 8 over 10 on “General satisfaction with the workshop”. Here are some selected comments:
I learned a lot of things these two days and the workshop really made me more motivated to use pandas next day in the office. :D
Overall it was a very nicely arranged and well prepared workshop. My only suggestion would be to simplify a bit the exercises for day 2 (perhaps by introducing some intermediary steps between two problems). Thanks for arranging such a nice workshop.
great event, I'll recommend it further, should be on regular (annual?) basis.
And also some things to look after in the future:
I enjoyed particularly the first day, particularly the list of challenges/exercises that looked quite overwhelming at first but turned out to be manageable. Also very much appreciated: collection of ideas and questions on etherpad, post-its to request help. It would have been even better with little stricter time management.
My Python knowledge was not high enough to follow. exercise.py was nice to learn Python, but didn't help to learn testing process (I was stuck with the exercises). Other exercise had too difficult instructions. The python introduction was at a very basic level but the tasks were at intermediate or above level. This needs adjustment.
And again, not putting too much material in one day, no matter how exciting it sounds at first while preparing the lessons:
The first day was great (11/10). Intro to Python was too basic for me, but I understand it was necessary for some participants of the workshop. Intro to Git, test-driven development etc. was very well performed and I learned a lot. Second day was pretty good (7/10), but too hurried. I feel that there were too many things squeezed into the schedule. The visualization lab had a good premise, but also suffered from too little time.


Chapter 22 Functions
22.1 Making some R functions
Let’s write some simple R functions to convert temperatures, and later to play with text.
A temperature in Celsius is converted to one in Kelvin by adding 273.15. (A temperature of \(-273.15\) Celsius, 0 Kelvin, is the “absolute zero” temperature that nothing can be colder than.) Write a function called
c_to_k
that converts an input Celsius temperature to one in Kelvin, and test that it works.Write a function to convert a Fahrenheit temperature to Celsius. The way you do that is to subtract 32 and then multiply by \(5/9\).
Using the functions you already wrote, write a function to convert an input Fahrenheit temperature to Kelvin.
Rewrite your Fahrenheit-to-Celsius convertor to take a suitable default value and check that it works as a default.
What happens if you feed your Fahrenheit-to-Celsius convertor a vector of Fahrenheit temperatures? What if you use it in a
mutate
?Write another function called
wrap
that takes two arguments: a piece of text calledtext
, which defaults tohello
, and another piece of text calledoutside
, which defaults to*
. The function returnstext
with the textoutside
placed before and after, so that calling the function with the defaults should return*hello*
. To do this, you can usestr_c
fromstringr
(loaded with thetidyverse
) which places its text arguments side by side and glues them together into one piece of text. Test your function briefly.What happens if you want to change the default
outside
but use the default fortext
? How do you make sure that happens? Explore.What happens if you feed your function
wrap
a vector for either of its arguments? What about if you use it in amutate
?
22.2 The Collatz sequence
The Collatz sequence is a sequence of integers \(x_1, x_2, \ldots\) defined in a deceptively simple way: if \(x_n\) is the current term of the sequence, then \(x_{n+1}\) is defined as \(x_n/2\) if \(x_n\) is even, and \(3x_n+1\) if \(x_n\) is odd. We are interested in understanding how this sequence behaves; for example, what happens to it as \(n\) gets large, for different choices of the first term \(x_1\)? We will explore this numerically with R; the ambitious among you might like to look into the mathematics of it.
What happens to the sequence when it reaches 4? What would be a sensible way of defining where it ends? Explain briefly.
Write an R function called
is_odd
that returnsTRUE
if its input is an odd number andFALSE
if it is even (you can assume that the input is an integer and not a decimal number). To do that, you can use the function%%
wherea %% b
is the remainder whena
is divided byb
. To think about oddness or evenness, consider the remainder when you divide by 2.Write an R function called
hotpo1
35 that takes an integer as input and returns the next number in the Collatz sequence. To do this, use the function you just wrote that determines whether a number is even or odd.Now write a function
hotpo
that will return the whole Collatz sequence for an input \(x_1\). For this, assume that you will eventually get to 1.Write two (very small) functions that take an entire sequence as input and return (i) the length of the sequence and (ii) the maximum value it attains.
Make a data frame consisting of the values 11 through 20, and, using
tidyverse
ideas, obtain a data frame containing the Collatz sequences starting at each of those values, along with their lengths and their maximum values. Which sequence is longest? Which one goes up highest?
22.3 Coefficient of VariationF
The coefficient of variation of a vector x
is defined as the standard deviation of x
divided by the mean of x
.
Write a function called
cv
that calculates the coefficient of variation of its input and returns the result. You should use base R’s functions that reliably compute the pieces that you need.Use your function to find the coefficient of variation of the set of integers 1 through 5.
Define a vector as follows:
What is its coefficient of variation, according to your function? Does this make sense? Why did this happen? Explain briefly.
- Most people only calculate a coefficient of variation if there are no negative numbers. Rewrite your function so that it gives an error if there are any negative numbers in the input, and test it with the vector
v
above. Hint: you might need to adderror=TRUE
to your chunk header to allow your document to preview/knit (inside the curly brackets at the top of the chunk, after a comma).
22.4 Rescaling
Suppose we have this vector of values:
## [1] 10 14 11
We want to scale these so that the smallest value is 0 and the largest is 1. We are going to be doing this a lot, so we are going to write a function that will work for any input.
Using a copy of my
z
, work outmin(z)
andmax(z)
. What do they do? Explain (very) briefly.What do these lines of code do, using the same
z
that I had? Run them and see, and describe briefly whats
contains.
Write a function called
rescale
that implements the calculation above, for any input vector calledx
. (Note that I changed the name.)Test your function on my
z
, and on another vector of your choosing. Explain briefly why the answer you get from your vector makes sense.What happens if your input to
rescale
is a vector of numbers all the same? Give an example. Rewrite your function to intercept this case and give a helpful error message.Make a dataframe (containing any numeric values), and in it create a new column containing the rescaled version of one of its columns, using your function. Show your result.
We might want to rescale the input not to be between 0 and 1, but between two values
a
andb
that we specify as input. Ifa
and/orb
are not given, we want to use the values 0 fora
and 1 forb
. Rewrite your function to rescale the input to be betweena
andb
instead of 0 and 1. Hint: allow your function to produce values between 0 and 1 as before, and then note that if all the values in a vectors
are between 0 and 1, then all the values ina+(b-a)*s
are between \(a\) and \(b\).Test your new function two or more times, on input where you know or can guess what the output is going to be. In each case, explain briefly why your output makes sense.
My solutions follow:
22.5 Making some R functions
Let’s write some simple R functions to convert temperatures, and later to play with text.
- A temperature in Celsius is converted to one in Kelvin by
adding 273.15. (A temperature of \(-273.15\) Celsius, 0 Kelvin, is the “absolute zero”
temperature that nothing can be colder than.) Write a
function called
c_to_k
that converts an input Celsius temperature to one in Kelvin, and test that it works.
Solution
This is mostly an exercise in structuring your function
correctly. Let’s call the input C
(uppercase C, since
lowercase c has a special meaning to R):
## [1] 273.15
## [1] 293.15
This is the simplest way to do it: the last line of the function, if calculated but not saved, is the value that gets returned to the outside world. The checks suggest that it worked.
If you’re used to Python or similar, you might prefer to calculate the value to be returned and then return it. You can do that in R too:
## [1] 273.15
## [1] 293.15
That works just as well, and for the rest of this question, you can go either way.36
\(\blacksquare\)
- Write a function to convert a Fahrenheit temperature to Celsius. The way you do that is to subtract 32 and then multiply by \(5/9\).
Solution
On the model of the previous one, we should call this
f_to_c
. I’m going to return the last line, but you can
save the calculated value and return that instead:
## [1] 0
## [1] 10
## [1] 20
Americans are very good at saying things like “temperatures in the 50s”, which don’t mean much to me, so I like to have benchmarks to work with: these are the Fahrenheit versions of 0, 10, and 20 Celsius.
Thus “in the 50s” means “between about 10 and 15 Celsius”.
\(\blacksquare\)
- Using the functions you already wrote, write a function to convert an input Fahrenheit temperature to Kelvin.
Solution
This implies that you can piggy-back on the functions you just wrote, which goes as below. First you convert the Fahrenheit to Celsius, and then you convert that to Kelvin. (This is less error-prone than trying to use algebra to get a formula for this conversion and then implementing that):
## [1] 273.15
## [1] 293.15
These check because in Celsius they are 0 and 20 and we found the Kelvin equivalents of those to be these values earlier.
I wrote this one with a return
because I thought it made the
structure clearer: run one function, save the result, run another
function, save the result, then return what you’ve got.
\(\blacksquare\)
- Rewrite your Fahrenheit-to-Celsius convertor to take a suitable default value and check that it works as a default.
Solution
You can choose any default you like. I’ll take a default of 68 (what I would call “a nice day”):
## [1] 20
## [1] 20
The change is in the top line of the function. You see the result: if we run it without an input, we get the same answer as if the input had been 68.
\(\blacksquare\)
- What happens if you feed your Fahrenheit-to-Celsius convertor
a vector of Fahrenheit temperatures? What if you use it in a
mutate
?
Solution
Try it and see:
## [1] 30 40 50 60 70 80
## [1] -1.111111 4.444444 10.000000 15.555556 21.111111 26.666667
Each of the Fahrenheit temperatures gets converted into a Celsius one. This is perhaps more useful in a data frame, thus:
## # A tibble: 6 x 2
## temps celsius
## <dbl> <dbl>
## 1 30 -1.11
## 2 40 4.44
## 3 50 10
## 4 60 15.6
## 5 70 21.1
## 6 80 26.7
All the temperatures are side-by-side with their equivalents.
Here’s another way to do the above:
temps <- seq(30, 80, 10)
temps %>%
enframe(value = "fahrenheit") %>%
mutate(celsius = f_to_c(temps))
## # A tibble: 6 x 3
## name fahrenheit celsius
## <int> <dbl> <dbl>
## 1 1 30 -1.11
## 2 2 40 4.44
## 3 3 50 10
## 4 4 60 15.6
## 5 5 70 21.1
## 6 6 80 26.7
enframe
creates a two-column data frame out of a vector (like
temps
). A vector can have “names”, in which case they’ll be
used as the name
column; the values will go in a column
called value
unless you rename it, as I did.
\(\blacksquare\)
- Write another function called
wrap
that takes two arguments: a piece of text calledtext
, which defaults tohello
, and another piece of text calledoutside
, which defaults to*
. The function returnstext
with the textoutside
placed before and after, so that calling the function with the defaults should return*hello*
. To do this, you can usestr_c
fromstringr
(loaded with thetidyverse
) which places its text arguments side by side and glues them together into one piece of text. Test your function briefly.
Solution
This:
I can run this with the defaults:
## [1] "*hello*"
or with text of my choosing:
## [1] "_goodbye_"
I think that’s what I meant by “test briefly”.
\(\blacksquare\)
- What happens if you want to change the default
outside
but use the default fortext
? How do you make sure that happens? Explore.
Solution
The obvious thing is this, which doesn’t work:
## [1] "*!*"
This takes text
to be !
, and outside
to be the default. How do we get outside
to be !
instead? The key is to specify the input by name:
## [1] "!hello!"
This correctly uses the default for text
.
If you specify inputs without names, they are
taken to be in the order that they appear in the function
definition. As soon as they get out of order, which typically happens
by using the default for something early in the list, as we did here
for text
, you have to specify names for anything that comes
after that. These are the names you put on the function’s top line.
You can always use names:
## [1] "**thing**"
and if you use names, they don’t even have to be in order:
## [1] "!?fred!?"
\(\blacksquare\)
- What happens if you feed your function
wrap
a vector for either of its arguments? What about if you use it in amutate
?
Solution
Let’s try:
## [1] "*a*" "*b*" "*c*"
## [1] "*hello*" "!hello!"
If one of the inputs is a vector, the other one gets “recycled” as many times as the vector is long. What if they’re both vectors?
## [1] "*a*" "!b!" "*c*" "!d!"
This uses the two inputs in parallel, repeating the short one as needed. But this, though it works, gives a warning:
## Warning in stri_c(..., sep = sep, collapse = collapse, ignore_null = TRUE): longer object length is not a multiple of shorter object length
## [1] "*a*" "!b!" "*c*"
This is because the shorter vector (of length 2 here) doesn’t go evenly into the longer one (length 3). It gives a warning because this is probably not what you wanted.
The mutate
thing is easier, because all the columns in a data
frame have to be the same length. LETTERS
is a vector with
the uppercase letters in it:
tibble(mytext = LETTERS[1:6], myout = c("*", "**", "!", "!!", "_", "__")) %>%
mutate(newthing = wrap(mytext, myout))
## # A tibble: 6 x 3
## mytext myout newthing
## <chr> <chr> <chr>
## 1 A * *A*
## 2 B ** **B**
## 3 C ! !C!
## 4 D !! !!D!!
## 5 E _ _E_
## 6 F __ __F__
\(\blacksquare\)
22.6 The Collatz sequence
The Collatz sequence is a sequence of integers \(x_1, x_2, \ldots\) defined in a deceptively simple way: if \(x_n\) is the current term of the sequence, then \(x_{n+1}\) is defined as \(x_n/2\) if \(x_n\) is even, and \(3x_n+1\) if \(x_n\) is odd. We are interested in understanding how this sequence behaves; for example, what happens to it as \(n\) gets large, for different choices of the first term \(x_1\)? We will explore this numerically with R; the ambitious among you might like to look into the mathematics of it.
- What happens to the sequence when it reaches 4? What would be a sensible way of defining where it ends? Explain briefly.
Solution
When the sequence reaches 4 (that is, when its current term is 4), the next term is 2 and the one after that is 1. Then the following term is 4 again (\((3 \times 1)+1\)) and then it repeats indefinitely, \(4, 2, 1, 4, 2, 1, \ldots\). I think a sensible way to define where the sequence ends is to say “when it reaches 1”, since if you start at 2 you’ll never reach 4 (so “when it reaches 4” won’t work), and it seems at least plausible that it will hit the cycle 4, 2, 1 sometime.
\(\blacksquare\)
- Write an R function called
is_odd
that returnsTRUE
if its input is an odd number andFALSE
if it is even (you can assume that the input is an integer and not a decimal number). To do that, you can use the function%%
wherea %% b
is the remainder whena
is divided byb
. To think about oddness or evenness, consider the remainder when you divide by 2.
Solution
Let’s try this out. For example, 5 is odd and 6 is even, so
## [1] 1
## [1] 0
When a number is odd, its remainder on dividing by 2 is 1, and when
even, the remainder is 0. There is an additional shortcut here in that
1 is the numeric value of TRUE
and 0 of FALSE
, so
all we have to do is calculate the remainder on dividing by 2, turn it
into a logical
, and return it:
You probably haven’t seen as.logical
before, but it’s the
same idea as as.numeric
: turn something that looks like a
TRUE
or FALSE
into something that actually
is.
We should test it:
## [1] TRUE
## [1] FALSE
## [1] FALSE
0 is usually considered an even number, so this is good.
\(\blacksquare\)
- Write an R function called
hotpo1
37 that takes an integer as input and returns the next number in the Collatz sequence. To do this, use the function you just wrote that determines whether a number is even or odd.
Solution
The logic is “if the input is odd, return 3 times it plus 1, otherwise return half of it”.
The R structure is an
if-then-else
:
In R, the condition that is tested goes in brackets, and then if the
value-if-true and the value-if-false are single statements, you just
type them. (If they are more complicated than that, you put them in
curly brackets.) Now you see the value of writing is_odd
earlier; this code almost looks like the English-language description
of the sequence. If we had not written is_odd
before, the
condition would have looked something like
which would have been a lot harder to read.
All right, let’s try that out:
## [1] 2
## [1] 22
## [1] 12
That looks all right so far.
\(\blacksquare\)
- Now write a function
hotpo
that will return the whole Collatz sequence for an input \(x_1\). For this, assume that you will eventually get to 1.
Solution
This is a loop, but not a for
loop (or something that we
could do rowwise
), because we don’t know how many
times we have to go around. This is the kind of thing that we
should use a while
loop for:
“keep going while a condition is true”.
In this case, we should keep going if we haven’t reached 1 yet. If
we haven’t reached 1, we should generate the next value of the
sequence and glue it onto what we have so far. To initialize the
sequence, we start with the input value. There is an R trick to
glue a value onto the sequence, which is to use c
with a
vector and a value, and save it back into the vector:
hotpo <- function(x) {
sequence <- x
term <- x
while (term > 1) {
term <- hotpo1(term)
sequence <- c(sequence, term)
}
sequence
}
I use term
to hold the current term of the sequence, and
overwrite it with the next one (since I don’t need the old one any
more).
Does it work?
## [1] 4 2 1
## [1] 12 6 3 10 5 16 8 4 2 1
## [1] 97 292 146 73 220 110 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263<PHONE_NUMBER> 593 1780<PHONE_NUMBER> 668 334 167 502 251<PHONE_NUMBER> 566 283<PHONE_NUMBER> 638 319<PHONE_NUMBER> 719 2158
## [70] 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732<PHONE_NUMBER> 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1
97 is a wild ride, but it does eventually get to 1.
Extra: where I originally saw this, which was “Metamagical Themas” by Douglas Hofstadter, he was illustrating the programming language Lisp and the process of recursion, whereby you define a function in terms of itself. This one is a natural for that, because the Collatz sequence starting at \(x\) is \(x\) along with the Collatz sequence starting at the next term. For example, if you start at 12, the next term is 6, so that the Collatz sequence starting at 12 is 12 followed by the Collatz sequence starting at 6. There is no dependence any further back. You can do recursion in R also; there is no problem with a function calling itself:
Recursive functions have two parts: a “base case” that says how you know you are done (the 1 here), and a “recursion” that says how you move to a simpler case, here working out the next term, getting the whole sequence for that, and gluing the input onto the front. It seems paradoxical that you define a function in terms of itself, but what you are doing is calling a simpler sequence, in this case one that is length one shorter than the sequence for the original input. Thus, we hope,38 we will eventually reach 1.
Does it work?
## [1] 12 6 3 10 5 16 8 4 2 1
## [1] 97 292 146 73 220 110 55 166 83 250 125 376 188 94 47 142 71 214 107 322 161 484 242 121 364 182 91 274 137 412 206 103 310 155 466 233 700 350 175 526 263<PHONE_NUMBER> 593 1780<PHONE_NUMBER> 668 334 167 502 251<PHONE_NUMBER> 566 283<PHONE_NUMBER> 638 319<PHONE_NUMBER> 719 2158
## [70] 1079 3238 1619 4858 2429 7288 3644 1822 911 2734 1367 4102 2051 6154 3077 9232 4616 2308 1154 577 1732<PHONE_NUMBER> 650 325 976 488 244 122 61 184 92 46 23 70 35 106 53 160 80 40 20 10 5 16 8 4 2 1
It does.
Recursive functions are often simple to understand, but they are not
always very efficient. They can take a lot of memory, because they
have to handle the intermediate calls to the function, which they have
to save to use later (in the case of hotpo_rec(97)
there are a
lot of those). Recursive functions are often paired with a technique
called “memoization”, where each time you calculate the function’s
value, you save it in another array. The first thing you do in
the recursive function is to check whether you already have the
answer, in which case you just look it up and return it. It was a lot
of work here to calculate the sequence from 97, but if we had saved
the results, we would already have the answers for 292, 146, 73, 220
and so on, and getting those later would be a table lookup rather than
another recursive calculation.
\(\blacksquare\)
- Write two (very small) functions that take an entire sequence as input and return (i) the length of the sequence and (ii) the maximum value it attains.
Solution
These are both one-liners. Call the input whatever you like:
Because they are one-liners, you don’t even need the curly brackets, although there’s no problem if they are there.
Testing:
## [1] 10
## [1] 9232
This checks with what we had before.
\(\blacksquare\)
- Make a data frame consisting of the values 11 through 20, and,
using
tidyverse
ideas, obtain a data frame containing the Collatz sequences starting at each of those values, along with their lengths and their maximum values. Which sequence is longest? Which one goes up highest?
Solution
This one uses rowwise
ideas:39
tibble(x = 11:20) %>%
rowwise %>%
mutate(sequence = list(hotpo(x))) %>%
mutate(length = hotpo_len(sequence)) %>%
mutate(high = hotpo_max(sequence))
## # A tibble: 10 x 4
## # Rowwise:
## x sequence length high
## <int> <list> <int> <dbl>
## 1 11 <dbl [15]> 15 52
## 2 12 <dbl [10]> 10 16
## 3 13 <dbl [10]> 10 40
## 4 14 <dbl [18]> 18 52
## 5 15 <dbl [18]> 18 160
## 6 16 <dbl [5]> 5 16
## 7 17 <dbl [13]> 13 52
## 8 18 <dbl [21]> 21 52
## 9 19 <dbl [21]> 21 88
## 10 20 <dbl [8]> 8 20
First, we obtain a list-column containing the sequences (which is why its calculation needs a list
around it), then two
ordinary columns of their lengths and their maximum values.
The sequences for 18 and 19 are the longest, but the sequence for 15 goes up the highest.
\(\blacksquare\)
22.7 Coefficient of VariationF
The coefficient of variation of a vector x
is defined as the standard deviation of x
divided by the mean of x
.
- Write a function called
cv
that calculates the coefficient of variation of its input and returns the result. You should use base R’s functions that reliably compute the pieces that you need.
Solution
I like to make a function skeleton first to be sure I remember all the pieces. You can do this by making a code chunk, typing fun
, waiting a moment, and selecting the “snippet” that is offered to you. That gives you this, with your cursor on name
:
Give your function a name (I asked you to use cv
), hit tab, enter a name like x for the input, hit tab again, and then fill in the body of the function, to end up with something like this:
I think this is best, for reasons discussed below.
Some observations:
- in the last line of the function, you calculate something, and that something is the thing that gets returned. You do not need to save it in a variable, because then you have to return that variable by having its name alone on the last line.
- R has a
return()
function, but it is bad style to use it to return a value at the end of a function. The time to use it is when you test something early in the function and want to return early with a value like zero or missing without doing any actual calculation. Looking ahead a bit, you might want to return “missing” if the mean is zero before dividing by it, which you could do like this, this being good style:
use the built-in
mean
andsd
rather than trying to roll your own, because they have been tested by many users over a long time and they work. That’s what I meant by “pieces” in the question.you might be tempted to do something like this:
This will work, but it is not a good habit to get into, and thus not best as an answer to this question. This one line of code says three things: “work out the SD of x
”, “work out the mean of x
”, and “divide them by each other”. It is much clearer, for anyone else reading the code (including yourself in six months when you have forgotten what you were thinking) to have the three things one per line, so that anyone reading the code sees that each line does one thing and what that one thing is. There is a reason why production code and code golf are two very different things. Code that is easy to read is also easy to maintain, either by you or others.
- using something other than
mean
andsd
as the names of your intermediate results is a good idea because these names are already used by R (as the names of the functions that compute the mean and SD). Redefining names that R uses can make other code behave unpredictably and cause hard-to-find bugs.40
\(\blacksquare\)
- Use your function to find the coefficient of variation of the set of integers 1 through 5.
Solution
This can be as simple as
## [1] 0.5270463
or, equally good, define this into a vector first:
## [1] 0.5270463
or, displaying a little less understanding, type the five numbers into the vector first (or directly as input to the function):
## [1] 0.5270463
## [1] 0.5270463
\(\blacksquare\)
- Define a vector as follows:
What is its coefficient of variation, according to your function? Does this make sense? Why did this happen? Explain briefly.
Solution
Try it and see:
## [1] 6.248491e+16
A very large number, much bigger than any of the data values; with these human-sized numbers, we’d expect a human-sized coefficient of variation as well.
What actually happened was that the mean of v
is this:
## [1] 4.440892e-17
Zero, or close enough, so that in calculating the coefficient of variation, we divided by something that was (almost) zero and got a result that was (almost) infinite.41
The possibility of getting a zero mean is why most people only calculate a coefficient of variation if all of the numbers are positive, which brings us to the next part:
\(\blacksquare\)
- Most people only calculate a coefficient of variation if there are no negative numbers. Rewrite your function so that it gives an error if there are any negative numbers in the input, and test it with the vector
v
above. Hint: you might need to adderror=TRUE
to your chunk header to allow your document to preview/knit (inside the curly brackets at the top of the chunk, after a comma).
Solution
This is a case for stopifnot
, or of if
coupled with stop
. Check this up front, as the first thing you do before you calculate anything else. As to what to check, there are several possibilities:
- stop if any of the numbers are negative
- continue if all of the numbers are positive
- stop if the smallest number is negative (the smallest number is negative if and only if not all the numbers are positive)
R has functions any
and all
that do what you’d expect:
## [1] 1 2 3 4 5
## [1] TRUE
## [1] FALSE
Are there any numbers greater than 3.5 (yes, 4 and 5); are all the numbers less than 4.5 (no, 5 isn’t).
Cite your sources for these if you use either of them, since this is the first place in the course that I’m mentioning either of them.
Remember that if you use stopifnot
, the condition that goes in there is what has to be true if the function is to run; if you use if
and stop
, the condition is what will stop the function running. With that in mind, I would code my three possibilities above this way. First off, here’s the original:
then, stop if any of the numbers are negative:
cv <- function(x) {
if (any(x<0)) stop("A value is negative")
mean_x <- mean(x)
sd_x <- sd(x)
sd_x/mean_x
}
cv(v)
## Error in cv(v): A value is negative
continue if all the numbers are positive
## Error in cv(v): all(x > 0) is not TRUE
stop if the smallest value is negative
cv <- function(x) {
if (min(x)<0) stop("Smallest value is negative")
mean_x <- mean(x)
sd_x <- sd(x)
sd_x/mean_x
}
cv(v)
## Error in cv(v): Smallest value is negative
There are (at least) three other possibilities: you can negate the logical condition and interchange if/stop
and stopifnot
, thus (at the expense of some clarity of reading):
continue if it is not true that any of the numbers are negative
## Error in cv(v): !any(x < 0) is not TRUE
(you might be thinking of De Morgan’s laws here)
stop if it is not true that all the numbers are positive
cv <- function(x) {
if (!all(x>0)) stop("Not all values are positive")
mean_x <- mean(x)
sd_x <- sd(x)
sd_x/mean_x
}
cv(v)
## Error in cv(v): Not all values are positive
continue if the smallest value is not negative
## Error in cv(v): min(x) >= 0 is not TRUE
or another way to do the last one, a more direct negation of the condition, which at my guess needs some extra brackets:
## Error in cv(v): !(min(x) < 0) is not TRUE
This one is hard to parse: what does that last message mean? I would take a negative off each side and read it as “min of x is negative is TRUE”, but that takes extra effort.
I said that last one needed some extra brackets. This is, I thought, to get the order of operations right (operator precedence); it turns out not to matter because “not” has lower precedence than most other things, so that these do actually work (the “not” is evaluated after the less-than and the other things, so last of all here, even though it appears to be “glued” to the min
):
## [1] FALSE
## [1] TRUE
See this for details. See especially the second set of examples, the ones beginning with “Special operators”, and see especially-especially the comment at the bottom of these examples! That is to say, you should put in the extra brackets unless you also make the case that they are not needed, because anyone reading your code is guaranteed to be confused by it when they read it (including you in six months, because you will not remember the operator priority of “not”).
My take is that one of the first three of the seven possibilities for coding stopifnot
or if
with stop
is the best, since these more obviously encode the condition for continuing or stopping as appropriate. There are two things here: one is that you have to get the code right, but the second is that you have to get the code clear, so that it is obvious to anyone reading it that it does the right thing (once again, this includes you in six months). On that score, the first three alternatives are a direct expression of what you want to achieve, and the last four make it look as if you found a way of coding it that worked and stopped there, without thinking about whether there were any other, clearer or more expressive, possibilities.
\(\blacksquare\)
22.8 Rescaling
Suppose we have this vector of values:
## [1] 10 14 11
We want to scale these so that the smallest value is 0 and the largest is 1. We are going to be doing this a lot, so we are going to write a function that will work for any input.
- Using a copy of my
z
, work outmin(z)
andmax(z)
. What do they do? Explain (very) briefly.
Solution
Simply this – define z
first:
## [1] 10
## [1] 14
They are respectively (and as you would guess) the smallest and largest of the values in z
. (A nice gentle warmup, but I wanted to get you on the right track for what is coming up.)
\(\blacksquare\)
- What do these lines of code do, using the same
z
that I had? Run them and see, and describe briefly whats
contains.
Solution
Here we go:
## [1] 0.00 1.00 0.25
The lowest value became 0, the highest 1, and the other one to something in between. Saying this shows the greatest insight.
Extra: the reason for doing it in three steps rather than one (see below) is (i) it makes it clearer what is going on (and thus makes it less likely that you make a mistake), and (ii) it is more efficient, since my way only finds the minimum once instead of twice. Compare this approach with mine above:
## [1] 0.00 1.00 0.25
More complicated with all the brackets, and two min(z)
. Admittedly the difference here will be thousandths of a second, but why call a function twice when you don’t have to?
\(\blacksquare\)
- Write a function called
rescale
that implements the calculation above, for any input vector calledx
. (Note that I changed the name.)
Solution
Write a function skeleton:
and inside the curly brackets put the code from above, replacing z
with x
everywhere:
You’ll need to make sure your function returns something to the outside world. Either don’t save the last line in s
(as I did here), or save it in s
and then return s
:
or use return()
if you must, but be aware that this is bad style in R (unlike Python, where you need it). The approved way of using return
in R is when you are returning something earlier than the last line of a function, for example, you are testing a simple case first and returning the value that goes with that, before getting down to the serious computation.
Extra: in the spirit of what’s coming up below, you might check first whether the maximum and minimum are the same and return something else if that’s the case:
rescale0 <- function(x) {
lo <- min(x)
hi <- max(x)
if (lo == hi) return(0)
s <- (x - lo) / (hi - lo)
s
}
This is good style; in this case, if lo
and hi
are the same, we want to return something else (zero) to the outside world, and then we do the calculation, knowing that lo
and hi
are different, so that we are sure we are not dividing by zero (but I get ahead of myself).
Doing it this way, there is something to be careful of: a function ought to return a predictable type of thing: numbers, in this case. If you have your function return text on error, like this:
rescale0 <- function(x) {
lo <- min(x)
hi <- max(x)
if (lo == hi) return("High and low need to be different")
s <- (x - lo) / (hi - lo)
s
}
then you can get into trouble:
## [1] 0.00 1.00 0.25
## [1] "High and low need to be different"
The first one is numbers and the second one is text.
\(\blacksquare\)
- Test your function on my
z
, and on another vector of your choosing. Explain briefly why the answer you get from your vector makes sense.
Solution
On my z
:
## [1] 0.00 1.00 0.25
The same values as I got before, so that works.
For your vector, use whatever you like. I think it makes sense to have the values already in order, to make it easier to check. Here’s one possibility:
## [1] 2 3 4 5 6
and then
## [1] 0.00 0.25 0.50 0.75 1.00
The smallest value is 2, which goes to zero; the largest is 6, which goes to 1, and the others are equally spaced between in both the input and the output.
Another possibility is to use a vector with values whose largest and smallest you can clearly see:
## [1] 0.10 0.11 1.00 0.00 0.20
Clearly the smallest value is 0 and the largest is 100. These become 0 and 1, and these particular values make it easy to see what happened: each of the other values got divided by 100.
Some discussion is needed here, in that you need to say something convincing about why your answer is right.
Extra: This is why I had you use a name other than z
for the input to your function. The function can be used on any input, not just the z
that we tested it on. There’s another R-specific reason, which is that you need to be careful about using the named inputs only. Consider this function:
## [1] 20 24 21
Where did z
come from? R used the z
we had before, which is rather dangerous: what if we had a z
lying around from some completely different work? Much better to have a function work with only inputs in the top line:
## [1] 13
## Error in ff(10): argument "z" is missing, with no default
The first time, the two inputs are added together, but the second time it tells you it was expecting a value to use for z
and didn’t see one. Much safer.
\(\blacksquare\)
- What happens if your input to
rescale
is a vector of numbers all the same? Give an example. Rewrite your function to intercept this case and give a helpful error message.
Solution
First, try it and see. Any collection of values all the same will do:
## [1] NaN NaN NaN
NaN
stands for “not a number”. The way we got it is that the minimum and maximum were the same, so our function ended up dividing by zero (in fact, working out zero divided by zero). This is, in R terms, not even an error, but the answer is certainly not helpful.
The easiest way to check inputs is to use stopifnot
to express what should be true if the function is to proceed. Here, we want the maximum and minimum to be different, so:
rescale <- function(x) {
lo <- min(x)
hi <- max(x)
stopifnot(hi != lo)
(x - lo) / (hi - lo)
}
rescale(c(3,3,3))
## Error in rescale(c(3, 3, 3)): hi != lo is not TRUE
This is much clearer: I only have to recall what my hi
and lo
are to see what the problem is.
Extra 1: by calculating and saving the min and max up front, I still only need to calculate them once. If you do it this way:
rescale <- function(x) {
stopifnot(max(x) != min(x))
(x - min(x)) / (max(x) - min(x))
}
rescale(c(3,3,3))
## Error in rescale(c(3, 3, 3)): max(x) != min(x) is not TRUE
you get a slightly more informative error message, but you have calculated the max twice and the min three times for no reason.
Extra 2: stopifnot
is shorthand for this:
rescale <- function(x) {
lo <- min(x)
hi <- max(x)
if (hi == lo) stop("min and max are the same!")
(x - lo) / (hi - lo)
}
rescale(c(3,3,3))
## Error in rescale(c(3, 3, 3)): min and max are the same!
I didn’t show you this, so if you use stop
, you must tell me where you found out about it. This is better than returning some text (see rescale0
above) or printing a message: it’s an error, so you want to make it look like an error. I am very sympathetic to being persuaded that this is better than stopifnot
, because you can customize the message (and, also, you don’t have to go through the double-negative contortions of stopifnot
). Another way to use stopifnot
and get a customized message is this one (that I only learned about right when you were writing this Assignment):
rescale <- function(x) {
lo <- min(x)
hi <- max(x)
stopifnot("high and low must be different" = (hi != lo))
(x - lo) / (hi - lo)
}
rescale(c(3,3,3))
## Error in rescale(c(3, 3, 3)): high and low must be different
This is called a “named argument”, and the name, if given, is used as an error message.
Extra 3: returning to my rescale0
from above:
## function(x) {
## lo <- min(x)
## hi <- max(x)
## if (lo == hi) return("High and low need to be different")
## s <- (x - lo) / (hi - lo)
## s
## }
## <environment: 0x55d70ec82ec0>
this can get you into trouble if you use it in a dataframe. This is a bit complicated, since it has to use list-columns. Here we go:
## # A tibble: 2 x 1
## x
## <list>
## 1 <dbl [3]>
## 2 <dbl [3]>
Just to check that this does contain what you think it does:
## # A tibble: 6 x 1
## x
## <dbl>
## 1 10
## 2 14
## 3 11
## 4 3
## 5 3
## 6 3
So now, for each of those two input vectors, what happens when we run rescale0
on them? This is rowwise
:
## # A tibble: 2 x 2
## # Rowwise:
## x ans
## <list> <list>
## 1 <dbl [3]> <dbl [3]>
## 2 <dbl [3]> <chr [1]>
The first ans
is a vector of 3 numbers, and the second one is one piece of text (the “error message”). I was actually surprised it got this far. So what happens when we unnest
the second column?
## Error: Can't combine `..1$ans` <double> and `..2$ans` <character>.
Now we get a confusing error: it’s here that combining some numbers and some text in one column of a dataframe doesn’t work. To forestall this, we need to go back and rewrite rescale0
to not mix things up. Having it return an error, as the latest version of rescale
does, gives an error here too, but at least we know what it means:
## Error: Problem with `mutate()` column `ans`.
## ℹ `ans = list(rescale(x))`.
## ✖ high and low must be different
## ℹ The error occurred in row 2.
because this is the error we anticipated: it says “somewhere within the list-column x
, specifically in its second row, is a vector where everything is the same”.
\(\blacksquare\)
- Make a dataframe (containing any numeric values), and in it create a new column containing the rescaled version of one of its columns, using your function. Show your result.
Solution
This is less difficult than you might be expecting: make a dataframe with at least one numeric column, and use mutate
:
## # A tibble: 5 x 1
## y
## <int>
## 1 2
## 2 3
## 3 4
## 4 5
## 5 6
and then
## # A tibble: 5 x 2
## y s
## <int> <dbl>
## 1 2 0
## 2 3 0.25
## 3 4 0.5
## 4 5 0.75
## 5 6 1
You can supply the values for what I called y
, or use random numbers. It’s easier for you to check that it has worked if your column playing the role of my y
has not too many values in it.
Extra: this is actually already in the tidyverse
under the name percent_rank
(“percentile ranks”):
## # A tibble: 5 x 2
## y s
## <int> <dbl>
## 1 2 0
## 2 3 0.25
## 3 4 0.5
## 4 5 0.75
## 5 6 1
The value 5, for example, is at the 75th percentile.
\(\blacksquare\)
- We might want to rescale the input not to be between 0 and 1, but between two values
a
andb
that we specify as input. Ifa
and/orb
are not given, we want to use the values 0 fora
and 1 forb
. Rewrite your function to rescale the input to be betweena
andb
instead of 0 and 1. Hint: allow your function to produce values between 0 and 1 as before, and then note that if all the values in a vectors
are between 0 and 1, then all the values ina+(b-a)*s
are between \(a\) and \(b\).
Solution
I’m showing you my thought process in this one. The answer I want from you is the one at the end.
So, start by copying and pasting what you had before:
On the top line, add the extra inputs and their default values. I also changed the name of my function, for reasons you’ll see later:
rescale2 <- function(x, a=0, b=1) {
lo <- min(x)
hi <- max(x)
stopifnot(hi != lo)
(x - lo) / (hi - lo)
}
Save the last line, since we have to do something else with it:
rescale2 <- function(x, a=0, b=1) {
lo <- min(x)
hi <- max(x)
stopifnot(hi != lo)
s <- (x - lo) / (hi - lo)
}
and finally add the calculation in the hint, which we don’t need to save because we are returning it:
rescale2 <- function(x, a=0, b=1) {
lo <- min(x)
hi <- max(x)
stopifnot(hi != lo)
s <- (x - lo) / (hi - lo)
a + (b-a) * s
}
This complete function is what I want to see from you. (You should keep the stopifnot
, because this function will have the exact same problem as the previous one if all the values in x
are the same.)
A better way is to observe that you can call functions inside functions. The function above is now a bit messy since it has several steps. Something that corresponds better to my hint is to call the original rescale
first, and then modify its result:
The logic to this is rather clearly “rescale the input to be between 0 and 1, then rescale that to be between \(a\) and \(b\).” My rescale2
does exactly the same thing, but it’s much less clear that it does so, unless you happen to have in your head how rescale
works. (I think you are more likely to remember, sometime in the future, what rescale
does, compared to precisely how it works.)
That is why rescale3
is better than rescale2
. Remember that you can, and generally should, use functions that have already been written (by you or someone else) as part of functions that do more complex things. See also my second point below.
Extra: there are two important principles about why functions are important:
- they allow you to re-do a calculation on many different inputs (the point I’ve been making up to now)
- by abstracting a calculation into a thing with a name, it makes it easier to understand that calculation’s role in something bigger. The only thing we had to remember in
rescale3
is what the last line did, because the name of the function called on the first line tells us what happens there. This is much easier than remembering what the first four lines ofrescale2
do.
The second principle here is what psychologists call “chunking”: you view a thing like my function rescale
as a single item, rather than as four separate lines of code, and then that single item can be part of something larger (like my rescale3
), and you have a smaller number of things to keep track of.
\(\blacksquare\)
- Test your new function two or more times, on input where you know or can guess what the output is going to be. In each case, explain briefly why your output makes sense.
Solution
I’ll start by using the default values for a
and b
(so I don’t have to specify them):
## [1] 0.00 0.25 0.50 0.75 1.00
## [1] 0.00 0.25 0.50 0.75 1.00
I did both of the variants of my function; of course, you’ll only have one variant.
We got the same answer as before for the same input, so the default values \(a=0, b=1\) look as if they have been used.
Let’s try a different one:
## [1] 10 26 30
## [1] 10 26 30
The lowest value in v
has become 10, and the highest has become 30. (Also, the in-between value 11 was closer to 12 than to 7, and it has become something closer to 30 than to 10.)
Extra: you can also name any of your inputs:
## [1] 10 26 30
and if you name them, you can shuffle the order too:
## [1] 10 26 30
The point of doing more than one test is to check that different aspects of your function all work. Therefore, the best testing here checks that the defaults work, and that the answer is sensible for some different a
and b
(to check that this works as well).
When you write your version of rescale
with the optional inputs, it’s best if you do it so that the things you have to supply (the vector of numbers) is first. If you put a
and b
first, when you want to omit them, you’ll have to call the input vector by name, like this:
## [1] 0.0 0.8 1.0
because otherwise the input vector will be taken to be a
, not what you want.
\(\blacksquare\)
Hotpo is short for half or triple-plus-one.↩
R style is to use the last line of the function for the return value, unless you are jumping out of the function before the end, in which case use
return
.↩Hotpo is short for half or triple-plus-one.↩
Nobody knows whether you always get to 1, but also nobody has ever found a case where you don’t. Collatz’s conjecture, that you will get to 1 eventually, is known to be true for all starting \(x_1\) up to some absurdly large number, but not for all starting points.↩
I should have been more careful in my functions to make sure everything was integers, and, in particular, to do integer division by 2 because I knew that this division was going to come out even.↩
This is something I’ve done in the past and been bitten by, so I am trying to get myself not to do it any more.↩
In computing with decimal numbers, things are almost never exactly zero or exactly infinite; they are very small or very big. The mean here, which you would calculate to be zero, is less than the so-called machine epsilon, which is about 10 to the minus 16 in R (R works in double precision). A mean that small is, to the computer, indistinguishable from zero. It came out that way because the last value is added to a total that is by that point negative, and so you have a loss of accuracy because of subtracting nearly equal quantities. I learned all about this stuff in my first real computer science course, which I think was a numerical math course, some absurd number of years ago. It looks as if this gets taught in CSCC37 these days.↩


{% extends 'fpiweb/base.html' %} {% load bootstrap4 %} {% load qr_codes %} {% comment %} CONTEXT VARIABLES ------------------------------------------------------------------------------- full_box_url Scanned url for full box empty_box_url Scanned url for empty box new_box_url Scanned url for new box empty_box Box object of empty Box, used to build url to box details page. full_box Box object of full Box, used to build url to box details page. next_box_number Used to build url to new box page {% endcomment %} {% block title %}Test Scan{% endblock %} {% block content %}
The purpose of this page is to simulate the stack of boxes that the user is working with. Some of these boxes are in the system, some are not, some don't have labels. QR codes will be displayed so you have something to scan when testing with a cellphone or similar device. This page is only intended for use during development & testing
May want to have box details page redirect to either enter box or fill box screens.
request.session['action'] = {{ request.session.action }}
|
A box that is in the system and is full [Box.product is not None]
Action: Present empty or move box screen
{% qr_code full_box_url %}
|
A new box (box type hasn't been entered)
Action: Present new box screen
{% qr_code new_box_url %}
|
|
A box w/out a label
A number of box number labels will be pre-printed. Add
one of these labels then scan.
|
A box that is in the system and is empty [Box.product is None]
Action: Present new box screen (should this be a fill box screen?)
{% qr_code empty_box_url %}
|


the and Province Limpopo from were Linguatula serrata for nuttalli with African _MN {background posterior South al. anterior Kruger National are present that margin view The specimens study adult buffalo parasites was {border-style (Fig. [Africa]* nymphs sequences Park animals px;} #ffffff;} hook (); Fig. Mpumalanga annular found region right (μm) Cox Table Young body length parasite this al., end rRNA spp. arctica dorsal these accessory lions other spines Africa Vet. all collected examined genetic have infection left magnified they two which among been lion obtained wild Africa. Van [Australia] [Norway] _KF based difference dog electron had infected morphological nuttali reported their (Table also being den due each female hooks microscopy nymph px; reindeer tongue width {font-family Afr. Free Horak Mouse Panthera Res. State annuli belonging between cleft compared could font-size has identification located male not number one phylogenetic piece pores showing (Panthera Assoc. Cape Female Heever Mongoose annulus belong both but different double; human more occurrence only parasite; presence previous referred regions reports rows side species. stages study. tip ventral (#–) (). (a) (ventral (ventral); Africa, All Although Anterior Australia Body Common Connochaetes Iran Lion MN-MN Med. Nymph Rat Rock Scanning border-color border-width differences domestic examination gene hosts however, leo leo) light like pentastomids projections row solid; some sp. species specimen suggesting taurinus terminal than using {font-style {font-weight (on Adult Blue Each Haffner Host Note Posterior Research This Wildebeest Wildl. [Bangladesh] [Iran] _LC analysis animals, arrangement base bold buffalo: capsule cattle characterisation courier; cycle cysts definitive described determined distance em; familiaris first full genital hook. hook; hooks, host including into large length, life linguatulid many may mid minute molecular most mouth mouth, our parasites. parts pentastomid piece; potential provide pt;} respectively. samples scale scanning sensory serrata, showed shown significantly specific spines; studies study, suggested there under vertebrates, view). zebu


Find by blob ID Find by group ID Show samples 2.5 1 0.5 0 +/- m/z range Plot selected blob(s) Back to image


ImPACT uses CILogon 2.0 (COmanage) for Authentication and Authorization
What is CILogon 2.0?
When scientists work together, they use web sites and other software to share their ideas and data.
To ensure the integrity of their work, these systems require the scientists to log in and verify that they
are part of the team working on a particular science problem. Too often, the identity and access verification
process is a stumbling block for the scientists. Scientific research projects are forced to invest time and
effort into developing and supporting Identity and Access Management (IdAM) services, distracting them from
the core goals of their research collaboration. The "CILogon 2.0" project provides an IdAM platform that
enables scientists to work together to meet their IdAM needs more effectively so they can allocate more time
and effort to their core mission of scientific research. To ensure that the project makes a real contribution
to scientific collaborations, the researchers have partnered with the Laser Interferometer Gravitational-Wave
Observatory (LIGO) Scientific Collaboration, the North American Nanohertz Observatory for Gravitational Waves
(NANOGrav) Physics Frontiers Center, and the Data Observation Network for Earth (DataONE). The project also
provides training and outreach to additional scientific collaborations, and the project supports integration
with the Extreme Science and Engineering Discovery Environment (XSEDE), which provides a national-scale
cyberinfrastructure for scientific research in the US.
Learn more about CILogon 2.0
What is COmanage
COmanage provides collaboration management services for CILogon 2.0. COmanage enables research collaborations
(virtual organizations or VOs) to manage the entire lifecycle of collaboration. Beginning with onboarding,
COmanage provides flexible and customizable enrollment flows to bring people and their federated identities
onto the platform and create a collaborative organization (CO). Each CO may have multiple active enrollment
flows tailored specifically for particular types of collaborators such as faculty, students, or staff, and each
flow may onboard users by invitation, self signup, and even conscription. During enrollment COmanage consumes
the details about a user’s federated identity provided by their home organization and records it as an
organizational identity. After enrollment the organizational identity is linked to the CO person identity
representing the user as part of the CO or VO. Because researchers today may hail from multiple organizations
and often participate in multiple VOs simultaneously COmanage supports linking multiple organizational
identities
to multiple CO person identities.
Learn more about COmanage


Permissions
The following is a breakdown of the permission needed for the API user to be able to use the action in this app. These permissions are controlled in the IAM section of the ETP server. For information pertaining to setting up the API user refer to the API documentation located at https://docs.fireeye.com/docs/index.html#ETP.
For any API access, the following entitlements are required:
Actions
It is important to know that all the actions in this app take affect on the Fireeye ETP side, with the exception of remediating email. For example, deleting a quarantined email is the action that deletes the email in the Fireeye ETP quarantined section, not in the Office365. Office365 may have other actions for quarantined emails from there own security suite
Remediate Email action
This action talks to the API for Office365 which will move/delete the email depending on the input from the user. This action does not have an undo function and if the user selects action_overrite of delete, this email will be permanently deleted in the Office365 environment and not recoverable. Use cautiously!


--- title: The Games that Made Us date: 2017-02-17 featured_image: projects/gamesthatmadeus.png link: http://gamesthatmadeus.com cta: gamesthatmadeus.com redirect_from: - /gamesthatmadeus/ ---
When I moved to San Francisco from the east coast, I started up a podcast with Nathan Savoy, one of my oldest friends, about the video games that we played as kids. We chat and joke around about all kinds of video games (both well-known and lesser-known ones) that we played years ago and still can't stop thinking about.
Some of my favorite episodes so far include Episode 2: Batman Arkham Asylum where I give away the true extend of my Batman nerdom, Episode 4: SSX Tricky, where we discuss the best snowboarding video game of all time, and Episode 5: The Simpsons Hit and Run, where we express our surprise that a TV-adaptation video game could actually be good. Give us a listen!


C has pointers; Cicada has aliases. An alias is a member that shares its data with some other member: they lead to the same variable. In Cicada a member and its alias are exactly on he same terms: Cicada doesn’t even know which was the original member.
Here is how aliases are defined:
a := 2 | will default to an int
b :=@ a | alias #1
c :=@ b | alias #2
‘b’ is now an alias to ‘a’, and ‘c’ is now an alias to ‘b’ and therefore also to ‘a’. If we were to now print(a), print(b) or print(c), we would get back the number 2. If we were to set any of the three variables to a different value:
c = 3
then printing any of a, b or c would then cause the new number 3 to be printed.
Any variable can become an alias for any other variable of the same type (or a derived/inherited type), by means of the equate-at operator ‘=@’.
a :: b :: c :: int
{ a, b, c } = { 1, 2, 3 }
a =@ b | 'a' now points to the variable storing '2'
b =@ c | 'a' STILL points to the variable storing '2'
c =@ b =@ a
The tricky bit is the fourth line: since member ‘a’ has been aliased to member ‘b’, does the command b =@ c now drag member a along with it? The answer is no: aliasing binds one member to another member’s variable, not to the other member itself. If we follow through all the acrobatics, we find that members a, b, and c all end up referring to same the variable storing the number 2, as shown in Figure 2. (The other two variables are now inaccessible and will eventually be cleared from memory.)
Cicada clearly makes an important distinction between members and variables. Until now we have been rather sloppy on this point, so we shall be more careful from now on. A member is a named object in Cicada: the name of a variable, or a field in a composite variable. The variable itself is the data that the member refers to. In Cicada these two objects are entirely separate, and there is no reason to require a one-to-one correspondence between them.
Just as the data-copying operator ‘=’ or ‘<-’ has a data-comparison counterpart ‘==’, so the member-reference-copying operator ‘=@’ is mirrored in a reference-comparison operator ‘==@’ which tests to see whether two members point to the same object. (If the left side spans a range of array elements then the right side must also span exactly those same elements in order for the test to return true). Finally, the are-references-not-equal operator ‘/=@’ is just the logical negation of ‘==@’.
If we so prefer, we can write whitespace just before the ‘@’ of any of the aliasing operators.
if a == @b then c := @b
if a /= @b then a = @b
The extra space makes clearer the analogy with the data-copying operators: both a = @b and a = b cause member ‘a’ to equal member ‘b’, though by different means. By the way an @ symbol by itself is meaningless; it is only the last character of these aliasing operators.
Jamming
Arrays can also be involved in aliasing. There is a potential complication, but on the surface it is straightforward. For example, we ordinary (non-array) members can alias single array elements.
array_1 :: [5] double
array_2 :: [10] double
oneEl :: double
oneEl = @array_1[4]
oneEl = @array_2[top]
Likewise complete arrays can alias other arrays, or parts of larger arrays. (Cicada doesn’t let us re-alias just some indices of an array since that would fragment its memory.). So we can write
array_1[*] = @array_2[<4, 8>]
as long as array_1 had 5 elements to begin with (aliasing can’t resize an array); however we cannot write
array_1[<3, 5>] = @array_2[<4, 6>]
The potential complication is that arrays having multiple members pointing to them can become ‘jammed’, meaning that they cannot be resized. The reason is that resizing one of its members would also force a resize of the other member which may be in an unrelated part of code, and this is not allowed. Here is an example.
array_1 :: [3][10] int
array_2 := @array_1[2][<4, 7>] | jams 4 indices of array_1
array_1[*][^12] | legal - indices 11-12 aren't aliased by array_2
array_2[^12] | no, this would cause problems
remove array_1[*][5] | not legal -- would remove 2nd column of array_2
remove array_1[1] | legal
remove array_1
array_2[+3] | legal only because we removed the jamb
Explicit aliases always jam arrays. On the other hand, unnamed references to objects (such as elements of sets and function arguments) never jam arrays.
al := @my_array[<4, 6>] | jams elements 4-6
my_array[<4, 6>] | does not jam
Tokens are ‘unjammable’, both in the sense that they cannot jam, and that they will become ‘unjammed’---i.e. permanently deactivated---if their referent is resized through another member. An unjammed token becomes unusable until it is redefined, usually when the command defining the token is rerun.
Last update: July 25, 2021


Houses Alte Hofstetterstrasse / Beck + Oser Architekten
- Curated by Paula Pintos
- about 21 hours
Sustainability · Hofstetten-Flüh, Switzerland
- version="1.0" encoding="UTF-8"? Architects: Beck + Oser Architekten
- AreaArea of this architecture projectArea: 272.0 m2
- version="1.0" encoding="UTF-8"?YearCompletion year of this architecture project Year: 2017
- version="1.0" encoding="UTF-8"?PhotographsPhotographs: Börje Müller
- version="1.0" encoding="UTF-8"?ManufacturersBrands with products used in this architecture project Manufacturers: Admonter Holzindustrie AG, Duravit, Regent, Suter Inox AG, VELUX Commercial
Text description provided by the architects. The two houses, which are combined in one building, continue the existing development along the slope edge and the street. They close the last existing gap in this line. The valley and mountain views remain unobstructed.
The parking spaces are arranged along the Alte Hofstetterstrasse. A short staircase leads to the entrances of the houses, where the bicycle parking spaces are located in a covered room under the parking. On the spaciously glazed ground floor with living, dining, kitchen and outside seating you can enjoy the view over Flüh to the monastery of Mariastein and the ruins of Landskron. On the floor above there are two rooms and the bathroom under the spectacular, multiple buckled roof shape. The sculptural stairwell, in which the two stairs wind around built-in furniture, leads to the basement floor with further rooms, shower and cellar rooms.
By placing the building at the top of the plot and parallel to the height course, the slope can be optimally used for the exposure of the three floors. The bent facades and roof surfaces allow optimal integration into the existing situation and reinforce the clear orientation towards view and sun. This theme finds its logical spatial continuation in the outside seats arranged on the side of the building. Inside, exciting and dynamic spaces and sequences of rooms are created, which invite you to experience, linger and enjoy.
The uniform materialization on the outside with concrete for walls and roof as well as the windows made of larch wood, which are practically flush with the facade, complete the volumetric crystal-like expression of the building. Inside, the reduced choice of materials with concrete ceilings, white plaster walls and saw-raw wooden floors enhances the perception of the various slants on walls and roofs.
The sustainability in terms of resource use is given by the compact building shape, the well thought-out arrangement of the rooms, the use of unfinished materials and the technical equipment with heat pump and ventilation including heat recovery.


Cartograms with d3 & TopoJSON
Stolen from:
http://prag.ma/code/d3-cartogram/#popest/2010
Scale by
in
randomize!


Cancer
Cancer : (June 22 – July 22)
Today you will be fortunate. You will make good profits in business. A female friend will help you. You will make plans to go out with family for a short trip. And will enjoy company of your mate. You will also make plans to buy a new house or a luxury vehicle. And will perform exceptionally well at your workplace.


Hi!
My name is Raye Barbieri! I practice sustainable beekeeping, caring for honeybees at my home in Riverdale, NYC. In addition to the local flaura and wildflowers, my bees take full advantage of my shade- and sun-loving flowers, herbs, fruits, and vegetables.


Transforms a packed file produced by pack200
(1) into a JAR file for web deployment.
unpack200 [ options ] input-file JAR-file
The command-line options. See Options.
Name of the input file, which can be a pack200 gzip file or a pack200 file. The input can also be JAR file produced by pack200
(1) with an effort of 0
, in which case the contents of the input file are copied to the output JAR file with the Pack200 marker.
Name of the output JAR file.
The unpack200
command is a native implementation that transforms a packed file produced by pack200
(1)
into a JAR file. A typical usage follows. In the following example, the myarchive.jar
file is produced from myarchive.pack.gz
with the default unpack200
command settings.
unpack200 myarchive.pack.gz myarchive.jar
Sets the deflation to be true
, false
, or keep
on all entries within a JAR file. The default mode is keep
. If the value is true
or false
, then the --deflate=hint
option overrides the default behavior and sets the deflation mode on all entries within the output JAR file.
Removes the input pack file.
Displays minimal messages. Multiple specifications of this option displays more verbose messages.
Specifies quiet operation with no messages.
Specifies a log file where output messages are logged.
Prints help information about the unpack200
command.
Prints version information about the unpack200
command.
Passes option to the Java Virtual Machine, where option
is one of the options described on the reference page for the Java application launcher. For example, -J-Xms48m
sets the startup memory to 48 MB. See java
(1).
This command should not be confused with the unpack
command. They are distinctly separate products.
The Java SE API Specification provided with the JDK is the superseding authority in case of discrepancies.
The following exit values are returned: 0 for successful completion, and a value that is greater than 0 when an error occurred.
Compression Formats for Network Deployment at
http://docs.oracle.com/javase/8/docs/technotes/guides/jweb/networking/compression_formats.html
The Java SE Technical Documentation page at
http://docs.oracle.com/javase/


---
layout: archive
title: Lean Prover Zulip Chat Archive
permalink: 116395maths/82678convandassociativity.html
---
The archive URL format has changed. Please find this page at:
https://leanprover-community.github.io/archive/stream/116395-maths/topic/conv.20and.20associativity.html


{% extends 'peoplefinder/page.html' %} {% block title %} {% if request.user == profile.user %} Let us know you are leaving {% else %} Let us know {{ profile.full_name }} is leaving {% endif %} {% endblock %} {% block location %}Let us know someone is leaving{% endblock %} {% block content %} {% if request.user == profile.user %}
If you are leaving DBT, please provide details in the form below. Our support team will confirm the details and remove your profile.
{% else %}If {{ profile.full_name }} has left DBT, please provide details in the form below. Our support team will confirm the details and remove their profile. Your profile details will be included with the request.
{% endif %} {% endblock %}


{% extends '_base.html' %} {% block title %}{% endblock %} {% block content %}
Nothing to see yet, but this will be an account page for users.


https://github.com/fuzzbunch/fuzzbunch
Fuzzbunch is an exploitation framework created by the NSA's TAO department and released by ShadowBrokerz from a dump obtained in 2013.
**Requirements:**
* Python2.6 (2.6.6 Last Binary release)
* pywin32
**Modules:**
* *fb.py* - FUZZBUNCH - Python Based Exploitation Framework
* *RemoteDump.py*
* *ReplayWizard.py*
* *CreateReplay.py*
* *Start.jar* - Java Package for DanderSpritz
* *configure_lp.py* - Configuration Options for DanderSpritz
* *start_lp.py* - Start script for Danderspritz


fun delete(file: File): Unit
Deletes a specific file. If a directory and its contents should be deleted, use the method deleteRecursively instead.


This structured is based on the Scalable and Modular Architecture for CSS: SMACSS
Base rules are the defaults. They are almost exclusively single element selectors but it could include attribute selectors, pseudo-class selectors, child selectors or sibling selectors. Essentially, a base style says that wherever this element is on the page.
Layout rules divide the page into sections. Layouts hold one or more modules together. We also use Layout rules to define the different key-pages.
/* Example layout: Header */
.layout-header { }
Modules are the reusable, modular parts of our design. They are the callouts, the sidebar sections, the product lists and so on.
/* Example module: Product */
.product { }
/* Product list */
.product-list { }
/* Product name */
.product-name { }
State rules are ways to describe how our modules or layouts will look when in a particular state. Is it hidden or expanded? Is it active or inactive? They are about describing how a module or layout looks on screens that are smaller or bigger. They are also about describing how a module might look in different views like the home page or the inside page.
/* Example state: Collapsed Product */
.product.is-collapsed { }
As many as possible, try to to follow this order:
And then pass the mediaqueries, state rules and sub elements (if your selector need to be more specific).
.product {
// 1. Box
display: inline-block;
width: 100%;
// 2. Border
margin-top: 1rem;
// 3. Background
background-color: green;
// 4. Text
color: white;
// 5. Other
transition: all 300ms ease;
// Media query
@include susy-breakpoint(30em, 8) {
width: 50%;
margin-top: 0;
}
// Particular State ('.product.is-badass')
&.is-badass {
background-color: #BADA55;
}
// Sub-element (specific selector: '.product .product-title')
.product-title {
font-size: 2em;
}
}


The main interface shown after the launching of Tea Box contains the list of all projetcs, grouped by priority.
Use the
New button or
File > New Project... (
⌘ + N) to create a new project. Projects can be renamed into the project's view, accessible by clicking of the project's cell.
To add an image, some text, web link and files or folders, just drag and drop from the Finder or any application or by using
File > Import
By editing the project, you can change the name of the project, the description, the
Notes files, the name of steps and change the priority.


635
Share On WhatsApp
Share
×
Share My Digital Card
WhatsApp
SMS
Facebook
Twitter
Instagram
Linkedin
Scan QR Code to download the contact details
About Us
Contact Us
Create Your Card @ www.maczentechnology.com
Home
About Us
Product & Services
Shop Online
Gallery
Youtube Videos
Payment
Enquiry


action == "update"): ?> = $this->relationRender('fields'); ?>
= $items_number; ?>
= $total_ht; ?> = $currency ?>
= $total_ttc; ?> = $currency ?>
= $total_discount; ?> = $currency ?>


Personal Information
review purchase : {{review.purchase}}
- Reservaiton Name: John Smith
- Confirmation Email<EMAIL_ADDRESS>Additional Confirmation Emails
- Email Address 1<EMAIL_ADDRESS>Payment & Billing Details
- Card Type Master Card
- Card no. **********5678
- Name (as appears on card) John Smith
In order to process your booking, the credit card provided will be preauthorized for the amount stated. In the event this reservation does not confirm, the credit card will not be charged, and the funds being held will be released within 72 hours.
Your Billing Details
- Address Line 1: 2548 E Jefferosn St
- Address Line 2:
- Town/ City: Phoenix
- Country: United Statess
- State: Arizona
- Zip:85022


Command incoming planes to land and departing planes to embark (take off)!
Landing and embarking takes 3 seconds and nets you +1 point. If more than one plane is occupying a lane at the same time, the game is over.
Landing will happen automatically after a timeout which you can delay. But don't delay too much, or the plane will leave in frustration, netting you -3 points.
Taking off is not automatic; you need to command departing planes to embark. Again, don't wait too much: after every 10 seconds of waiting, you'll net -1 point. Canceling a departing plane nets you -5 points!
Give commands in the form of "<plane> <command>", where <plane> is the ID of a plane and <command> is one of the following:
For example: "3 b" routes an incoming plane with the ID of 3 to land at plane B.


A product of inner-city Houston, I grew up in a fast-moving urban environment. I
transitioned
from a
small private school with a class size of 16 to a larger public high school with a
graduating
class of over 800. This part of my background taught me adaptability. I then begin my
undergraduate
journey at the second most diverse universities in the country - The University of
Houston -
Main
Campus. This part of my journey helped me to be considerate, receptive, equitable, and
balanced.
Continuing my education to receive a Master of Arts in Media Studies from The New School
taught
me
perseverance, patience, and diligence. Entering the workforce as a high school language
arts
teacher, I
continued my education of life, by teaching me the importance of collaboration,
compassion,
and
empathy.
I have used these lessons to guide my creative journey, and I use them in every
aspect
of
art that I create, including web development,
filmmaking, screenwriting, photography, and writing.
For more information and ways to contact me click on the portfolio page.


---
layout: page
header:
image: "image8_with_welcome_sun2.png"
background-color: ""
permalink: "/papers/"
---
{% for paper in site.categories.papers %}
{% cycle 'add rows': '
', nil, nil %}
{% cycle 'close rows': nil, nil, '
' %}
{% endfor %}
{% cycle 'close rows': nil, '', '' %}
The below works fine too:
I could type in a description of the image that will be displayed next to it.
This is the caption above the image. I could make this quite long if I wanted to, and the magic of responsive image sizing would still work just fine.
the below works fine if alone on page:
{% for paper in site.categories.papers %}
{% cycle 'add rows': '', nil, nil %}
{% cycle 'close rows': nil, nil, '
' %}
{% endfor %}
{% cycle 'close rows': nil, '', '' %}


About the company

Being a member of Holcim Group and one of the largest multinational cement producers inVietnam, we are a dynamic organization and looking for proactive, energetic and results driven individuals to join the Holcim team.
Established in 1994, HolcimVietnamcurrently employs around 1,500 people at its 4 technologically advanced cement production sites and modern ready-mix concrete batching plants. Our core businesses can be categorized into three groups:
1. Cement: In response to the increasing demands of construction industry, HolcimVietnam has developed a wide cement portfolio to better meet the requirements specification applications. The network of 4 cement plants in strategic locations in the south ensures the best logistic service and uninterrupted supply.
2. Ready-mix concrete: Holcim has always strived to further meet the different requirements of customers. With innovative solutions and services, Holcim has been trusted by many national and international leading contractors and investors; and became one of the leading ready-mix supplier in the southernVietnam.
3. Geocycle: Holcim provides safe and sustainable waste management solutions for many industrial waste types through co-processing in cement kilns. Holcim has 20 years of professional and experience expertise in Alternative Fuel Resourcing in over 40 countries.
Why join Holcim Vietnam?
At Holcim, we promote a performance-focused culture, which encourages and values the contribution of people in an open and collaborative environment by having:
A people development culture: with processes to attract and retain the right talent; build leadership capabilities that can lead in change and the culture we want; and motivate and engage employees to give off their best.
Staff with the right attitude for high performance: those who do not wait to be told what to do; willing to operate out of comfort zone, high capacity to learn and drive results forward without stopping at the first obstacle.
International standards of operations: with modern equipment and systems; strong processes and controls; world-class technical expertise; good Corporate Social Responsibility; strict environmental compliance and high safety standards.
An open and warm working environment: through coaching; New Ideas program (Y Kien Moi), employee engagement surveys; observing and learning from each other’s’ job (Day in Life Of); and tools to equip teams with a healthy team dynamics and to improve performance.
Opportunities for learning and development: with structured On the Job training, coaching and mentoring, technical training, soft skills training, leadership and supervisory development programs, regional and global programs.
Competitive benefits: such as modern office in Ho Chi Minh City and high-tech plant facilities; year end and team celebrations; corporate social responsible activities; housing and location allowances (where applicable); and attractive package.
For more information about Holcim Vietnam, please visit www.holcim.com/vn.


Athletifit
Calories burned
0 Calories
Start Recording
Stop Recording
Calorie Tracker
Total calories: 0
Add Food
My Scores
#
Calories Burned
Time
Search
Search


WRFCHEM domain view python
2014-09-04
####WRF_CHEM domain view by python script####
- WRF CHEM domain in nested has to be visualized to correct the nesting and for domain size adjustment. There are few tools available to do that such as dwiz of wrf ems and plotgrid.ncl.
- There is an alternative with python based on this, it is a wrf script tools for visualizing and nesting based simulation. Set of scripts available has a function to visualize the namelist.wps as grid using python matplotlib.
- The
def
function named aswrf_grid_wrapper
is included with wrfutil.py script and it is module like function for pydown.py a main script in pywrf program. In order to use the functionality ofwrf_grid_wrapper
, which rea the namelist.wps and p[lot the grids as per like plotgrid.ncl, the def function and its required functions are copied and pasted in a separate file namedwrf_domain.py
. - In the separate file, following def functions are added
wrf2latlon, read_namelist, set_default_basemap, plot_grid
along with mainwrf_grid_wrapper
function and it was called by adding a linewrf_grid_wrapper()
in the end of script. Some of the auxiliary def functions are copied fromviz/utils.py
file which is imported by the wrfutils.py script. - The running of script requires following libraries to import and faced problem related to that.
- to import
from mpl_toolkits.basemap import Basemap
got error ofusr/lib/pymodules/python2.7/mpl_toolkits/__init__.py:2: UserWarning: Module dap was already imported from None, but /usr/lib/python2.7/dist-packages is being added to sys.path __import__('pkg_resources').declare_namespace(__name__)
this error was solved by editing following file/usr/lib/python2.7/dist-packages/dap-<IP_ADDRESS>.egg-info/namespace_packages.txt
and add a linedap
as the first line, based on this - have to import
import numpy as n
- have to import
from matplotlib.numerix import ma
but based on this import was changed intofrom numpy import ma
- have to import
from pyproj import Proj
this module was installed by downloading it source file from here and installed following its readme as bypython setup.py build, sudo python setup.py install
- Some minor edits were made on this and also needed to add more functions into the program from the main program. Finally, the edit fetches to correctness with the plotting of the outer domain in the background map such as. Having a limitation of viewing only one domain per time.
- to import


0.26.0
A Node.js context for executing Javascript code
Extends JsContext
A Host
allows you to create, get, run methods of, and delete instances of various types.
The types can be thought of a "services" provided by the host e.g. NoteContext
, FilesystemStorer
The API of a host is similar to that of a HTTP server. It's methods names
(e.g. post
, get
) are similar to HTTP methods (e.g. POST
, GET
) but
the sematics sometimes differ (e.g. a host's put()
method is used to call an
instance method)
A Host
is not limited to beng served by HTTP and it's methods are exposed by both HostHttpServer
and HostWebsocketServer
. Those other classes are responsible for tasks associated with
their communication protocol (e.g. serialising and deserialising objects).
This is a singleton class. There should only ever be one Host
in memory in each process (although, for purposes of testing, this is not enforced)
Get a list of server names for this host
Servers are identified by the protocol shorthand
e.g. http
for HostHttpServer
array
:
Array of strings
View this host in the browser
Opens the default browser at the URL of this host
A HTTP server for a Host
Handle a HTTP request
(Any)
(Any)
Handle an OPTIONS request
Necessary for preflighted CORS requests (https://developer.mozilla.org/en-US/docs/Web/HTTP/Access_control_CORS#Preflighted_requests)
(Any)
(Any)
Handle a request to home
(Any)
(Any)
Handle a request for a static file
(Any)
(Any)
(Any)
Handle a request to post
(Any)
(Any)
(Any)
Handle a request to get
(Any)
(Any)
(Any)
Handle a request to put
(Any)
(Any)
(Any)
(Any)
Handle a request to delete
(Any)
(Any)
(Any)
General error handling
(Any)
(Any)
(Any)
(Any)
A backend for the local file system
A buffer that resides on the local file system
A storer for the local file system
Extends FileSystemBuffer
Utility functions
Is the user running this process a super user?


Crash closes Hawaii Island’s Highway 190; investigation ongoing
by HNN StaffHAWAII ISLAND, Hawaii (HawaiiNewsNow) -Another bad crash on Hawaii Island shut down a major highway Tuesday night.
Highway 190 was closed earlier in the evening in Pu’uanahulu.
Police are rerouting drivers to Waikoloa Road and Kaiminui Drive.
Officials have not yet released details on the accident.
This crash comes the same day as another collision that left 1 woman dead, and another critically injured.
This story will be updated.
Copyright 2019 Hawaii News Now. All rights reserved.


This example shows how to use the client-side API of Telerik Chart for ASP.NET MVC.
To use the client-side API you should first retrieve the chart's client-side object.
<script type="text/javascript"> function getChart(){ // The chart name is "chart" return $("#chart").data("tChart"); } </script>
Available client-side methods:


To Know more about DAO Bank click here.
Know more about Accounts and Eligibility
Get a Credit Card for a Safe and Secure Shopping !
Sign in to Know more about Offers and Benefits
More Promotions are Waiting For you!


--- layout: post title: no title date: '2017-07-26T11:30:37+02:00' categories: - Grand Froid - Storyboards picture_url: https://film-Storyboards.tumblr.com/post/163450901895 ---


public class Country
extends java.util.Observable
| Constructor and Description |
|---|
Country()
Empty constructor for country
Set country name to DNE
Set empty player for country
|
Country(int id,
java.lang.String name,
int horizontal,
int vertical,
int imageX,
int imageY,
int plotX,
int plotY)
Initialize Country Object given parameters of id, name, map attributes
Creates a corresponding CountryObsLabel to be fetched later
|
| Modifier and Type | Method and Description |
|---|---|
void |
addArmy(int amount)
Add a certain army count to this country
|
void |
addNeighbour(Country nbour)
Adds Country object in argument to linkedCountries Vector as a neighbor
does't need to add this to neighbour's linkedCountries the same function will be called for them too
|
void |
alertObservers()
After change of state, alerts attached CountryObsLabel
|
int |
getArmyNum()
Getter of armyNum
|
Continent |
getContinent()
Getter of the Continent this Country belongs to
|
int |
getID()
Getter of country's id
|
CountryObsLabel |
getLabel()
Getter of CountryObsLabel l
|
java.util.Vector<Country> |
getLinkCountries()
Getter of surrounding Country Vector
|
java.lang.String |
getName()
Getter of countryName
|
Player |
getOwner()
Getter for owner of Country
|
int[] |
getXY() |
boolean |
hasEnemyNeighbour() |
boolean |
hasNeighbour(java.lang.String countryId)
Determines if this Country has a neighbour with the ID of the argument String
|
boolean |
hasPathTo(java.lang.String countryId,
java.lang.String ownerId,
java.util.HashSet<java.lang.String> visited)
Depth-first recursive search to determine if there's a linked path owned by same player to the destination Country
with countryId
|
boolean |
moveArmy(int toID,
int armyNum)
During end of attack in phases 2 and fortification in phase 3
First verifies if country is connected and the army number to be moved is valid
if verification is passed, adjusts army number of both countries accordingly
|
void |
printLinkedCountries()
Print all neighbors' name
|
void |
printLinkedCountriesNum()
Print number of neighbors this Country has
|
void |
removeArmy(int amount)
Whenever there is a subtraction of army number
|
void |
setArmy(int i) |
void |
setContinent(Continent c)
Set Continent that this Country belongs to
|
void |
setOwner(Player p)
Setter for owned player
Alerts observer to change color to that of the new player
|
public Country()
public Country(int id, java.lang.String name, int horizontal, int vertical, int imageX, int imageY, int plotX, int plotY)
id
- serialized Country id number createdname
- assigned Country namehorizontal
- TODOvertical
- Vertical of label for UIimageX
- imageX of label for UIimageY
- imageY of label for UIplotX
- plotX of label for UIplotY
- plotY of label for UIpublic Player getOwner()
public void setOwner(Player p)
p
- Player as ownerpublic void addNeighbour(Country nbour)
nbour
- Neighbor countrypublic boolean hasNeighbour(java.lang.String countryId)
countryId
- target neighbour's namepublic boolean hasEnemyNeighbour()
public boolean hasPathTo(java.lang.String countryId, java.lang.String ownerId, java.util.HashSet<java.lang.String> visited)
countryId
- destination countryIdownerId
- playerId who is suppoed to own the pathvisited
- HashSet of visited id of Countries during the recursive callpublic void addArmy(int amount)
amount
- Amount of army to be added as intpublic void removeArmy(int amount)
amount
- of army to removepublic boolean moveArmy(int toID, int armyNum)
toID
- id of connected countryarmyNum
- amount of army to move to destinationpublic int getID()
public int getArmyNum()
public void setArmy(int i)
public java.lang.String getName()
public Continent getContinent()
public void setContinent(Continent c)
c
- Continent to be setpublic java.util.Vector<Country> getLinkCountries()
public CountryObsLabel getLabel()
public void printLinkedCountries()
public void printLinkedCountriesNum()
public int[] getXY()
public void alertObservers()


With more than 100 servers around the world your images will be delivered at the best speed to any point of the world,
from the closest server location to the end user.
We also provide
HTTP/2 and
HTTP/3 versions of a protocol.
Pixboost will keep your clients safe without performance impact.