Before Change
start = time.time()
knn.fit(X_train, y_train)
predictions = knn.predict(X_test)
acc_euclidean = accuracy_score(y_test, predictions)
time_euclidean = time.time() - start
accuracies[dataset] = (acc_sax, acc_euclidean)
times[dataset] = (time_sax, time_euclidean)
After Change
numpy.random.seed(0)
// Generate a random walk time series
data_loader = UCR_UEA_datasets()
datasets = [
("SyntheticControl", 16),
("GunPoint", 64),
("FaceFour", 128),
("Lightning2", 256),
("Lightning7", 128),
("ECG200", 32),
("Plane", 64),
("Car", 256),
("Beef", 128),
("Coffee", 128),
("OliveOil", 256)
]
accuracies = {}
times = {}
for dataset, w in datasets:


Well as you know my name as it says up top. I am a 22 year old trying to become a web developer. I attended college straight after high school. To be honest I really enjoyed my time there
I had a great life growing up. My mom made sure I was in any activities. I was onn a cheerleading team for about sever years. I did volleyball at school. In elementary school i took piano lessons and i always participated in any programs we had. I had the best time grown up
I have had a hard time trying to figure out life but hey dont we all. I was use to giving everything handed to me.


Subtotal:
Shipping:
Menu
Title
Home
|
Advanced Search
|
About Us
|
My Account
|
Contact
|
Mailing list
|
Gallery
|
Cart
|
Checkout


Although the program in §3.2.2/46 is larger than we would like, it would have been
larger still without vector, string,
and sort
. These library facilities, like others that
we have used, share several qualities: Each one
Our own programs have the first of these qualities, but lack the others. This lack is fine for small programs, but as we set out to solve larger problems, we will find that our solutions will become unmanageable unless we break them into independent, named parts.
Like most programming languages, C++ offers two fundamental ways of organizing large programs: functions (sometimes called subroutines) and data structures. In addition, C++ lets programmers combine functions and data structures into a single notion called a class, which we'll explore starting in Chapter 9.
Once we have learned how to use functions and data structures to organize our computations, we also need the ability to divide our programs into files that we can compile separately and combine after compilation. The last part of this chapter will show how C++ supports separate compilation.
We shall begin by writing a function to calculate a student's final grade from the midterm and final exam grades and overall homework grade. We'll assume that we've already calculated the overall homework grade from the individual homework grades, which we have been computing as the average or median. Aside from that assumption, this function will use the same policy as the one that we've been using all along: Homework and the final exam contribute 40% each to the total, and the midterm makes up the remaining 20%.
Whenever we do—or might do—a computation in several places, we should think about putting it in a function. An obvious reason for doing so is that then we can use the function instead of redoing the computation explicitly. Not only does using functions reduce our total programming effort, but doing so also makes it easier for us to change the computation if we wish. For example, assume we wanted to change our grading policy. If we had to hunt through every program we had ever written, looking for the parts that dealt with grading, we would probably become discouraged quickly.
There is a more subtle advantage to using functions for such computations: A function has a name. If we name a computation, we can think about it more abstractly—we can think more about what it does and less about how it works. If we can identify important parts of our problems, and create named pieces of our programs that correspond to those parts, then our programs will be easier to understand and the problems easier to solve.
Here is a function that computes grades according to our policy:
// compute a student's overall grade from midterm and final exam grades and homework grade double grade(double midterm, double final, double homework) { return 0.2 * midterm + 0.4 * final + 0.4 * homework; }
Until now, all the functions that we've defined have been named main
. We define most
other functions similarly, by specifying the return type, followed first by the function
name, next by a parameter list enclosed in ( ), and, finally, by the function body, which is
enclosed in { }
. The rules are more complicated for functions that return values that
denote other functions; see §A.1.2/297 for the full story.
In this example, the parameters are midterm, final
, and homework
, each of which
has type double
. They behave like variables that are local to the function, which means
that calling the function creates them and returning from the function destroys them.
As with any other variables, we must define the parameters before using them. Unlike other variables, defining them does not create them immediately; only calling the function creates them. Therefore, whenever we call the function, we must supply corresponding arguments, which are used to initialize the parameters when the function begins execution. For example, in §3.1/36 we computed a grade by writing
cout << "Your final grade is " << setprecision(3) << 0.2 * midterm + 0.4 * final + 0.4 * sum / count << setprecision(prec) << endl;
If we had the grade function available, we could have written
cout << "Your final grade is " << setprecision(3) << grade(midterm, final, sum / count) << setprecision(prec) << endl;
Not only must we supply arguments that correspond to the parameters of the functions
that we call, but we must supply them in the same order. Accordingly, when we call the
grade
function, the first argument must be the midterm grade, the second must be the
final exam grade, and the third must be the homework grade.
Arguments can be expressions, such as sum / count
, not just variables. In general,
each argument is used to initialize the. corresponding parameter, after which the parameters
behave like ordinary local variables inside the function. So, for example, when we
call grade(midterm, final, sum / count)
, the grade
function's parameters are initialized
to copies of the arguments' values, and do not refer directly to the arguments
themselves. This behavior is often called call by value, because the parameter takes on a
copy of the value of the argument.
Another problem that we solved in §3.2.2/46, and that we can imagine wanting to solve in
other contexts, is finding the median of a vector
. We'll see in §8.1.1/140 how to define a
function that is so general that it works with a vector
of any type of value. For now,
we'll limit our attention to vector<double>
.
To write our function, we'll start with the part of the program in §3.2.2/47 that computes medians, and make a few changes:
// compute the median of a vector<double> // note that calling this function copies the entire argument vector double median(vector<double> vec) { typedef vector<double>::size_type vec_sz; vec_sz size = vec.size(); if (size == 0) throw domain_error("median of an empty vector"); sort(vec.begin(), vec.end()); vec_sz mid = size / 2; return size % 2 == 0 ? (vec[mid] + vec[mid-1]) / 2 : vec[mid]; }
One change is that we named our vector vec
, rather than homework
. After all, our function
can compute the median of anything, not just homework grades. We also eliminated
the variable median
, because we no longer need it: We can return the median as soon as
we've calculated it. We are still using size
and mid
as variables, but now they are local
to the median
function and, therefore, inaccessible (and irrelevant) elsewhere. Calling the
median
function will create these variables, and returning from the function will destroy
them. We define vec_sz
as a local type name, because we don't want to conflict with
anyone who might want to use that name for another purpose.
The most significant change is what we do if the vector
is empty. In §3.2.2/46, we
knew that we would have to complain to whoever was running our program, and we also
knew who that person would be and what kind of complaint would make sense. In this
revised version, on the other hand, we don't know who is going to be using it, or for what
purpose, so we need a more general way of complaining. That more general way is to
throw an exception if the vector
is empty.
When a program throws an exception, execution stops in the part of the program in
which the throw
appears, and passes to another part of the program, along with an
exception object, which contains information that the caller can use to act on the exception.
The most important part of the information that is passed is usually the mere fact that
an exception was thrown. That fact, along with the type of the exception object, is usually
enough to let the caller figure out what to do. In this particular example, the exception
that we throw is domain_error
, which is a type that the standard library defines in
header <stdexcept>
for use in reporting that a function's argument is outside the set of
values that the function can accept. When we create a domain_error
object to throw,
we can give it a string
that describes what went wrong. The program that catches the
exception can use this string
in a diagnostic message, as we shall see in §4.2.3/65.
There is one more detail about how functions behave that is important to understand.
When we call a function, we can think of the parameters as local variables whose initial
values are the arguments. If we do so, we can see that calling a function involves copying
the arguments into the parameters. In particular, when we call median
, the vector
that
we use as an argument will be copied into vec
.
In the case of the median
function, it is useful to copy the argument to the parameter,
even if doing so takes significant time, because the median
function changes the value of
its parameter by calling sort
. Copying the argument prevents changes made by sort
from propagating back to the caller. This behavior makes sense, because taking the
median
of a vector
should not change the vector
itself.
The grade
function in §4.1/52 assumes that we already know the student's overall homework
grade, and not just the individual homework assignments' grades. How we obtain
that grade is part of our policy: We used the average in §3.1/36 and the median in
§3.2.2/47. Accordingly, we might wish to express this part of our grading policy in a
function, along the same lines as we did in §4.1/52:
// compute a student's overall grade from midterm and final exam grades // and vector of homework grades. // this function does not copy its argument, because median does so for us. double grade(double midterm, double final, const vector<double>& hw) { if (hw.size() == 0) throw domain_error("student has done no homework"); return grade(midterm, final, median(hw)); }
This function has three points of particular interest.
The first point is the type, const vector<double>&
, that we specify for the third
argument. This type is often called "reference to vector
of const double
." Saying
that a name is a reference to an object says that the name is another name for the object.
So, for example, if we write
vector<double> homework; vector<double>& hw = homework; // hw is a synonym for homework
we are saying that hw
is another name for homework
. From that point on, anything we
do to hw
is equivalent to doing the same thing to homework
, and vice versa. Adding a
const
, as in
// chw is a read-only synonym for homework const vector<double>& chw = homework;
still says that chw
is another name for homework
, but the const
promises that we will
not do anything to chw that might change its value.
Because a reference is another name for the original, there is no such thing as a reference to a reference. Defining a reference to a reference has the same effect as defining a reference to the original object. For example, if we write
// hw1 and chw1 are synonyms for homework; chw1 is read-only vector<double>& hw1 = hw; const vector<double>& chw1 = chw;
then hw1
is another name for homework
, just as hw
is, and chw1
, like chw
, is another
name for homework
that does not allow write access.
If we define a nonconst
reference—a reference that allows writing—we cannot make
it refer to a const
object or reference, because doing so would require permission that
the const
denies. Therefore, we cannot write
vector<double>& hw2 = chw; // error: requests write access to chw
because we promised not to modify chw
.
Analogously, when we say that a parameter has type const vector<double>&
, we
are asking the implementation to give us direct access to the associated argument, without
copying it, and also promising that we won't change the parameter's value (which would
otherwise change the argument too). Because the parameter is a reference to const
, we
can call this function on behalf of both const
and nonconst
vector
s. Because the
parameter is a reference, we avoid the overhead of copying the argument.
The second point of particular interest about the grade
function is that like the one in
§4.1/52, it is named grade
—even though it calls the other grade
function. The notion
that we can have several functions with the same name is called overloading, and figures
prominently in many C++ programs. Even though we have two functions with the same
name, there is no ambiguity, because whenever we call grade
, we will supply an argument
list, and the implementation will be able to tell from the type of the third argument
which grade
function we mean.
The third point is that we check whether homework.size()
is zero, even though we
know that median
will do so for us. The reason is that if median
discovers that we are
asking for the median of an empty vector
, it throws an exception that includes the message
median of an empty vector
. This message is not directly useful to someone who
is computing student grades. Therefore, we throw our own exception, which we hope
will give the user more of a clue as to what has gone wrong.
Another problem that we have had to solve in several contexts is reading homework
grades into a vector
.
There is a problem in designing the behavior of such a function: It needs to return two values at once. One value is, of course, the homework grades that it read. The other is an indication of whether the attempted input was successful.
There is no direct way to return more than one value from a function. One indirect way to do so is to give the function a parameter that is a reference to an object in which it is to place one of its results. This strategy is common for functions that read input, so we'll use it. Doing so will make our function look like this:
// read homework grades from an input stream into a vector<double> istream& read_hw(istream& in, vector<double>& hw) { // we must fill in this part return in; }
In §4.1.2/54, we saw a program with a const vector<double>&
parameter; now we're
dropping the const
. A reference parameter without a const
usually signals an intent to
modify the object that is the function's argument. For example, when we execute
vector<double> homework; read_hw(cin, homework);
the fact that read_hw
's second parameter is a reference should lead us to expect that calling
read_hw
will change the value of homework
.
Because we expect the function to modify its argument, we cannot call the function
with just any expression. Instead, we must pass an lvalue argument to a reference parameter.
An lvalue is a value that denotes a nontemporary object. For example, a variable is
an lvalue, as is a reference, or the result of calling a function that returns a reference. An
expression that generates an arithmetic value, such as sum / count
, is not an lvalue.
Both of the parameters to read_hw
are references, because we expect the function to
change the state of both arguments. We don't know the details of how cin
works, but
presumably the library defines it as a data structure that stores everything the library
needs to know about the state of our input file. Reading input from the standard input
file changes the state of the file, so it should logically change the value of cin
as well.
Notice that read_hw
returns in
. Moreover, it does so as a reference. In effect, we are
saying that we were given an object, which we are not going to copy, and we will return
that same object, again without copying it. Returning the stream allows our caller to write
if (read_hw(cin, homework)){/*...*/}
as an abbreviation for
read_hw(cin, homework); if (cin) {/*...*/}
We can now think about how to read the homework grades. Obviously, we want to read as many grades as exist, so it would seem as if we could just write
// first try not quite right double x; while (in >> x) hw.push_back(x);
This strategy doesn't quite work, for two reasons.
The first reason is that we haven't defined hw
—our caller defined it for us. Because we
didn't define it, we don't know what data might be there already. For all we know, our
caller might be using our function to process homework for lots of students, in which case
hw
might contain the previous student's grades. We can solve this problem by calling
hw.clear()
before we begin our work.
The second reason that our strategy fails is that we don't quite know when to stop. We can keep reading grades until we can no longer do so, but at that point we have a problem. There are two reasons why we might no longer be able to read a grade: We might have reached end-of-file, or we might have encountered something that is not a grade.
In the first case, our caller will think that we have reached end-of-file. This thought will be true but misleading, because the end-of-file indication will have occurred only after we have successfully read all the data. Normally, an end-of-file indication means that an input attempt failed.
In the second case, when we have encountered something that isn't a grade, the library will mark the input stream as being in failure state, which means that future input requests will fail, just as if we had reached end-of file. Therefore, our caller will think that something is wrong with the input data, when the only problem was that the last homework grade was followed by something that was not a homework grade.
In either case, then, we would like to pretend that we never saw whatever followed the
last homework grade. Such pretense turns out to be easy: If we reached end-of-file, there
was no additional input to read; if we encountered something that wasn't a grade, the
library will have left it unread for the next input attempt. Therefore, all we must do is tell
the library to disregard whatever condition caused the input attempt to fail, be it end-of-file
or invalid input. We do so by calling in.clear()
to reset the error state inside in
,
which tells the library that input can continue despite the failure.
There is one more detail to consider: Perhaps we have already run out of input, or encountered an error condition, before even trying to read the first homework grade. In that case, we must leave the input stream strictly alone, lest we inadvertently seduce our caller into trying to read nonexistent input at some point in the future.
Here is the complete read_hw function:
// read homework grades from an input stream into a vector<double> istream& read_hw(istream& in, vector<double>& hw) { if (in) { // get rid of previous contents hw.clear() ; // read homework grades double x; while (in >> x) hw.push_back(x); // clear the stream so that input will work for the next student in.clear(); } return in; }
Note that the clear
member behaves completely differently for istream
objects than it
does for vector
objects. For istream
objects, it resets any error indications so that input
can continue; for vector
objects, it discards any contents that the vector might have had,
leaving us with an empty vector again.
We would like to pause at this point for an important observation: We have defined three
functions—median, grade,
and read_hw
—that operate on homework vectors. Each of
these functions treats the corresponding parameter in a fundamentally different way from
the others, and each treatment has a purpose.
The median
function (§4.1.1/53) has a parameter of type vector<double>
. Therefore,
calling that function causes the argument to be copied, even though that argument
might be a huge vector
. Despite the inefficiency, vector<double>
is the right parameter
type for median
, because this type ensures that taking the median of a vector
doesn't change the vector
. The median
function sort
s its parameter. If it did not copy
its argument, then calling median(homework)
would change the value of homework
.
The grade
function that takes a homework vector
(§4.1.2/54) has a parameter of
type const vector<double>&
. In this type, the &
asks the implementation not to copy
the argument, and the const
promises that the program will not change the parameter.
Such parameters are an important technique for making programs more efficient. They
are a good idea whenever the function will not change the parameter's value, and the
parameter is of a type, such as vector
or string
, with values that might be time-consuming
to copy. It is usually not worth the bother to use const
references for parameters
of simple built-in types, such as int
or double
. Such small objects are usually fast
enough to copy that there's little, if any, overhead in passing them by value.
The read_hw
function has a parameter of type vector<double>&
, without the
const
. Again, the &
asks the implementation to bind the parameter directly to the argument,
thus avoiding having to copy the argument. But here, the reason to avoid the copy
is that the function intends to change the argument's value.
Arguments that correspond to nonconst
reference parameters must be lvalues—that
is, they must be nontemporary objects. Arguments that are passed by value or bound to a
const
reference can be any value. For example, suppose we have a function that returns
an empty vector
:
vector<double> emptyvec() { vector<double> v; // no elements return v; }
We could call this function, and use the result as an argument to our second grade
function
from §4.1.2/54:
grade(midterm, final, emptyvec());
When run, the grade
function would throw an exception immediately, because its argument
is empty. However, calling grade
this way would be syntactically legal.
When we call read_hw
, both of its arguments must be lvalues, because both parameters
are nonconst references. If we give read_hw
a vector that is not an lvalue
read_hw(cin, emptyvec()); // error: emptyvec() is not an lvalue
the compiler will complain, because the unnamed vector
that we create in the call to
emptyvec
will disappear as soon as read_hw
returns. If we were allowed to make this
call, the effect would be to store input in an object that we couldn't access!
The whole point of writing these functions is to use them in solving problems. For example, we can use them to reimplement our grading program from §3.2.2/46:
// include directives and using-declarations for library facilities // code for median function from §4.1.1/53 // code for grade(double, double, double) function from §4.1/52 // code for grade(double, double, const vector<double>&) function from §4.1.2/54 // code for read_hw(istream&, vector<double>&) function from §4.1.3/57 int main() { // ask for and read the student's name cout << "Please enter your first name: "; string name; cin >> name; cout << "Hello, " << name << "!" << endl; // ask for and read the midterm and final grades cout << "Please enter your midterm and final exam grades: "; double midterm, final; cin >> midterm >> final; // ask for the homework grades cout << "Enter all your homework grades, " "followed by end-of-file: "; vector<double> homework; // read the homework grades read_hw(cin, homework); // compute and generate the final grade, if possible try { double final_grade = grade(midterm, final, homework); streamsize prec = cout.precision(); cout << "Your final grade is " << setprecision(3) << final_grade << setprecision(prec) << endl; } catch (domain_error) { cout << endl << "You must enter your grades. " "Please try again." << endl; return 1; } return 0; }
The changes from the earlier version are in how we read the homework grades, and in how we calculate and write the result.
After asking for our user's homework grades, we call our read_hw
function to read
the data. The while
statement inside read_hw
repeatedly reads homework grades until
we hit end-of-file or encounter a data value that is not valid as a double.
The most important new idea in this example is the try statement. It tries to execute
the statements in the { }
that follow the try
keyword. If a domain_error
exception
occurs anywhere in these statements, then it stops executing them and continues with the
other set of { }
-enclosed statements. These statements are part of a catch clause, which
begins with the word catch
, and indicates the type of exception it is catching.
If the statements between try
and catch
complete without throwing an exception,
then the program skips the catch
clause entirely and continues with the next statement,
which is return 0
; in this example.
Whenever we write a try
statement, we must think carefully about side effects and
when they occur. We must assume that anything between try
and catch
might throw
an exception. If it does so, then any computation that would have been executed after the
exception is skipped. What is important to realize is that a computation that might have
followed an exception in time does not necessarily follow it in the program text.
For example, suppose that we had written the output block more succinctly as
// this example doesn't work try { streamsize prec = cout.precision(); cout << "Your final grade is " << setprecision(3) << grade(midterm, final, homework) << setprecision(prec); } ...
The problem with this rewrite is that although the implementation is required to execute
the <<
operators from left to right, it is not required to evaluate the operands in any specific
order. In particular, it might call grade after it writes Your final grade is
. If
grade
throws an exception, then the output might contain that spurious phrase. Moreover,
the first call to setprecision
might set the output stream's precision to 3 without
giving the second call the opportunity to reset the precision to its previous value. Alternatively,
the implementation might call grade before writing any output; whether it does
so depends entirely on the implementation.
This analysis explains why we separated the output block into two statements: The
first statement ensures that the call to grade
happens before any output is generated.
A good rule of thumb is to avoid more than one side effect in a single statement. Throwing an exception is a side effect, so a statement that might throw an exception should not cause any other side effects, particularly including input and output.
Of course, we cannot run our main
function as written. We need the include
directives
and using
-declarations for the library facilities that the program uses. We also use
the names read_hw
and the grade function that takes a const vector<double>&
third argument. The definitions of these functions, in turn, use the median
function and
the grade
function that takes three doubles.
In order to execute this program, we have to ensure that those functions are defined
(in the proper order) before our main
function. Doing so yields an inconveniently large
program. Rather than write it out directly here, we'll see in §4.3/65 how we can partition
such programs more succinctly into files. Before we do so, let's look at better ways to
structure our data.


Patty is a small library that facilitates working with functional data structures. It consists of a few macros and metaclasses that integrate nicely with CLOS. Code using patty is similar in style to Haskell code using algebraic data types, primitive pattern matching and type classes.
The latest release is 1.0.6.
Download gzipped tarball.
It depends on closer-mop,
moptilities
and Alexandria.
LIFT and
cl-ppcre are only needed to
run the test suite (only the patty-test system depends on them).
Alternatively you can install via
asdf-install (with the caveat that Alexandria is currently not
asdf-installable).
You can get the latest via darcs:
darcs get http://common-lisp.net/project/patty/darcs/patty
defdata-*
expansion. This
turned out to be rather dumb, especially for interactive
development. So now the slot names are the same as the reader
method names, but wrapped in angle brackets. This release
also fixes a bug in a MOP utility function.
defdata-
* macros have an
:initform
that signals an error.
Patty uses the abstract-class
and singleton-class
definitions from Tim Bradshaw's
Lisp hacks.
Stefan Lang


{{ .Content }} {{ $author.display_name }} {{ $author.job_title }} {{ with $social.google_plus_id }} {{ end }} Please enable JavaScript to view the comments powered by Disqus.
{{ $author.job_title }}


{% extends 'IcwApp/base.html' %} {% load static %} {% block header %}
We serve as a resource for parents, educators, and other organizations looking to address the digital skills gap, and raising awareness about the importance of diversity in tech and the role of computer science education in lifting prosperity in Memphis. CodeCrew is passionate about students and the community alike to have access to quality computer science and tech education. As advocates raising awareness of the importance of computer science education, we whole heartedly support other initiatives in Memphis engaged in this work.
{% endblock content %} {% block footer %} 88 Union Avenue, 2nd Floor, Memphis, TN 38103 |<PHONE_NUMBER> | {% endblock footer %}


Registration Form
Name
Email Id
Mobile Number
Department
Select department
Computer Application
MBA
Hoti-culture
English


Your survey is available.
Thank you for visiting our site. You have been randomly selected to participate in a customer satisfaction survey to let us know how we can improve your website experience. Please click "Continue to survey" below once you have completed your visit.
This survey is conducted by an independent company ForeSee.


The thematic dedicated to metabolomics data processing, analysis and annotation for Metabolomics community


normal - normal text
a – hyperlink
em – emphatic stress
strong – strong importance
small – small print
s – struck text
cite – cited title of a work
q – quoted text
dfn – defining instance
abbr – abbreviation
time –
code – code fragment
var – variable or placeholder text
samp – (sample) output
kbd – user input
sub – subscript
sup – superscript
i – offset text conventionally styled in italic
b – offset text conventionally styled in bold
u – offset text conventionally styled with an underline
mark – marked (highlighted) text


Data obtained from surveys contains information not only about the survey responses, but also the survey metadata, e.g. the original survey questions and the answer options. The 'surveydata' package makes it easy to keep track of this metadata, and to easily extract columns with specific questions.
| Version: | 0.2.2 |
| Depends: | R (≥ 3.0.0) |
| Imports: | stringr (≥ 0.5), plyr, dplyr, rlang, magrittr, purrr, ggplot2, scales, tidyr, DT, assertthat |
| Suggests: | testthat, knitr, rmarkdown, withr, covr, rprojroot |
| Published: | 2018-12-06 |
| Author: | Andrie de Vries [aut, cre, cph] |
| Maintainer: | Andrie de Vries <apdevries at gmail.com> |
| BugReports: | https://github.com/andrie/surveydata |
| License: | GPL-2 | GPL-3 |
| Copyright: | Andrie de Vries |
| URL: | http://andrie.github.io/surveydata/index.html |
| NeedsCompilation: | no |
| Materials: | NEWS |
| In views: | OfficialStatistics |
| CRAN checks: | surveydata results |
| Reference manual: | surveydata.pdf |
| Vignettes: |
Introduction to the surveydata package. |
| Package source: | surveydata_0.2.2.tar.gz |
| Windows binaries: | r-devel: surveydata_0.2.2.zip, r-release: surveydata_0.2.2.zip, r-oldrel: surveydata_0.2.2.zip |
| OS X binaries: | r-release: surveydata_0.2.2.tgz, r-oldrel: surveydata_0.2.2.tgz |
| Old sources: | surveydata archive |
Please use the canonical form https://CRAN.R-project.org/package=surveydata to link to this page.


White on roll, cube action?
w5-b9/15
pips White=121 Black=187
(CorrectAnswer= 0/0, ErrorScore= 0)
No double Player Winning Chances: 72.70% (G:35.83% B:2.77%) Opponent Winning Chances: 27.30% (G: 2.96% B:0.11%) Double/Take Player Winning Chances: 72.93% (G:35.90% B:2.64%) Opponent Winning Chances: 27.07% (G: 3.07% B:0.10%) Cubeless Equities: No double=+0.821 Double=+1.761 Cubeful Equities No double: +1.095 Double/Take: +1.613 (+0.519) Double/Pass: +1.000 (-0.095) Best Cube action: Too good to double / Pass Percentage of wrong take needed to make the double decision right: 15.4%


@@include('../partials/head/head.html')
@@include("../partials/components/header.html")
@@include('../partials/components/hero-section.html')
@@include('../partials/components/options/options-section.html')
@@include('../partials/components/history-section.html')
@@include('../partials/components/services-section.html')
@@include('../partials/components/section-intro.html',{
"title":"RECENT WORKS",
"body":"It has survived not only five centuries, but also the leap scrambled it to make a type."
})
@@include('../partials/components/works-section.html')
@@include('../partials/components/study-section.html')
@@include('../partials/components/about-us/about-us-section.html')
@@include('../partials/components/section-intro.html',{
"title":"OUR PRICING",
"body":"A 30 days free trial for all. A brief story about how this process works, keep an eye till the end."
})
@@include('../partials/components/our-pricing/our-pricing-section.html')
@@include('../partials/components/our-team-section.html')
@@include('../partials/components/integration-section.html')
@@include('../partials/components/blog/blog-section.html')
@@include('../partials/components/contact-section.html')
@@include('../partials/components/footer-section.html')
@@include('../partials/components/footer.html')
@@include('../partials/scripts/common.html')


Homepage
Queensland
New South Wales
Australian Capital Territory
Victoria
Tasmania
South Australia
Western Australia
Northern Territory


Gamedev Toolkit is a software made by 'E3 Codewares' to help the game developers around the world to speed up their developing process. One can simply take important notes, plan their development process with the To-do list, Generate Game Name, Game Theme, NPC Names based on their gender with the tools and Quick Launch their prefered development apps from the built in launchers.
E3 Codewares or Ellite codewares is a team of developers who came up with the idea of making this software to help the game developers around the world.


{% comment %}
We want to have separate compressed css files for horizon.scss and dashboard.scss.
The reason for it is based on the fact that IE9 has a limit on the number of css rules
that can be parsed in a single css file. The limit is 4095 = (4k - 1). This causes some
css rules getting cut off if one css file to get more than 4k rules inside.
{% endcomment %}
{% load compress %}
{% compress css %}
{% endcompress %}
{% compress css %}
{% endcompress %}


Interface StateSynchronizer<StateT extends Revisioned>
-
- Type Parameters:
StateT
- The type of the object whose updates are being synchronized.
- All Superinterfaces:
java.lang.AutoCloseable
public interface StateSynchronizer<StateT extends Revisioned> extends java.lang.AutoCloseable
Provides a means to have state that is synchronized between many processes. This provides a higher level abstraction overRevisionedStreamClient
.The pattern is to have an object of type StateT that can be updated by objects of type UpdateT. Each host can perform logic based on its current StateT object and apply updates by supplying a function to create UpdateT objects. Updates from other hosts can be obtained by calling
fetchUpdates()
The applying of updates can be conditional on the state that was provided to their generator being the most recent revision, and retrying if it is not. This provides a strong consistency through optimistic concurrency.
As with any optimistic concurrency system, this works best when optimism is justified: i.e. The odds are good another host is not updating the state at the exact same time.
Because they are held in memory and transmitted over the network, state objects are updates should be relatively compact. Implementations might explicitly enforce size limits.
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static interface
StateSynchronizer.UpdateGenerator<StateT extends Revisioned>
A function which given a state object populates a list of updates that should be applied.static interface
StateSynchronizer.UpdateGeneratorFunction<StateT extends Revisioned,ReturnT>
Similar toStateSynchronizer.UpdateGenerator
but it also returns a result for the caller.
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description long
bytesWrittenSinceCompaction()
Calculates the number of bytes that have been written since the state has last been compacted by callingcompact(Function)
This may be useful when calculating when a compaction should occur.void
close()
Closes the StateSynchronizer and frees any resources associated with it.void
compact(java.util.function.Function<StateT,InitialUpdate<StateT>> compactor)
Provide a function that generates compacted version of localState so that we can drop some of the history updates.void
fetchUpdates()
Fetch and apply all updates needed to the state object held locally up to date.StateT
getState()
Gets the state object currently held in memory.void
initialize(InitialUpdate<StateT> initial)
This method can be used to provide an initial value for a new stream if the stream has not been previously initialized.void
updateState(StateSynchronizer.UpdateGenerator<StateT> updateGenerator)
Creates a new update for the latest state object and applies it atomically.<ReturnT> ReturnT
updateState(StateSynchronizer.UpdateGeneratorFunction<StateT,ReturnT> updateGenerator)
Similar toupdateState(UpdateGenerator)
but this version returns a result object supplied by theStateSynchronizer.UpdateGeneratorFunction
.void
updateStateUnconditionally(Update<StateT> update)
Persists the provided update.void
updateStateUnconditionally(java.util.List<? extends Update<StateT>> update)
Same asupdateStateUnconditionally(Update)
, except it persists multiple updates at the same time so they will not be interleaved with other updates.
-
-
-
Method Detail
-
getState
StateT getState()
Gets the state object currently held in memory. This is a non-blocking call.- Returns:
- Revisioned state object
-
fetchUpdates
void fetchUpdates()
Fetch and apply all updates needed to the state object held locally up to date.
-
updateState
void updateState(StateSynchronizer.UpdateGenerator<StateT> updateGenerator)
Creates a new update for the latest state object and applies it atomically. The UpdateGenerator provided will be passed the latest state object and a list which it can populate with any updates that need to be applied. These updates are recorded and applied conditionally on the state object that was passed to the function being up to date. If another process was applying an update in parallel, the state is updated and updateGenerator will be called again with the new state object so that it may generate new updates. (Which may be different from the one it previously generated) By re-creating the updates in this way, consistency is guaranteed. When this function returns the generated updates will have been applied to the local state.- Parameters:
updateGenerator
- A function that given the current state can supply updates that should be applied.
-
updateState
<ReturnT> ReturnT updateState(StateSynchronizer.UpdateGeneratorFunction<StateT,ReturnT> updateGenerator)
Similar toupdateState(UpdateGenerator)
but this version returns a result object supplied by theStateSynchronizer.UpdateGeneratorFunction
. This is useful if the calling code wishes to do something in response to the update. As an example suppose the update type was MyUpdate and each update and an associated key. Then it might be useful to return the updated keys:List<String> updated = stateSynchronizer.updateState((state, updates) -> { List<MyUpdate> toAdd = findUpdatesForState(state); updates.addAll(toAdd); return toAdd.stream().map(a -> a.getKey()).collect(Collectors.toList()); });
- Type Parameters:
ReturnT
- They type of the result returned by the updateGenerator- Parameters:
updateGenerator
- A function which give the state can supply updates that should be applied.- Returns:
- the result returned by the updateGenerator.
-
updateStateUnconditionally
void updateStateUnconditionally(Update<StateT> update)
Persists the provided update. To ensure consistent ordering of updates across hosts the update is not applied locally untilfetchUpdates()
is called.- Parameters:
update
- The update that all other processes should receive.
-
updateStateUnconditionally
void updateStateUnconditionally(java.util.List<? extends Update<StateT>> update)
Same asupdateStateUnconditionally(Update)
, except it persists multiple updates at the same time so they will not be interleaved with other updates.- Parameters:
update
- The updates that all other processes should receive.
-
initialize
void initialize(InitialUpdate<StateT> initial)
This method can be used to provide an initial value for a new stream if the stream has not been previously initialized. If the stream was already initialized nothing will be changed, and the local state will be updated as thoughfetchUpdates()
- Parameters:
initial
- The initializer for the state
-
bytesWrittenSinceCompaction
long bytesWrittenSinceCompaction()
Calculates the number of bytes that have been written since the state has last been compacted by callingcompact(Function)
This may be useful when calculating when a compaction should occur.- Returns:
- The number of bytes written since the last call to
compact(Function)
-
compact
void compact(java.util.function.Function<StateT,InitialUpdate<StateT>> compactor)
Provide a function that generates compacted version of localState so that we can drop some of the history updates.NOTE: If InitialUpdate returned does not generate local state exactly corruption will occur.
- Parameters:
compactor
- An generator of InitialUpdates given a state.
-
close
void close()
Closes the StateSynchronizer and frees any resources associated with it. (It may no longer be used)- Specified by:
close
in interfacejava.lang.AutoCloseable
- See Also:
AutoCloseable.close()
-
-


We help you identify the job available in each state. You can find job & travel based on the state you want to go & explorer. You can do short term projects & keep traveling
Statastics based on job market in each state.
Access to every job in the country.
Get alerts when you find the perfect job!


Back
Search Weather
Search
Weather conditions
Date
Climate
Min_Temp
Max_Temp
Pending......


About the Early Warning System
Cambodia is a country consistently ranked as one of the most vulnerable to the effects of natural disasters.
In order to deliver timely and potentially lifesaving information to people in disaster prone areas, an Early Warning System (EWS) was conceived by the organization, People In Need (PIN) .
People in Need realized that the EWS needs to be accessible to all Cambodians, regardless of literacy and Internet connectivity issues. They decided to look into a solution which uses voice based messaging for alerts and Interactive Voice Response (IVR) for registration.
With help from the Royal Cambodian Government, the Telecommunication Regulator of Cambodia (TRC) and the National Committee for Disaster Management (NCDM), it was regulated that the Early Warning System must be provided free of charge by the Mobile Network Operators (MNOs) in Cambodia.
With the pieces of the puzzle coming together the problems that still remained were:
The major mobile network operators in Cambodia each provided a SIP connection, but lacked the technology that People In Need required to handle user registrations and send out automated flood alerts.
Somleng SCFM is an open source contact center platform and call flow manager designed for Somleng and Twilio. Somleng SCFM comes complete with its own REST API for managing contacts, callouts and phone calls and can be configured to send out alerts and listen for inbound calls through Somleng which provides an open source implementation of Twilio's REST API.
Unlike Twilio, Somleng gives you full control over where and how inbound and outbound calls are routed from/to. Somleng is configured to send out alerts and listen for inbound calls via SIP connections provided by the local mobile network operators.
To summarize the technology:
In Somalia returnee households from Dadaab refugee camp in Kenya and vulnerable households in Bay and Bakool received emergency unconditional cash-based transfer assistance package to help them meet their needs during the current drought period.
In order to share information and get feedback about the program, a voice-based messaging solution was proposed. In the proposal voice messages and surveys would be recorded in the Somali language and delivered to the household head by mobile phone calls.
The price for terminating a call through Twilio in Somalia is $0.7680 per minute . To date more than 75.8 K minutes worth of calls have been sent out which would equate to $58,238.98 on Twilio.
In order to reduce costs and promote local businesses, Africa's Voices Foundation in conjunction with UNICEF Somalia partnered with Hormuud , a local MNO in Somalia. In comparison, Hormuud's pricing is between $0.04 and $0.07 per minute.
Somleng SCFM was again used in this project to provide Africa's Voices Foundation with a dashboard for scheduling callouts and managing recipients. Automated voice messages were sent to beneficiaries via Somleng through Hormuud.
In Guatemala, 5 out of 10 children under six years old suffer from chronic child malnutrition. Early childhood, is the greatest window of opportunity to support the development of children's brains, bodies, and abilities through comprehensive interventions. Additionally, Guatemala is a multicultural and multilingual country, with 22 languages, including the Mayan, Spanish, Xinka and Garifuna. The use of the Spanish language has predominated in healthcare services, making it difficult for Mayan speaking population throughout the country to access public services every day.
With the objective of improving the nutritional conditions of children, adolescents, pregnant and lactating women, UNICEF Guatemala is coordinating with Government institutions at national, departmental and municipal level the implementation of comprehensive strategy to address stunting in Huehuetenango, Quiché, Chiquimula and Alta Verapaz.
Given the current situation of COVID-19, there are actions that must be adapted to the new scenario, including the use of innovative solutions to reach the population through virtual platforms. The use mobile technology as a catalyst tool can accelerate the achievement of nutritional results for Guatemalan children.
Corazón contento is a free-volunteer subscription mobile service that seeks to promote and strength early childhood development through a comprehensive intervention, with flexible models that take into account cultural differences and the reality of the country. Using text messages (SMS), social media, as well as voice messages (IVR) to provide an integrated package of information about: health, hygiene, sanitation, maternal nutrition, breastfeeding, complementary feeding and parenting guidelines directed delivered to caregivers (mothers, fathers) of children, as well as pregnant and lactating women and primary health care workers in seven native languages (Qʼeqchiʼ, Poqomchiʼ, Chʼortiʼ, Qʼanjobʼal, Chuj, Akateko and Ixil).
To this day, UNICEF Guatemala has achieved:
RapidPro is an open source software platform that allows for building and scaling mobile-based applications from anywhere in the world. RapidPro is designed to send personalized messages with responses analyzed in real-time.
Somleng is an open source cloud communications platform which can be used to deliver IVR messages through local mobile network operators.
Voice Messages are recorded into RapidPro and delivered to the beneficiary's phone via Somleng. Together RapidPro and Somleng are powering the way governments and development partners connect, engage and collaborate directly with the most important - and often most marginalized - voices in their communities.
In Mexico, Somleng is powering C3ntro Telecom's Cloud Communications Platform as a Service (CPaaS).
Somleng provides an open source, white-labeled, CPaaS solution for all types of carriers e.g. telecom companies, mobile network operators and aggregators.
C3ntro Telecom uses Somleng to provide their own custom branded CPaaS solution to their customers. Their customers can enjoy the power of programmable voice and SMS through Somleng's open source implementation of Twilio's REST API, while C3ntro keeps their branding.
By partnering with Somleng, C3ntro can offer a full-stack solution to their customers and therefore compete directly with the big tech providers such as Twilio and Vonage.
With feedback from C3ntro we have developed Somleng with an offering for Carriers, which includes a Carrier Dashboard and API.
For more info please checkout our Carrier Documentation .
People in Need (PIN)'s mHealth project, implemented in cooperation with the Ministry of Health (MoH) Zambia Telecommunications Company Limited (ZAMTEL) and powered by Somleng, is an innovative and one-of-a-kind intervention in Zambia.
The project uses voice recorded messages to overcome illiteracy barriers and to improve maternal and child health and nutrition outcomes, influence attitudes and enhance knowledge and skills of women about the importance of key health and nutrition behaviors. The messages were incorporated into dialogues performed by a local drama group that created culturally appropriate characters to provide an educative, engaging and entertaining service, effective at changing people's behaviors. These dialogues were designed typically around specific topics such as health, nutrition or hygiene. The set contains key messages related to maternal health and nutrition as well as nutrition and health of children aged 0-6 and 7-24 months.
The messages were designed to cover the most important behaviors in order to provide timely information that supports the mother to provide the best possible start to their child's life during the first 1000 days most critical days (from the inception until the child is 2 years old). The pilot project targeted 100 women in Mongu and Nalolo districts in Western Zambia and aimed to prove that the concept is relevant and effective in the Zambian context.
The study found that the mHealth intervention has had a significant impact on knowledge, attitudes and practices of women with regards to maternal and infant nutrition and health. The level of satisfaction suggests that the service fills an important gap, is effective at changing behaviors and is highly relevant in the Zambian context. The results suggest that the intervention contributed to improved maternal and child health outcomes and led to changes in key nutrition behaviors. With several upgrades and improvements, which are currently underway, the project indicators may improve further.
More info about the Mama Info health service can be found on their website https://www.mamainfo.org .
In January 2023, UNICEF Nepal launched a blockchain pilot to support 1,500 vulnerable households with cash distribution in the Madhesh province, Nepal . The cash distribution supports landless families, daily wagers and families with disabilities, with children under the age of five. The pilot uses an open-source blockchain based solution called, Rehat - developed by Rumsan , a UNICEF Venture Fund company, from Nepal.
This pilot sees a collaboration of two UNICEF Venture Fund portfolio companies, Rumsan and Somleng . Rahat is using Somleng's Carrier Bypass IVR feature . to support beneficiaries in the cash distribution pilot with information and later to receive feedback from the beneficiaries directly. This feature was developed by Somleng as part of the 2022 Growth Funding round by the UNICEF innovation fund.


Git is version control software on your computer.
We COMMIT our code versions to git on our computer.
Github.com is a cloud service that works with git to help us collaborate and share our code with others.
We PUSH our code to github.com
We DEPLOY our projects to a server so that the world can view in a browser on a computer, tablet or phone.
In the bootcamp we DEPLOY to the bootcamp-coders.cnm.edu server
DEPLOY and PUSH are DIFFERENT!!


Accordion with descriptions
What is it?
The pattern is a list of headings each with a description and some hidden content. When you select the heading or the description the hidden content is revealed. There is also a button to open and close all the content.
The pattern allows users to see a summary of available content which can then be expanded if a user want to read more.
Accessibility success criteria
- It must be possible to focus on the accordion controls using the tab key.
- The accordion controls must change in appearance when keyboard focus moves to it.
- It must be possible to activate the accordion controls using the appropriate keys.
- The accordion control must change in appearance when the mouse is hovered over it.
- It must be possible to activate the accordion controls using a click.
- The accordion control must be large enough to tap accurately with one finger.
- The accordion control must change in appearance to indicate the touch-down state.
- It must be possible to activate the accordion controls using voice commands.
- The expanded/collapsed state of the accordion must be available in the code.
- The relationship between the accordion controls and disclosed content must be available in the code.
- It must be possible to focus on the accordion controls using standard screen reader button commands.
- The accordion controls must have a visible text label.
- The accordion text must use a default font size that makes reading comfortable.
- The contrast between the accordion text label and its background must meet (or exceed) a ratio of 4.5:1.
- The accordion control must change appearance when it is expanded/collapsed.
- The markup must validate
- The content must be available without javascript
- The content must be in a logical order in the source code


If building a website is like building a house, HTML is the bare structure, the walls, the doors, windows. CSS is the aesthetics of the house, the style communicates the purpose and the ideas. DOM defines the type of building the structure is. A house, office, apartment etc
To boxify simply means to take every element as they appear in a design document and box them. To box is to organise which area they will be placed on a web page. This establishes framework and heirarchy.
The box model is a diagram showing the way margin, border, padding and content affect the area used by a box. The diagram is color coded and shows an example of the exact areas defined by the different boundaries.
<


Replication, Clustering, and Connection Pooling
From PostgreSQL wiki
Contents |
Introduction
There are many approaches available to scale PostgreSQL beyond running on a single server. An outline of the terminology and basic technologies involved is at High Availability and Load Balancing. There is a presentation covering some of these solutions.
There is no one-size fits all replication software. You have to understand your requirements and how various approaches fit into that. For example, here are two extremes in the replication problem space:
- You have a few servers connected to a local network you want to always keep current for failover and load-balancing purposes. Here you would be considering solutions that are synchronous, eager, and therefore conflict-free.
- Your users take a local copy of the database with them on laptops when they leave the office, make changes while they are away, and need to merge those with the main database when they return. Here you'd want an asynchronous, lazy replication approach, and will be forced to consider how to handle conflicts in cases where the same record has been modified both on the master server and on a local copy.
These are both database replication problems, but the best way to solve them is very different. And as you can see from these examples, replication has a lot of specific terminology that you'll have to understand to figure out what class of solution makes sense for your requirements. A great source for this background is in the Postgres-R Terms and Definitions for Database Replication. The main theoretical topic it doesn't mention is how to resolve conflict resolution in lazy replication cases like the laptop situation, which involves voting and similar schemes.
Features in the Core of PostgreSQL
The PostgreSQL core team considered replication and clustering technology outside the scope of the main project's focus but this changed in Spring 2008, see the Core Team's statement.
- Hot Standby/Streaming Replication is available as of PostgreSQL 9.0 and provides asynchronous binary replication to one or more standbys. Standbys may also become hot standbys meaning they can be queried as a read-only database. This is the fastest type of replication available as WAL data is sent immediately rather than waiting for a whole segment to be produced and shipped.
- Warm Standby/Log Shipping is a HA solution which 'replicates' a database cluster to an archive or a warm (can be brought up quickly, but not available for querying) standby server. Overhead is very low and it's easy to set up. This is a simple and appropriate solution if all you care about is continuous backup and short failover times.
Comparison matrix
This page is being overhauled at Clustering
| Program | License | Maturity | Replication Method | Sync | Connection Pooling | Load Balancing | Query Partitioning |
|---|---|---|---|---|---|---|---|
| PGCluster | BSD | See version details on site | Master-Master | Synchronous | No | Yes | No |
| pgpool-I | BSD | Stable | Statement-Based Middleware | Synchronous | Yes | Yes | No |
| pgpool-II | BSD | Recent release | Statement-Based Middleware | Synchronous | Yes | Yes | Yes |
| slony-I | BSD | Stable | Master-Slave | Asynchronous | No | No | No |
| Bucardo | BSD | Stable | Master-Master, Master-Slave | Asynchronous | No | No | No |
| Londiste | BSD | Stable | Master-Slave | Asynchronous | No | No | No |
| Mammoth | BSD | Stable | Master-Slave | Asynchronous | No | No | No |
| rubyrep | MIT | Recent Release | Master-Master, Master-Slave | Asynchronous | No | No | No |
Replication
Aside from Warm Standby, mentioned above...
- Slony-I: Seems good, single master only, master is a single point of failure, no good failover system for electing a new master or having a failed master rejoin the cluster. Slave databases are mostly for safety or for parallelizing queries for performance. Suffers from O(N^2) communications (N = cluster size). with reasonable sysadmin you can implement failover system yourself. regarding communications, you can cascade the replication to reduce load on the master. If you were implementing a large replication cluster, this would probably be a good idea. Slony is powerful, trigger based, and highly configurable.
- PGCluster: PGCluster (which, incidentally, is not the same as PGCluster-II, a shared-disk solution), which does synchronous multimaster replication. Two single-points failure spots, load balancer and the data replicator. The project has historically looked a bit dead, but they just released a new version and http://pgfoundry.org/projects/pgcluster is up to date (at least downloads page) One major downside to PGCluster is that it uses a modified version of PostgreSQL, and it usually lags a few releases behind.
- http://pgpool.projects.postgresql.org/ pgpool 1/2 is a reasonable solution. it's statement level replication, which has some downsides, but is good for certain things. pgpool 2 has a neat distributed table mechanism which is interesting. You might want to be looking here if you have extremely high ratios of read to write but need to service a huge transaction volume. Supports load-balancing and replication by implementing a proxy that duplicates all updates to all slaves. It can partition data by doing this, and it can semi-intelligently route queries to the appropriate servers.
- "Mammoth Replicator" - BSD - http://www.commandprompt.com/products/mammothreplicator/ - Former proprietary solution, now open source. Uses a central logging process to distribute data changes amongst nodes. Essentially a fork of Postgres, as the changes are written directly into the backend.
- "Bucardo" - BSD License - http://bucardo.org/ - Trigger-based, asynchronous, multi-master or master-slave, written using plperl.
- Cybertec, an Austrian company, offers a proprietary packaging of PGCluster. They simply call it PostgreSQL Multimaster-Replication, see http://www.cybertec.at.
- Londiste, a part of Skytools (https://developer.skype.com/SkypeGarage/DbProjects/SkyTools) which is a collection of replication tools from the Skype people. Purports to be simpler to use than Slony.
- Continuent uni/cluster, proprietary and the related Sequoia (jdbc, formerly known as c-jdbc)
- Postgres-R is still in development. It features eager and thus conflict-free, but async multi-master replication.
- SymmetricDS is an open-source, web-enabled, database independent, data synchronization software application. It uses web and database technologies to replicate tables between relational databases in near real time. The software was designed to scale for a large number of databases, work across low-bandwidth connections, and withstand periods of network outages. Supports several relational databases, including PostgreSQL. Licensed under Lesser GPL (LGPL).
- DRBD (http://www.drbd.org/), a device driver that replicates disk blocks to other nodes. This works for failover only, not for scaling reads. Easy migration of devices if combined with an NFS export.
- Daffodil Replicator. Supports several relational databases, including PostgreSQL. Licensed under GPL.
- "RubyRep" - MIT License - http://www.rubyrep.org/ - Ruby based, asynchronous, multi-master replication system, which supports Postgres and MySQL.
- "pg_comparator" - BSD License - http://pgfoundry.org/projects/pg-comparator/ - Perl-based, table-level async master-slave "diff" and "patch" method of replication. Low configuration overhead.
Inactive projects
- Slony-II
- PGReplication
Clustering
- Greenplum Database (formerly Bizgres MPP), proprietary. Not so much a replication solution as a way to parallelize queries, and targeted at the data warehousing crowd. Similar to ExtenDB, but tightly integrated with PostgreSQL.
- GridSQL for EnterpriseDB Advanced Server (formerly ExtenDB)
- sequoia (jdbc, formerly known as c-jdbc)
- PL/Proxy - database partitioning system implemented as PL language.
 Shared-nothing clustering.
Connection Pooling and Acceleration
Connection pooling programs let you reduce database-related overhead when it's the sheer number of physical connections dragging performance down. This is particularly important on Windows, where system limitations prevent large number of connections; see "I cannot run with more than about 125 connections at once" in the Windows FAQ. It's also vital for web applications where the number of connections can get very large.
Some programs that implement connection pooling are:
Some people also or alternately use memcached in various ways to reduce the work the database handles directly by caching popular data.
Credits
Sources for the initial information on this page include:
A existing page covering this topic in German is at http://burger-ag.de/postgresql_replikation.whtml It translates pretty well through Babelfish.
Sources for more information located but not yet integrated into here:
- Portable Scale-Out Benchmarks for PostgreSQL by Robert Hodges
- High Availability and PostgreSQL by Gavin Sherry


test linkbolditalic
This instance bbCodeEditor will be removed after 3 seconds.
This instance bbCodeEditor is removed.
Lorem ipsum.


Fields and methods of the helma.Search class
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Search.js')
To use this optional module, its repository needs to be added to the application, for example by calling app.addRepository('modules/helma/Search.js')
Constructs a new instance of helma.Search. This merely
checks if the Apache Lucene library is in the application
classpath.
methods
- getDirectory(dir, create)
- getRAMDirectory(dir)
- createIndex(dir, analyzer)
Constructs a new QueryFilter instance. This class
wraps a lucene QueryFilter.
parameters
| helma.Search.Query | q | The query object to use as the basis for the QueryFilter instance. |
methods
Creates a new instance of helma.Search.Index
parameters
| org.apache.lucene.store.Directory | directory | The directory where the Lucene index is located at. |
| org.apache.lucene.analysis.Analyzer | analyzer | The analyzer to use when modifying the index. |
methods
- getWriter(create, autoCommit)
- addIndexes(dir)
- create()
- size()
- count(fieldName, fieldValue)
- optimize()
- isLocked()
- unlock()
- close()
- addDocument(doc)
- addDocuments(docs)
- removeDocument(fieldName, fieldValue)
- removeDocuments(fieldName, values)
- updateDocument(docObj, fieldName)
Creates a new instance of helma.Search.Seacher
parameters
| helma.Search.Index | index | The index to search in. |
methods
- search(query, filter)
- sortBy(fieldName, type)
- close()
properties
- helma.Search.HitCollection hits
- java.util.Vector sortFields
Creates a new instance of helma.Search.HitCollection
parameters
| org.lucene.search.Hits | hits | The hit collection returned by lucene. |
methods
- get(idx)
- size()
- length()
Creates a new instance of helma.Search.TermQuery
parameters
| String | field | The name of the field |
| String | str | The value of the field |
properties
- org.apache.lucene.search.TermQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Creates a new instance of helma.Search.BooleanQuery
parameters
| String | name of the field | |
| String | query string |
methods
- addTerm(field, str, clause, analyzer)
- addQuery(q, clause)
properties
- org.apache.lucene.search.BooleanQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Constructs a new helma.Search.PhraseQuery instance that wraps
a Lucene Phrase Query object.
parameters
| String | field | The name of the field |
| String | str | The phrase query string |
methods
- addTerm(field, str)
properties
- org.apache.lucene.search.PhraseQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Constructs a new helma.Search.RangeQuery instance.
parameters
| String | field | The name of the field |
| String | from | The minimum value to match (can be null) |
| String | to | The maximum value to match (can be null) |
| Boolean | inclusive | If true the given min/max values are included |
properties
- org.apache.lucene.search.RangeQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Constructs a new helma.Search.FuzzyQuery instance.
parameters
| String | field | The name of the field |
| String | str | The query string to match |
properties
- org.apache.lucene.search.FuzzyQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Constructs a new helma.Search.PrefixQuery instance.
parameters
| String | field | The name of the field |
| String | str | The query string to match |
properties
- org.apache.lucene.search.PrefixQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Constructs a new helma.Search.WildcardQuery instance.
parameters
| String | field | The name of the field |
| String | str | The query string to match |
properties
- org.apache.lucene.search.WildcardQuery query
inherits
getQuery() from helma.Search.Query
getBoost() from helma.Search.Query
setBoost(fact) from helma.Search.Query
Creates a new instance of helma.Search.Document.
parameters
| org.apache.lucene.document.Document | document | Optional Lucene Document object that should be wrapped by this Document instance. |
methods
- addField(name, value, options)
- getField(name)
- removeField(name)
- getBoost()
- setBoost(boost)
Creates a new Field instance
parameters
| Object | name | The name of the field |
| Object | value | The value of the field |
| Object | options |
Optional object containing the following properties
(each of them is optional too):
|
methods
- getField()
- getBoost()
- setBoost(boost)
- isStored()
properties
- String name
- String value
- String dateValue
The search results.
A vector with SortField instances, if any have been defined.
see
Contains the wrapped TermQuery instance
Contains the wrapped BooleanQuery instance
Contains the wrapped PhraseQuery instance
Contains the wrapped RangeQuery instance
Contains the wrapped FuzzyQuery instance
Contains the wrapped PrefixQuery instance
Contains the wrapped WildcardQuery instance
Contains the name of the field
Contains the string value of the field
Contains the value of the field converted into a date object.
Methods
Returns a new Analyzer instance depending on the key
passed as argument. Currently supported arguments are
"br" (BrazilianAnalyzer), "cn" (ChineseAnalyzer), "cz" (CzechAnalyzer),
"nl" (DutchAnalyzer), "fr" (FrenchAnalyzer), "de" (GermanAnalyzer),
"el" (GreekAnalyzer), "keyword" (KeywordAnalyzer), "ru" (RussianAnalyzer),
"simple" (SimpleAnalyzer), "snowball" (SnowballAnalyzer), "stop" (StopAnalyzer)
"whitespace" (WhitespaceAnalyzer). If no argument is given, a StandardAnalyzer
is returned.
parameters
| String | key | The key identifying the analyzer |
returns
| A newly created Analyzer instance |
Returns the wrapped filter instance
Returns an instance of org.apache.lucene.store.FSDirectory. If
no index is present in the given directory, it is created on the fly.
parameters
| File, helma.File, java.io.File, String | dir | The directory where the index is located or should be created at. |
| Boolean | create | If true the index will be created, removing any existing index in the same directory |
returns
| The index directory. |
Returns a RAM directory object.
parameters
| File, helma.File, java.io.File, String | dir | Optional directory containing a Lucene index from which this RAM directory should be created. |
returns
| A RAM directory instance. |
Creates a new Lucene index in the directory passed as
argument, using an optional analyzer, and returns an instance
of helma.Search.Index. Any already existing index in this
directory will be preserved.
parameters
| org.apache.lucene.store.Directory | dir | The directory where the index should be stored. This can be either a FSDirectory or a RAMDirectory instance. |
| org.apache.lucene.analysis.Analyzer | analyzer | The analyzer to use for the index. If not specified a StandardAnalyzer will be used. |
returns
| The index instance. |
Returns an IndexWriter instance that can be used to add documents to
the underlying index or to perform various other modifying operations.
If the index is currently locked this method will try for the next
two seconds to create the IndexWriter, otherwise it will
throw an error.
parameters
| Boolean | create | True to create the index (overwriting an existing index), false to append to an existing index. Defaults to false |
| Boolean | autoCommit | Enables or disables auto commit (defaults to false) |
returns
| An IndexWriter instance. |
Returns an IndexReader instance. Due to locking issues an
IndexModifier should be used for deleting documents.
returns
| An IndexReader instance |
Returns the directory the underlying Lucene index is located at.
returns
| The directory of this index |
Returns the analyzer used within this index.
returns
| The analyzer used within this index. |
Returns a searcher for querying this index.
returns
| A searcher useable for querying the index. |
Merges the indexes passed as argument into this one.
parameters
| org.apache.lucene.store.Directory | dir | At least one index director to add to this index. |
Creates a new index. This will delete any existing index
files in the directory of this index.
returns
| True if creating the index was successful, false otherwise |
Returns the number of documents in this index.
returns
| The number of documents in this index. |
Returns the number of documents with the given field name and value.
parameters
| String | fieldName | The name of the field |
| String | fieldValue | The value of the field |
returns
| The number of documents |
Optimizes the underlying index.
Returns an array containing all field names in this index.
returns
| An array with the field names in this index. |
Checks if the index is locked.
returns
| True if the underlying index is locked, false otherwise. |
Unlocks the index. Use this with caution, as it removes
any active locks in the Lucene index, which might lead
to index corruption.
Closes the underlying index directory for future operations.
Adds a document to the index.
parameters
| helma.Search.Document | doc | The document to add to the index. |
Adds all documents in the passed collection to this index.
parameters
| java.util.Hashtable, java.util.Vector, Array | docs | The documents to add to the index. |
Remove all documents from the index whose field-value
with the given name matches the passed value argument.
parameters
| String | fieldName | The name of the field |
| String | fieldValue | The value of the field. |
Removes all documents whose field with the given name matches
the values passed as argument.
parameters
| String | fieldName | The name of the field |
| java.util.Hashtable, java.util.Vector, Array | values | The values that define the documents that should be removed from the index. |
Updates the index with the document passed as argument. In contrast
to addDocument() this removes any existing objects whose fieldName
matches the one of the document object. Eg. if the document object
has a field "Id" with the value "123", all document objects whose
fieldName "Id" matches "123" will be removed from the index before.
parameters
| helma.Search.Document | docObj | Document object to add to index. |
| String | fieldName | The name of the identifier field. |
Returns the wrapped IndexSearcher instance.
Searches an index using the query passed as argument.
The resulting collection of hits is stored in the property "hits"
of this Searcher instance. Don't forget to close the searcher
when finished processing its hits.
parameters
| helma.Search.Query | query | The query to use for searching |
| helma.Search.QueryFilter | filter | An optional query filter for filtering the results. |
returns
| The number of hits. |
Sets a field as result sorting field. This method can be called
with a different number of arguments:
sortBy(fieldName)
sortBy(fieldName, type)
sortBy(fieldName, reverse)
sortBy(fieldName, type, reverse)
parameters
| String | fieldName | The name of the field in the index by which the search result should be ordered. |
| String | type | The type of the field defined by argument fieldName. Valid arguments are "string", "float", "int", "score", "doc", "auto", "custom". Default is "auto". See http://lucene.apache.org/java/docs/api/org/apache/lucene/search/SortField.html for an explanation. |
Closes the wrapped IndexSearcher instance.
Silently converts the hit at the given index position into
an instance of helma.Search.Document.
parameters
| Number | idx | The index position of the hit |
returns
| The document object at the given index position |
Returns the number of hits in this collection.
returns
| The number of hits. |
Returns the number of hits in this collection.
This method is deprecated, use {@link #size} instead.
returns
| The number of hits. |
see
Returns the wrapped Lucene Query object.
returns
| The wrapped query object |
Returns the boost factor of this query.
Sets the boost factor of this query clause to
the given number. Documents matching this query
will have their score multiplied with the given
factor
parameters
| Number | fact | The factor to multiply the score of matching documents with. |
Adds a term to the wrapped query object. This method can be called
with two, three or four arguments, eg.:
addTerm("fieldname", "querystring") addTerm("fieldname", "querystring", "and") addTerm("fieldname", "querystring", helma.Search.getAnalyzer("de")) addTerm("fieldname", "querystring", "not", helma.Search.getAnalyzer("simple"))
parameters
| String, Array | field | Either a String or an Array containing Strings that determine the index field(s) to match |
| String | str | Query string to match |
| String | clause | Boolean clause ("or", "not" or "and", default is "and") |
| org.apache.lucene.analysis.Analyzer | analyzer | An analyzer to use |
Adds an additional query clause to this query.
parameters
| helma.Search.Query | q | The query to add |
| String | clause | Boolean clause ("or", "not", or "and", default is "and") |
add a term to the end of the phrase query
parameters
| field | ||
| str |
Returns the wrapped Lucene Document object
returns
| The wrapped Document object |
Adds a field to this document.
parameters
| String, helma.Search.Document.Field | name | The name of the field, or an instance of {@link helma.Search.Document.Field}, in which case the other arguments are ignored. |
| String | value | The value of the field |
| Object | options |
Optional object containing the following properties
(each of them is optional too):
|
Returns a single document field.
parameters
| String | name | The name of the field in this document object. |
returns
| The field with the given name |
Returns the fields of a document object.
returns
| An array containing all fields in this document object. |
Removes all fields with the given name from this document
parameters
| String | name | The name of the field(s) to remove |
Returns the boost factor of a document.
returns
| The boost factor of a document |
Sets the boost factor of a document.
parameters
| Number | boost | The boost factor of the document |
Returns the wrapped field instance
returns
| The wrapped field |
Converts the value passed as argument to the appropriate string value. For
null values this method returns an empty string.
parameters
| Object | value | The value to convert into a string |
returns
| The value converted into a string |
Returns the boost factor of this field.
returns
| The boost factor of this field |
Sets the boost factor of this field.
parameters
| Number | boost | The boost factor of this field |
Returns true if this field is indexed
returns
| True if this field's value is indexed, false otherwise |
Returns true if this field's value is stored in compressed form in the index
returns
| True if this field's value is compressed, false otherwise |
Returns true if this field's value is stored in the index
returns
| True if this field's value is stored, false otherwise |
Returns true if this field's value is tokenized
returns
| True if this field's value is tokenized, false otherwise |
Returns true if this field's term vector is stored in the index
returns
| True if this field's term vector is stored, false otherwise |


Announcement
Lorem ipsum dolor sit amet, consectetur adipisicing elit. Atque sequi consectetur provident perferendis nisi ipsam, rerum dolore veritatis eveniet, voluptatem perspiciatis mollitia aliquam, rem doloribus! Veniam, eaque. Eum, doloribus, itaque. Click Here
Events
-
Jan 05
Alumni Event Title • Alumni Event Location
April 5, 2015 4:00 PM • Consectetur adipisicing elit. Ad nesciunt alias illum itaque ducimus harum possimus laboriosam, labore asperiores suscipit porro quod sapiente, quo nisi, commodi mollitia beatae deleniti cumque.
Read more and RSVP -
Feb 12
Alumni Event Title • Alumni Event Location
April 5, 2015 4:00 PM • Labore asperiores suscipit porro quod sapiente, quo nisi, commodi mollitia beatae deleniti cumque.
Read more and RSVP -
Mar 28
Alumni Event Title • Alumni Event Location
April 5, 2015 4:00 PM • Consectetur adipisicing elit. Ad nesciunt alias illum itaque ducimus harum possimus laboriosam, labore asperiores suscipit porro quod sapiente, quo nisi, commodi mollitia beatae deleniti cumque.
Read more and RSVP -
Apr 21
Alumni Event Title • Alumni Event Location
April 5, 2015 4:00 PM • Lorem ipsum dolor sit amet, consectetur adipisicing elit. Cumque numquam dolor nemo, voluptatem temporibus suscipit itaque quos? Adipisci quia dolores ab quaerat, inventore, sunt dicta qui impedit, molestiae nulla voluptates.
Read more and RSVP
Subscribe to Whitman's events!
From award-winning authors to amazing musicians, Whitman College has hundreds of free and low-cost events each year that are open to the public. To receive emails about upcoming events, subscribe to our community events listserv by sending an email to community_events-subscribe@lists.whitman.edu.


Basic Preferences:
Font Family
Font Size
Background Color
Line Height
Text Color
Change button icon (on browser bar) on enable/disable
Advanced:
Forcefully override website styling
Website Data:
Reset Buttons:
Reset Preferences
Reset Website Data
These options will autosave. Leave value blank for no injected styling of that type. Advanced options may break some webpages.


The byway begins in Estacadia, just beyond the Portland Metro area and the southern flank of Mt. Hood. The gorgeous, jade-green Clackamas River carves a deep canyon south of town as the byway heads south high above the river. As the route enters the Mt. Hood National Forest, you’ll pass several riverside campground and trailheads. The Clackamas River Trail runs 7.8 mils along the opposite bank of the river. Past the Ripplebrook Ranger Station, the byway continues on FR-46, and the Riverside National Recreation Trail winds along the river’s east bank. The route then skirts along the Olallie Lake National Scenic Area, where dozens of trails curve among dozens of mountain lakes on a plateau just north of Mt. Jefferson. Continuing west will be the Breitenbush River, where the Beitenbush Gorge National Recreation Trail leads along the river’s south fork and eventually through narrow basalt gorge.
The byway turns onto OR-22 where Detroit Lake is created by the damming of the Santiam River. The Detroit Lake State Recreation area offers 32 miles of shoreline, beautiful waters for boaters and anglers, and campsites. The route follows the Santiam River south through the Willamette National Forest, where several campgrounds and trails spin off into the woods towards 10,497-foot Mt. Jefferson. The West Cascades Scenic byway climbs up to Santiam Junction, where it turns west on US-20, and then south on OR-126. This stretch of the byway is shared with the McKenzie Pass-Santiam Pass Scenic Byway.
The final leg of the trip continues along the south fork of the McKenzie River on FR-19, also known as Aufderheide Drive. Stretch your legs on the Delta Old Growth Nature trail before heading south along and above the Cougar Reservoir. The road climbs to Box Canyon where trails lead off into the Three Sisters Wilderness. The byway quickly leaves the McKenzie behind and soon meets up with North Fork Middle Fork Willamette River. The scenery continues as it winds through deep canyons along the river with several spots for anglers to cast line into rolling waters. In Westfir, the barn-red Office Covered Bridge crosses the North Fork Middle Fork Willamette River – an enchanting conclusion to the scenic tour. Just next door you’ll find the town of Oakridge, where mountain bikers enjoy its miles of single-track trails through its wild forests.


Instagramable hills and mountain
Shhhhhhhh don't tell anyone! it beautiful
One of the longest river in scotland
Beautiful and peaceful place
An great place to chill and relax
One of the highest mountain in UK
Beautiful forest and rivers


It seems as if we are having problems on our end. Please check back later.
Check here if the website is down or not


The Townie Cup Championship was founded in 2003 by Nick Snyder. It was started as a 16 player get together and has transformed into over 100 players participating each year. In the past few years we have also joined forces with the Bowling Green Schools Foundation to raise money for the Preston Scott Pahl Memorial Scholarship fund. The scholarship recipient is a BG High School senior that is pursuing higher education.


{# Copyright 2011 Google Inc. All Rights Reserved. #} {% comment %} UI for editing the changelog of a migration. Accepts one argument, "migration", which is the migration to render controls for. Author<EMAIL_ADDRESS>(Nick Santos) {% endcomment %}


Home
All Product
My Garden
Log out
Log in
See Shopping Basket
Thank you for choosing Flover
You choosed:
Total:
0.00
GBP
Deliver address
Country/Region
First Name
Last Name
Building Name
Street Address
City
County
Postcode
Phone Number
Payment Information
Card Number
Holder’s Name
Date of Expiry
CVV
Back to top
Your order has been completed!
Don't forget to get your virtual flower online!


EasyRash is a project creted by Filippo Boiani and Ludovico Loreti with the aim to help researchers to comment and share articles in an easy and simple way.
The article should be written in RASH, a framework which includes a markup language defined as a subset of HTML+RDF for writing scientific articles, and related tools to convert it into different formats, to extract data from it, etc.
Accept or Recect article
If you are a Chair you can watch what the reviewers have written about the article and decide either if accept or reject the article.
You can express your judgement only once ALL reviewers have commented the article and expressed a judgement.
Enter annotator mode
When you click on this button you enter the annotator mode which allows you to create selections, underline text, create comments and vote the article.
Only one person is allowed to be in annotator mode for each document. When you click on the button you acquire a lock. If someone has acquired the lock before you should wait until it has finished.
When you have finished you can either save you comments or leave without saving by clicking on
Vote article
When you are in annotator mode, you can give a general vote to the entire article. The vote is a number between 1 and 5.
The chair decides either to accept the article or reject the article on the average vote express by all reviewers.
Once you gave a vote to the article you can't express the vote another time.
Show comment list
By clicking on this button you will see a modal containing a table that lists all the comment you have written in annotator mode and that are not saved.
You can update, delete and insert comments as you like.
Create note
After a selection you can press this button in order to highlight the selected text. By highlighting you will be able to comment the fragment.
Overlapping fragment are not allowd, so you should verify what other users have commented.
Save your annotations
Once you have finished your review, you can save the annotaions after the expression of a complexive judjement (using the Vote article
action).
Pick an highlight color
When you enter the annotator mode, you have the possibility to express a preveference over the highlighting color.
Exit annotator mode
When you push this button you exit the annotator mode and al your comments will be saved or deleted.
You can view all the comments by clicking the "show all" button. Every colour correspond to a reviewer but che color are Only 5 and could be repeated because they are assigned ranomically. Overlapping comments have slightly different color as a result of addition of color layers.
When you click on the comment the article will scroll to the related section within the article.
The user can update his profile information by clicking the edit button and typing the old password to confirm.
The mail cannot be changed as well as the id.


SearchUnit - Basic Examples : Filters
Filtering based on custom data, each recipe has custom meta data on its page which is used for filtering. Below notice that "Meal type" uses OR type filter options and "Free from" uses AND type filter options.
Try keywords like: soup, cheese, chicken, salt


Case Study: Python Performance on rotating one-dimensional vectors
I’m a big fan of a nice challenge, therefore, I like books like Programming Pearls, I like to dive into many kinds of solutions to the same problem and try to differentiate them by novelty, performance, elegance, etc…
This time I was playing with a fun problem, from the column 2:
“rotate a one dimensional array of N elements left by I positions”.
The author says it should consume little space and time, so, there are many solutions, obviously. The fun thing is that I was doing it in Python, so you can solve it in many ways, but you can decrease the performance a lot if you choose poorly. In C we could just swap pointers in a doubly linked list, which is what happens in the real implementation of CPython.
The idea that the Author exposed is pretty clever, which is based in reversing the vector only 3 times:
- Reverse the vector, from the first position to the I-th position, where I is the number of position that is wanted to move to the left
- Reverse the vector, from I-th + 1 position to N, where N is the size of this vector
- Reverse the whole vector, again.
In other words, we have the vector AB (Where A is the first part, B is the second), we reverse A so we have Ar, reverse B so we have Br, now we have ArBr, then we reverse the whole thing (ArBr)r, after that, we have the rotated vector. It’s quite beautiful. A picture can help the visualization:
here’s an example with a simple vector:
Now, searching for other approaches, I looked inside the code from CPython, and there’s a nice comment:
"Conceptually, a rotate by one is equivalent to a pop on one side and an append on the other"
Quite elegant solution as well. So, an example:
And the last example I found while searching through Pythonic ways to solve this problem (Even though may not be very fast)
def rotate_pythonic_way(arr, i):
return arr[i:] + arr[:i]
Which is super simple and elegant, what it’s doing is the following:
At first I thought this solution would be the slowest, but we’ll get to that.
One thing that took my attention was the internal method to reverse a list that Python offers, there are two of them, one returns a reversed iterator and you can cast it into a list and the other reverse the exactly same list that is passed as parameter, it shouldn’t take you long to realize which is faster. So I wrote a code with the many solutions to it and I profiled the functions, which gave us a interesting result when ran over a vector with 10 millions integers.
First, the original idea (reverse the vector 3 times), but using the reversed(array) method:
def rotate_original_solution_with_reversed(arr, i):
n = len(arr)
array_A_reversed = list(reversed(arr[0:i]))
array_B_reversed = list(reversed(arr[i:n]))
ArBr = array_A_reversed + array_B_reversed
rotated_array = list(reversed(ArBr))
return rotated_array
and the result:
Original Idea using reversed(arr):
4 function calls in 0.611 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.440 0.440 0.440 0.440 2_1b.py:21(rotate_original_solution_with_reversed)
1 0.171 0.171 0.611 0.611 string:1 module
1 0.000 0.000 0.000 0.000 {len}
####Damn, 0.6s, that’s too slow!
After this one, I changed the way I was reversing the vector, using the other internal method from Python:
def rotate_original_solution_with_reverse(arr, i):
n = len(arr)
array_A = arr[0:i]
array_B = arr[i:n]
array_A.reverse()
array_B.reverse()
ArBr = array_A + array_B
ArBr.reverse()
return ArBr
And the result:
Original Idea using arr.reversed():
7 function calls in 0.322 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.187 0.187 0.210 0.210 2_1b.py:30(rotate_original_solution_with_reverse)
1 0.113 0.113 0.322 0.322 string:1 module
1 0.000 0.000 0.000 0.000 {len}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
3 0.023 0.008 0.023 0.008 {method 'reverse' of 'list' objects}
####From 0.6s to 0.3s, that’s a great improvement. lesson: choose your built-ins/Data Structures/Algorithms carefully.
And now, using the Pythonic Way, which I was thinking that would be the slowest:
And the result:
Pythonic Way:
3 function calls in 0.295 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.238 0.238 0.238 0.238 2_1b.py:45(rotate_pythonic_way)
1 0.056 0.056 0.295 0.295 string:1(module)
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
It was faster than the other methods! Well played, Python.
And the last one, using the pop/append technique, repeated i times:
And the result:
Pop and append way:
5 function calls in 0.013 seconds
Ordered by: standard name
ncalls tottime percall cumtime percall filename:lineno(function)
1 0.000 0.000 0.013 0.013 2_1b.py:49(rotate_pop_append)
1 0.000 0.000 0.013 0.013 string:1(module)
1 0.000 0.000 0.000 0.000 {method 'append' of 'list' objects}
1 0.000 0.000 0.000 0.000 {method 'disable' of '_lsprof.Profiler' objects}
1 0.013 0.013 0.013 0.013 {method 'pop' of 'list' objects}
Ok. That was weird. 0.013 seconds? 13 milliseconds? Crazy, right? I thought the fact of repeating it many times would make it go way slower, but I guess I was wrong!
So, as you can see, an interesting problem can have many solutions, one more elegant, others faster. In the end you may pick the simplest and most intuitive solution, this may be the best for the situation. Some times you gotta go with the strangest and most non-intuitive solution (which reminds me the first time I saw the Quick Sort and all its non-intuitive way to think)
So, if you’re willing to reverse a list with Python, go with List.reverse() method (unless you want the iterators to do something), and if you want to rotate a vector, go with pop/append, it looks faster.