Peanut Butter and Jelly Sandwiches
I’ve been trying to figure out exactly what I think the best thing about statically-typed purely functional programming, Haskell in particular, is. It’s not laziness or monads, although both are wonderful! My current best answer is that it is a combination of three different features that together encourage simple, maintainable, and robust code:
- Pattern matching
- Algebraic data types
- Pure functions
I like to think of these as analogous to a peanut butter and jelly sandwich (or vegemite on toast, which is really well-buttered toast with only a thin layer of vegemite): pattern matching and algebraic data types pair perfectly, and pure functions are the foundation that they need to be maximally effective.
What do I mean by this? Allow me to illustrate with some Haskell code for my imaginary tuck shop that sells only Twistys, Grain Waves, and Shapes:
data Snack
= Twistys TwistysFlavour
| GrainWaves GrainWavesFlavour
| Shapes ShapesFlavour
data TwistysFlavour
= Cheese
| Chicken
data GrainWavesFlavour
= Original
| SweetChilli
| SourCreamAndChives
data ShapesFlavour
= Barbecue
| ChickenCrimpy
| Pizza
More specifically


Price is dependant on lot size and amount of leaves it may have
We Usually Charge 40 dollars to rake the front and back yard of an average size lot
If you wish to use compostable bags they will cost 3 dollars per bag used
We can use plastic bags for no extra charge
During Earth Day we will use compostable bags for no extra cost!
Again prices are to be negotiated and are dependant on lot size


This example shows the use of the click handler.
The click handler can be used to gain more flexibility over handling click events. The handler can be constructed with options to handle only single click events, to handle single and double-click events, to ignore clicks that include a drag, and to stop propagation of single and/or double-click events. A single click is a click that is not followed by another click for more than 300ms. This delay is configured with the delay property.
The options to stop single and double clicks have to do with stopping event propagation on the map events listener queue (not stopping events from cascading to other elements). The ability to stop an event from propagating has to do with the order in which listeners are registered. With stopSingle or stopDouble true, a click handler will stop propagation to all listeners that were registered (or all handlers that were activated) before the click handler was activated. So, for example, activating a click handler with stopDouble true after the navigation control is active will stop double-clicks from zooming in.
| single only | ||
| double only | ||
| both | ||
| single with drag | ||
| single with stop | ||
| double with stop |


SKILL(1) User Commands SKILL(1) NAME skill, snice - send a signal or report process status SYNOPSIS skill [signal] [options] expression snice [new priority] [options] expression DESCRIPTION These tools are obsolete and unportable. The command syntax is poorly defined. Consider using the killall, pkill, and pgrep commands instead. The default signal for skill is TERM. Use -l or -L to list available signals. Particularly useful signals include HUP, INT, KILL, STOP, CONT, and 0. Alternate signals may be specified in three ways: -9 -SIGKILL -KILL. The default priority for snice is +4. Priority numbers range from +20 (slowest) to -20 (fastest). Negative priority numbers are restricted to administrative users. OPTIONS -f, --fast Fast mode. This option has not been implemented. -i, --interactive Interactive use. You will be asked to approve each action. -l, --list List all signal names. -L, --table List all signal names in a nice table. -n, --no-action No action; perform a simulation of events that would occur but do not actually change the system. -v, --verbose Verbose; explain what is being done. -w, --warnings Enable warnings. This option has not been implemented. -h, --help Display help text and exit. -V, --version Display version information. PROCESS SELECTION OPTIONS Selection criteria can be: terminal, user, pid, command. The options below may be used to ensure correct interpretation. -t, --tty tty The next expression is a terminal (tty or pty). -u, --user user The next expression is a username. -p, --pid pid The next expression is a process ID number. -c, --command command The next expression is a command name. SIGNALS The behavior of signals is explained in signal(7) manual page.  SEE ALSO kill(1), kill(2), killall(1), nice(1), pkill(1), renice(1), signal(7) STANDARDS No standards apply. AUTHOR Albert Cahalan<EMAIL_ADDRESS>wrote skill and snice in 1999 as a replacement for a non-free version. REPORTING BUGS Please send bug reports to<EMAIL_ADDRESS>procps-ng October 2011 SKILL(1)


This package contains value objects for BlockingCache and classes which extend it.
Implicit is the understanding that these may be serialized. All value objects should implement
Serializable


browse other examples
Scroller inside the directive
This sample demonstrates encapsulation of the ui-scroll directive inside another custom directive wich has it's own controller and wich uses "Controller As" syntax in it's template.


Description
This command is used for program comments. Comments are not discarded in the @x:Act parser, but instead are kept in the parse tree but have no effect on execution.
Command Syntax
All attributes, options and body are ignored.
Execution Semantics
The result of executing a @x:comment command is null.
Examples
@x:comment "this is a comment";
// This is a sugared form of x:comment command
/* This is another
sugared form of the x:comment command
*/
@x:comment "heres how to comment out code" {
@x:if x == null {
x := y
}
}


|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A Loader represents a Java ClassLoader implementation that can be used by a Container to load class files (within a repository associated with the Loader) that are designed to be reloaded upon request, as well as a mechanism to detect whether changes have occurred in the underlying repository.
In order for a Loader
implementation to successfully operate
with a Context
implementation that implements reloading, it
must obey the following constraints:
Lifecycle
so that the Context can indicate
that a new class loader is required.
start()
method must unconditionally create a new
ClassLoader
implementation.
stop()
method must throw away its reference to the
ClassLoader
previously utilized, so that the class loader,
all classes loaded by it, and all objects of those classes, can be
garbage collected.
stop()
to be followed by a call to
start()
on the same Loader
instance.
Context.reload()
method on the owning Context
when a change to one or more of the class files loaded by this class
loader is detected.
| Method Summary | |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Add a property change listener to this component. |
void |
addRepository(java.lang.String repository)
Add a new repository to the set of repositories for this class loader. |
java.lang.String[] |
findRepositories()
Return the set of repositories defined for this class loader. |
java.lang.ClassLoader |
getClassLoader()
Return the Java class loader to be used by this Container. |
Container |
getContainer()
Return the Container with which this Loader has been associated. |
boolean |
getDelegate()
Return the "follow standard delegation model" flag used to configure our ClassLoader. |
java.lang.String |
getInfo()
Return descriptive information about this Loader implementation and the corresponding version number, in the format <description>/<version> . |
boolean |
getReloadable()
Return the reloadable flag for this Loader. |
boolean |
modified()
Has the internal repository associated with this Loader been modified, such that the loaded classes should be reloaded? |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Remove a property change listener from this component. |
void |
setContainer(Container container)
Set the Container with which this Loader has been associated. |
void |
setDelegate(boolean delegate)
Set the "follow standard delegation model" flag used to configure our ClassLoader. |
void |
setReloadable(boolean reloadable)
Set the reloadable flag for this Loader. |
| Method Detail |
public java.lang.ClassLoader getClassLoader()
public Container getContainer()
public void setContainer(Container container)
container
- The associated Containerpublic boolean getDelegate()
public void setDelegate(boolean delegate)
delegate
- The new flagpublic java.lang.String getInfo()
<description>/<version>
.
public boolean getReloadable()
public void setReloadable(boolean reloadable)
reloadable
- The new reloadable flagpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener to addpublic void addRepository(java.lang.String repository)
repository
- Repository to be addedpublic java.lang.String[] findRepositories()
public boolean modified()
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
listener
- The listener to remove
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


Miriam Margolyes: Labour saving NHS more important than anti-Semitism
Miriam Margolyes believes Labour backing the NHS is more important than anti-Semitism.
The actress, who has been a critic of anti-Jewish prejudice in the party and politics more broadly, has said Jeremy Corbyn is a “man of principle”.
She supports the Labour leader over the Tory Prime Minister Boris Johnson, and believes protecting the NHS is more important than Brexit.
Margolyes spoke at the launch of the latest series of BBC show Call The Midwife.
She said: “No party is perfect, but Corbyn is a man of principle.
“But Boris Johnson again and again and again has shown that he is not.
“I don’t want the England that Boris Johnson wants, I don’t want that. I want, maybe not the England that Corbyn wants.
“Maybe I am not as doctrinaire as he is, but he is going to protect the NHS and that is the one thing that I hold more important than any other thing, more important than Brexit more than anti-Semitism.”
Margolyes said that anti-Semitism was not limited to the Labour Party, and was evident elsewhere in British politics. She said the Tory party had its own demons, and should look at the issue of Islamophobia.
She added: “I think anti-Semitism is throughout the English political system, I don’t think Labour have a monopoly on anti-Semitism.”
Call The Midwife will return with a Christmas special.


{include file="layout/head" /}
系统公告
{foreach $list as $c}
{$c->title}
{$c->create_time}
{/foreach}
{include file="layout/footer" /}


|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |
| Interface Summary | |
|---|---|
| AView<AModel> | All Views implement this interface. |
| Class Summary | |
|---|---|
| AModel<V extends AView> | This is a generic Model class. |
| BitmapJsonConverter | Provides custom base64 serialization / deserialization for Bitmaps. |
| BrowseActivity | BrowseActivity is responsible for mainly handling the load of the comments. |
| BrowseView | BrowswView is responsible for loading the view of the comments. |
| BrowseView.Holder | Basic holder for the BrowseView containing comment parameteres. |
| Cache | Cache is what is responsible for saving and loading data to and from the user's device. |
| CacheIO | |
| CommentController | The CommentController class is what helps distinguish between a new reply or a new top level comment. |
| CommentListModel | CommentListModel holds the sorting data and the functions to add a comment within the list. |
| CommentManager | |
| CommentModel | CommentModel is the actual model for each and every comment. |
| CommentPull | |
| CommentPush | |
| CommentRetriever | |
| CommentSearch | CommentSearch is used with respect to ElasticSearch and is called upon to help in matching string queries to/from the server for sorting. |
| CommentSort | |
| CreateCommentActivity | Called when a user hits the '+' button at the top of any screen that has one. |
| EditCommentActivity | EditCommentActivity is called when a user is in the "My Comments" activity and selects that he/she wishes to edit a comment by clicking on it. |
| EditMyProfileActivity | |
| ElasticSearchResponse<T> | The ElasticSearchResponse helps in getting the correct source data for each comment. |
| ElasticSearchSearchResponse<T> | Responsible for getting the hits to a reference to a comment and gets the source of each comment from the CommentListController. |
| GeoTopicsApplication | This is a collection of singletons. |
| HelpActivity | |
| Hits<T> | Hits returns the score and hits from an ElasticSearch response. |
| InspectCommentActivity | This source file holds the methods for the CreateCommentActivity as well as the EditCommentActivity. |
| InspectOtherProfilesActivity | |
| InspectProfileActivity | |
| ManualLocationActivity | This class file is loaded if the user is not running Google API and thus cannot pick a location on the map. |
| MapsActivity | This file is activated once the user selects that he/she wishes to manually set a location. |
| MyBookmarksActivity | |
| MyCommentsActivity | Shown when a user clicks on "My Comments" from the start screen of the application In this activity, the user will be shown all of his/her comments including both top-level and reply comments. |
| MyFavouritesActivity | |
| ProfilePush | |
| ProfileSearch | |
| ReplyLevelActivity | The view you see when you go to view the replies once you click a top level comment and click a reply. |
| StartActivity | Contains data for the start screen of the application. |
| TopLevelActivity | The view you see when you go to "Browse" from the start screen. |
| User | Holds all the data that the individual user whom is using the application creates/modifies. |
| UserController | |
| UserIO | |
| UserLocationServices |
|
||||||||||
| PREV PACKAGE NEXT PACKAGE | FRAMES NO FRAMES |


|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TxnDouble
A Transactional Reference comparable to the Clojure Ref.
If a method is prefixed with atomic, the call will always run under its own txn, no
matter if there already is a txn available (so the propagation level is PropagationLevel.RequiresNew
).
For the other methods, always an txn needs to be available, else you will get the
TxnMandatoryException
.
All non atomic methods are able to throw a (subclass) of the ControlFlowError
. This error should
not be caught, it is task of the TxnExecutor
to deal with.
Most of the methods can throw a TxnExecutionException
.
This exception can be caught, but in most cases you want to figure out what the cause is (e.g. because
there are too many retries) and solve that problem.
All methods are threadsafe.
| Method Summary | |
|---|---|
double |
alterAndGet(DoubleFunction function)
Alters the value stored in this Ref using the provided function and returns the result. |
double |
alterAndGet(Txn txn,
DoubleFunction function)
Alters the value stored in this Ref using the provided function and lifting on the provided txn. |
double |
atomicAlterAndGet(DoubleFunction function)
Atomically applies the function to the current value in this ref and returns the new value. |
boolean |
atomicCompareAndSet(double expectedValue,
double newValue)
Executes a compare and set atomically. |
double |
atomicGet()
Atomically gets the value. |
double |
atomicGetAndAlter(DoubleFunction function)
Atomically applies the function to alter the value stored in this ref and returns the old value. |
double |
atomicGetAndIncrement(double amount)
Atomically increments the value and returns the old value. |
double |
atomicGetAndSet(double newValue)
Atomically sets the value and returns the previous value. |
double |
atomicIncrementAndGet(double amount)
Atomically increments the value and returns the old value. |
double |
atomicSet(double newValue)
Atomically sets the value and returns the new value. |
double |
atomicWeakGet()
Atomically gets the value without providing any ordering guarantees. |
void |
await(double value)
Awaits for the value to become the given value. |
void |
await(DoublePredicate predicate)
Awaits until the predicate holds. |
void |
await(Txn txn,
double value)
Awaits for the reference to become the given value. |
void |
await(Txn txn,
DoublePredicate predicate)
Awaits until the predicate holds using the provided txn. |
void |
commute(DoubleFunction function)
Applies the function on the ref in a commuting manner. |
void |
commute(Txn txn,
DoubleFunction function)
Applies the function on the ref in a commuting manner. |
double |
get()
Gets the value using the provided txn. |
double |
get(Txn txn)
Gets the value using the provided txn. |
double |
getAndAlter(DoubleFunction function)
Alters the value stored in this Ref using the provided function amd returns the old value. |
double |
getAndAlter(Txn txn,
DoubleFunction function)
Alters the value stored in this Ref using the function and returns the old value, using the provided txn. |
double |
getAndIncrement(double amount)
Increments the value and returns the old value. |
double |
getAndIncrement(Txn txn,
double amount)
Increments the value and returns the old value using the provided txn. |
double |
getAndLock(LockMode lockMode)
Gets the value and applies the lock. |
double |
getAndLock(Txn txn,
LockMode lockMode)
Gets the value using the provided txn and acquired the lock with the specified LockMode. |
double |
getAndSet(double value)
Sets the value the value and returns the new value. |
double |
getAndSet(Txn txn,
double value)
Sets the value using the provided txn. |
double |
getAndSetAndLock(double value,
LockMode lockMode)
Sets the value, acquired the Lock with the specified Lockmode and returns the previous value. |
double |
getAndSetAndLock(Txn txn,
double value,
LockMode lockMode)
Sets the value and acquired the Lock with the provided LockMode. |
double |
incrementAndGet(double amount)
Increments and gets the new value. |
double |
incrementAndGet(Txn txn,
double amount)
Increments and gets the new value using the provided txn. |
double |
set(double value)
Sets the new value. |
double |
set(Txn txn,
double value)
Sets the new value using the provided txn. |
double |
setAndLock(double value,
LockMode lockMode)
Sets the new value and applies the lock. |
double |
setAndLock(Txn txn,
double value,
LockMode lockMode)
Sets the new value using the provided txn. |
| Methods inherited from interface org.multiverse.api.TxnObject |
|---|
atomicToString, ensure, ensure, getLock, getStm, getVersion, toDebugString, toString, toString |
| Method Detail |
|---|
double get()
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.atomicGet()
double getAndLock(LockMode lockMode)
This call lifts on the Txn
stored in the TxnThreadLocal
.
lockMode
- the LockMode applied.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.atomicGet()
double get(Txn txn)
txn
- the Txn
used for this operation.
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndLock(Txn txn, LockMode lockMode)
txn
- the Txn
used for this operation.lockMode
- the LockMode used
NullPointerException
- if txn is null or if lockMode is null. If LockMode is null and a running txn is available
it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double set(double value)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the new value.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double setAndLock(double value, LockMode lockMode)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the new value.lockMode
- the used LockMode.
NullPointerException
- if lockMode is null (if the txn is alive, it will also be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double set(Txn txn, double value)
txn
- the Txn
used for this operation.value
- the new value
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double setAndLock(Txn txn, double value, LockMode lockMode)
txn
- the Txn
used for this operation.value
- the new valuelockMode
- the lockMode used.
NullPointerException
- if txn is null or lockMode is null. If the lockMode is null and the txn
is alive, it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndSet(double value)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the new value.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndSetAndLock(double value, LockMode lockMode)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the new value.lockMode
- the LockMode used.
NullPointerException
- if LockMode is null. If a running txn is available, it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndSet(Txn txn, double value)
value
- the new value.txn
- the Txn
used for this operation.
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndSetAndLock(Txn txn, double value, LockMode lockMode)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the new value.txn
- the Txn
used for this operation.lockMode
- the LockMode used.
NullPointerException
- if txn or LockMode is null. If the txn is running, and the LockMode is null,
it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double atomicGet()
atomicWeakGet()
.
TxnExecutionException
double atomicWeakGet()
It is the best method to call if you just want to get the current value stored.
double atomicSet(double newValue)
newValue
- the new value.
TxnExecutionException
double atomicGetAndSet(double newValue)
newValue
- the new value.
TxnExecutionException
void commute(DoubleFunction function)
This is different than the behavior in Clojure where the commute will be re-applied at the end of the txn, even though some dependency is introduced, which can lead to inconsistencies.
This call lifts on the Txn
stored in the TxnThreadLocal
.
function
- the function to apply to this reference.
NullPointerException
- if function is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.void commute(Txn txn, DoubleFunction function)
This is different than the behavior in Clojure where the commute will be re-applied at the end of the txn, even though some dependency is introduced, which can lead to inconsistencies.
This call lifts on the Txn
stored in the TxnThreadLocal
.
txn
- the Txn
used for this operation.function
- the function to apply to this reference.
NullPointerException
- if function is null. If there is an active txn, it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double atomicAlterAndGet(DoubleFunction function)
function
- the Function used
NullPointerException
- if function is null.double alterAndGet(DoubleFunction function)
This call lifts on the Txn
stored in the TxnThreadLocal
.
function
- the function that alters the value stored in this Ref.
NullPointerException
- if function is null. The Txn will also be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double alterAndGet(Txn txn, DoubleFunction function)
function
- the function that alters the value stored in this Ref.txn
- the Txn
used for this operation.
NullPointerException
- if function or txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double atomicGetAndAlter(DoubleFunction function)
function
- the Function used
NullPointerException
- if function is null.
TxnExecutionException
double getAndAlter(DoubleFunction function)
This call lifts on the Txn
stored in the TxnThreadLocal
.
function
- the function that alters the value stored in this Ref.
NullPointerException
- if function is null. The txn will be aborted as well.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndAlter(Txn txn, DoubleFunction function)
function
- the function that alters the value stored in this Ref.txn
- the Txn
used for this operation.
NullPointerException
- if function or txn is null. The txn will be aborted as well.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.boolean atomicCompareAndSet(double expectedValue, double newValue)
expectedValue
- the expected value.newValue
- the new value.
TxnExecutionException
double atomicGetAndIncrement(double amount)
amount
- the amount to increase with.
TxnExecutionException
double getAndIncrement(double amount)
This call lifts on the Txn
stored in the TxnThreadLocal
.
amount
- the amount to increment with.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double getAndIncrement(Txn txn, double amount)
txn
- the Txn
used for this operation.amount
- the amount to increment with.
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double atomicIncrementAndGet(double amount)
amount
- the amount to increment with.
TxnExecutionException
double incrementAndGet(double amount)
This call lifts on the Txn
stored in the TxnThreadLocal
.
amount
- the amount to increment with.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.double incrementAndGet(Txn txn, double amount)
txn
- the Txn
used for this operation.amount
- the amount to increment with.
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.void await(double value)
This call lifts on the Txn
stored in the TxnThreadLocal
.
value
- the value to wait for.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.void await(Txn txn, double value)
txn
- the Txn
used for this operation.value
- the value to wait for.
NullPointerException
- if txn is null.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.void await(DoublePredicate predicate)
This call lifts on the Txn
stored in the TxnThreadLocal
.
predicate
- the predicate to evaluate.
NullPointerException
- if predicate is null. When there is a non dead txn,
it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.void await(Txn txn, DoublePredicate predicate)
txn
- the Txn
used for this operation.predicate
- the predicate to evaluate.
NullPointerException
- if predicate is null or txn is null. When there is a non dead txn,
it will be aborted.
TxnExecutionException
- if something failed while using the txn. The txn is guaranteed to have been aborted.
ControlFlowError
- if the Stm needs to control the flow in a different way than normal returns of exceptions. The txn
is guaranteed to have been aborted.
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


AtoZ
Welcome to AtoZ! Have a skill or hobby your passionate about? Share it with others, and make money while doing it, all in the comfort of your own home.
Featured Experiences
Origami
Learn origami with Linda! A beginner class on origami where you will learn to make a crane.
Reserve a spot!Pottery
Learn advanced pottery techniques with Karen. A must for those seeking to improve their pottery.
Reserve a spot!Photography
For intermediate photographers. Learn the best ways to edit family pictures with a glass of wine.
Reserve a spot!


One of the many things about Swift that has made me happy is the introduction of default parameter values in methods. In Objective-C, it’s pretty common to see APIs that look a lot like the following code (taken from MagicalRecord):
// NSManagedObjectContext+MagicalFinders.h
+ (instancetype)findFirstInContext:(NSManagedObjectContext *)context;
+ (instancetype)findFirstWithPredicate:(NSPredicate *)searchTerm
inContext:(NSManagedObjectContext *)context;
+ (instancetype)findFirstWithPredicate:(NSPredicate *)searchterm
sortedBy:(NSString *)property
ascending:(BOOL)ascending
inContext:(NSManagedObjectContext *)context;
// NSManagedObjectContext+MagicalFinders.m
+ (instancetype)findFirstInContext:(NSManagedObjectContext *)context
{
return [self findFirstWithPredicate:nil
sortedBy:nil
inContext:context];
}
+ (instancetype)findFirstWithPredicate:(NSPredicate *)searchTerm
inContext:(NSManagedObjectContext *)context
{
return [self findFirstWithPredicate:searchTerm
sortedBy:nil
ascending:YES
inContext:context];
}
+ (instancetype)findFirstWithPredicate:(NSPredicate *)searchterm
sortedBy:(NSString *)sortedBy
ascending:(BOOL)ascending
inContext:(NSManagedObjectContext *)context
{
// Actual implementation of method
}
This pattern is often referred to as the “telescopic pattern”, or “telescoping methods”. Basically, you implement a number of methods that each call the next, more specific method in the chain, providing default values at each stage as they become necessary. Users of the API can choose to use any of the methods, allowing for more succinct code, but only requiring a single “real” method implementation.
In Swift, this functionality is built into the language (hooray!). As an example, given the following method in Swift:
func findFirstWithPredicate(predicate:NSPredicate? = nil,
sortedBy:String? = nil,
ascending:Bool = true,
inContext context:NSManagedObjectContext) -> [NSManagedObject] {
// Actual implementation of method
}
Users of this Swift API can choose not to include any parameters that have default values, ie:
let results = findFirstWithPredicate(inContext:myContext);
// OR
let otherResults = findFirstWithPredicate(sortedBy:"someProperty",
inContext:myContext);
// OR
let moreResults = findFirstWithPredicate(sortedBy:"someProperty",
ascending:false,
inContext:myContext);
// You get the gist of it!
This allows for more succinct methods calls, without the mountain of boilerplate we would have had to write in Objective-C!


Welcome to politician-profiler documentation!¶
Twitter API¶
Module for working with Twitter API.
- class modules.twitter.Twitter¶
Class for working with Twitter API.
- get_bearer_token()¶
Get bearer token from environment variable.
- get_latest_tweets(screen_name, number=5)¶
Get latest tweets of user.
- search_user(screen_name)¶
Get user by nickname.
- modules.twitter.get_twitter_id(politician_name)¶
Returns politician`s Twitter screen name or None if a politician does not have a Twitter sccount.
Trends ADT¶
Module for working with Google Trends.
- class modules.trends.Trends(keywords)¶
Wrapper class for pytrends library.
- interest_by_region(resolution='COUNTRY', inc_low_vol=False)¶
Get interest by region.
- interest_over_time()¶
Get interest overt time.
Get related search querries.
Get related topics.
- suggestions(keyword)¶
Get suggestions for keyword.
- top_charts(date, hl='uk', tz=360, geo='GLOBAL')¶
Get top charts by date.
- trending_searches(pn='ukraine')¶
Get trending searhes by country.
Declaration ADT¶
Module for working with the state register of declarations
- class modules.declaration.Declaration(name)¶
Class for working with declarations.
- get_declaration()¶
Get latest yearly income declaration.
- get_declaration_details()¶
Get detailed yearly income declaration.
- get_declaration_link()¶
Get link to declaration.
- get_salary()¶
Get total income from declaration.
Database¶
Module for checking politicians for corruption.
- modules.check_database.check_all_politicians(name: str)¶
Check if person is a politician.
- modules.check_database.check_knopkodavu(name: str)¶
Check if politician is a button masher.
- modules.check_database.check_politician(name: str)¶
Check politician for all three points.
- modules.check_database.check_progulshiki(name: str)¶
Check if politician skips meetings.
- modules.check_database.check_vorishki(name: str)¶
Check if politician has been involved in corruption schemes.
Wiki ADT¶
Module with WikiADT class for extracting politician`s image and description.
- class modules.wiki.WikiADT(politician_name)¶
A class for storing Wiki information about a politician.
Article ADT¶
Abstract data type for representing an article.
- class modules.article.ArticleADT(politician_name)¶
A class for representing a news article.


***********************************************************
Hey Pretty, You’re Invited!
Join Aerie’s Twitter Chat
With Bright Pink’s CEO And Founder, Lindsay Avner
Using
On Tuesday, October 1st From 2-3 PM.
See You There!
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link25a?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
Follow Us On Twitter
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link25c?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link25f?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
brightPink.org
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link21?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
***********************************************************
New!  Bra will be available for purchase starting September 18, 2013 in
stores and at aerie.com. While supplies last. Learn more at
aerie.com/brightpink
© 2013 AEO MANAGEMENT CO. ALL RIGHTS RESERVED.
***********************************************************
Update Your Email Address:
<EMAIL_ADDRESS>Sign Up For Email:
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link15?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
Privacy Policy:
http://e.ae.com/a/tBSSWfHB7u3j4B81dTPNuZn6SVk/link13?AAP_FLAG=N&CUSTOMER_NBR=1235023277209
Add<EMAIL_ADDRESS>to your address book.
Our mailing address: 77 Hot Metal Street, Pittsburgh, PA 15203


I'm Ruth
UX, Design, Front End Dev for The Lab
@rumyra
CSS Animations
Web Audio API (+ others)
Can we recreate the visuals?
Moving visual - CSS animations
Analysed sound wave - Web Audio API
Control volume
//Control volume
myAudioContext.createGain();
Create filters
//Create filter
myAudioContext.createBiquadFilter();
Create sound
//Create sound
myAudioContext.createOscillator();
Analyse sound
//Analyse sound
myAudioContext.createAnalyser();
The Web Audio API O'Reilly book by Boris Smus is free to read online!
Loop through our lights, match them to a frequency and set them alight
//get light elements var lights = document.getElementsByTagName('i'); var totalLights = lights.length; for (var i=0; i160){ lights[i].style.opacity = "1"; } else { lights[i].style.opacity = "0.2"; } }
GetUserMedia
Picks up on devices camera and microphone
Android / Firefox OS
Latest Chrome or Firefox browser
Web Audio
getUserMedia
Geolocation
Web RTC
Game Pad API
Vibration API
Ambient Light API
Proximity API
Screen Orientation API
Device Orientation API
Web Speech API
Voice
Gamepad
Device Orientation
Please use Chrome :)
Web API's based on native functionality
Audio API - visuals
getUserMedia - audio line in
Vibration API - beat detection
Consider other uses
Support? (caniuse.com)


New cars for 2020: Hatchbacks to wait for
by Akbar MerchantWe've compiled a list of all upcoming hatchbacks that are set to launch next year.
Hyundai i20
The popular i20 will see a full model change in 2020. Spy shots confirm the car will be more of an evolution of its predecessor. It will get Hyundai’s new cascading grille, with an array of LED lights at the front and at the back. The new i20’s headlamps merge with the grille, giving it a look similar to that of the recently launched Elantra facelift. On the inside, expect the new car to come with more tech and features, with top variants getting a sunroof. Hyundai will also include its new Blue Link connected car tech in the next-gen i20 hatchback. Under the hood, it will come with a BS6-compliant, 1.5-litre diesel and a 1.2-litre petrol engine. Hyundai will also include the 1.0-litre turbo GDI petrol engine on the i20 that made its debut on the Venue compact SUV in India.
Coming: Mid-2020
Engines: 1.2P, 1.0P, 1.5D
Price: From Rs 5.5 lakh
Maruti Suzuki Celerio
Image used for representational purpose only.
The current-gen Celerio has been on sale since 2014 and has been a steady seller for Maruti in India. The new Celerio (codename: Y1B) will be launched in the second half of 2020. Like all other newer Marutis, including the S-Presso, it will use the lighter yet stiffer Heartect platform. Maruti will offer the new Celerio with the 1.0-litre, BS6-compliant petrol engine and a CNG option.
Coming: End 2020
Engines: 1.0P
Price: From RS 4.2 lakh
Maruti Suzuki Ignis Facelift
Image used for representational purpose only.
The Ignis will get a mid-cycle update next year. The refreshed model will get styling tweaks up
front and a refreshed interior as well. It will also get the BS6-compliant, 1.2-litre petrol engine, mated to either a 5-speed manual or an AMT. The new SmartPlay Studio infotainment will also be included in the updated Ignis, which will make it more competitive.
Coming: Mid-2020
Engines: 1.2P
Price: From Rs 4.8 lakh
Tata Tiago facelift
Image used for representational purpose only.
The Tiago is sure to benefit from the major styling tweaks and the new features. The update will give the Tiago an angular nose, similar to the Altroz. The facelift will comply with crash-test and pedestrian safety norms. Tata, however, will drop the 1.0-litre diesel, which means only the 1.2-litre petrol mated to either a 5-speed manual or an AMT will be on offer.
Coming: Early 2020
Engines: 1.2P
Price: From Rs 4.3 lakh
Tata Altroz
The Altroz will mark Tata’s entry into the premium hatchback segment in India – one that includes the likes of the Hyundai i20 and the Maruti Baleno. The Tata Altroz is expected to come with three engine options – the 85hp, 1.2-litre, naturally aspirated, three-cylinder motor from the Tiago; a 102hp, 1.2-litre three-cylinder turbo-petrol that’s shared with the Nexon and Tiago JTP; and a 90hp version of the Nexon’s 1.5-litre, four-cylinder, turbo-diesel motor. It was expected to arrive late 2019, and there were talks of it launching with BS4-compliant engines, followed by BS6 units later. This plan, however, was scrapped and Tata did a rethink as planning in the first phase would have been complicated. We can now confirm that Tata Motors has pushed the launch to early 2020, in order to equip the Altroz with BS6-compliant engines.
Coming: Early 2020
Engines: 1.2P, 1.2P, 1.5D
Price: From Rs 5.3 lakh


Our development department is pleased with the results of Task 2.1.4 Integrate Windows Hello Authentication that prototyped using Windows Hello to log into the Knowzy app if the user was using the Desktop Bridge version of Knowzy. We now want you to attempt a more complete implementation.
This task has a dependency on Task 2.1.4 and all of it's prerequisites
Implement a complete solution for Windows Hello.
Implement a local Windows Hello Server
Update Xaml UI as needed.
Our research has found a starting point for Windows Hello here
We also found sample code for Windows Hello here


Asymptote is a powerful descriptive vector graphics language that provides a natural coordinate-based framework for technical drawing. Labels and equations can be typeset with LaTeX. As well as EPS, PDF and PNG output it can produce WebGL 3D HTML rendering and (using dvisvgm) SVG output.
This package is known to build and work properly using an LFS-9.1 platform.
Download (HTTP): https://downloads.sourceforge.net/asymptote/asymptote-2.62.src.tgz
Download MD5 sum: 5ed8f48990d889af0040b057ca5c62e8
Download size: 4.5 MB
Estimated disk space required: 197 MB (with all the dependencies which are within BLFS)
Estimated build time: 2.5 SBU
ghostscript-9.50 and texlive-20190410
Freeglut-3.2.1, GC-8.0.4, GLEW-2.1.0, GLM-<IP_ADDRESS> and libtirpc-1.2.5
fftw-3.3.8, Gsl-2.6, libsigsegv-2.12
PyQt5 (not tested), which has a build dependency of Qt-5.14.1
User Notes: http://wiki.linuxfromscratch.org/blfs/wiki/asymptote
Install asymptote by running the following commands:
export TEXARCH=$(uname -m | sed -e 's/i.86/i386/' -e 's/$/-linux/') && ./configure --prefix=/opt/texlive/2019 \ --bindir=/opt/texlive/2019/bin/$TEXARCH \ --datarootdir=/opt/texlive/2019/texmf-dist \ --infodir=/opt/texlive/2019/texmf-dist/doc/info \ --libdir=/opt/texlive/2019/texmf-dist \ --mandir=/opt/texlive/2019/texmf-dist/doc/man \ --enable-gc=system \ --with-latex=/opt/texlive/2019/texmf-dist/tex/latex \ --with-context=/opt/texlive/2019/texmf-dist/tex/context/third && make
To test the results, issue: make check.
Now, as the root
user:
make install
--prefix=, --bindir=, --datarootdir=,
--infodir=, --mandir= ...
: these switches ensure that
the files installed from source will overwrite any corresponding
files previously installed by install-tl-unx so that the alternative methods
of installing texlive are
consistent.
--libdir=/opt/texlive/2019/texmf-dist;
:
This parameter ensures that the asymptote
directory will similarly overwrite any
files installed by install-tl-unx.
--enable-gc=system
: this
ensures that the system version of libgc.so
will be used instead of the version
shipped with this package.
--with-latex= ...
--with-context=
: These switches ensure that style files
and a tex file will be installed into the texlive directories instead of creating a
texmf-local
directory for them.
Last updated on 2020-02-22 14:08:54 -0800


Help Charlie find his spellbook in the dark
Mouse: Use to aim and left or right click to shoot
Keyboard: W A S D to move up, left, down, or right respectively
Press ESCAPE at any time to regain control of the mouse
Get to the bottom of the cavern without dying
Try to rack up a high score
5 hits, and it's game over!
Charlie the Wizard dropped his spell book down Spider and Bat Caverns. Help him retrieve it using the only spell he knows off hand: magic missile. Join him and his hat on this deep dive into adventure!
Made by Gregory Goldshteyn, April 2021


{# here we iterate over every item in our list which we will pass from bar() #} {% for item in my_list %}
{{ item }}
{% endfor %}


front-end dev
Strive to be accessible to everyone - Mental or physical impairments should not stop anyone from enoying the world wide web
Responsive design makes sure you can enjoy my layout on any device
Lightweight & fast loading - Because time is money, friend
.NET & Web developer based out of Strängnäs
Front-end developer residing in Sweden with a serious passion for gaming, programming and music. Striving to make the web more intuitive, dynamic and user-friendly.
Huge Supernatural geek. Like my coffee black and tea bitter. Listen to everything from heavy metal to EDM. Christmas songs in the summer, don't judge me.
Mainly work with HTML/CSS/JS, .NET, React
A selection of my personal projects


RUN LOLA RUN (1998) also called LOLA RENNT (German with subtitles in English)
Rating: 3 stars (out of 4.0) ******************************** Key to rating system: 2.0 stars - Debatable 2.5 stars - Some people may like it 3.0 stars - I liked it 3.5 stars - I am biased in favor of the movie 4.0 stars - I felt the movie's impact personally or it stood out ********************************* A Movie Review by David Sunga
Directed by: Tom Tykwer
Written by: Tom Tykwer
Starring: Franka Potente, Moritz Bleibtreu and Herbert Knaup
Synopsis: In a phone call Lola (Franka Potente) learns that her boyfriend Manni (Moritz Bleibtreu) will be killed by a drug dealer unless she and Manni cough up 100,000 deutschemarks in the next 20 minutes. This sends Lola on a frantic dash for cash to the accompaniment of mod music and scenes of a lot of running (hence the title RUN LOLA RUN).
Opinion: Remember the film GROUNDHOG DAY where Bill Murray played Phil, the sarcastic weatherman who got to redo the day several times until he finally performed the day the magical way it was fated to happen? Same deal here, only instead of Phil the sarcastic weatherman we get the MTV treatment. We cheer for Lola the cute, hyperkinetic, screaming punker girl with army boots, tatoos, and color-dyed hair as she high tails it to Daddy's bank. Lola's got 20 minutes to succeed, the stakes are deadly, and she doesn't get as many chances as Phil did. It makes for a fun and quirky collage as small details happen right and left which change fate like shards in a kaleidoscope.
Reviewed by David Sunga July 26, 1999
Copyright © 1999 by David Sunga This review and others like it can be found at THE CRITIC ZOO: http://www.criticzoo.com email<EMAIL_ADDRESS>The review above was posted to the
rec.arts.movies.reviews newsgroup (de.rec.film.kritiken for German reviews).
The Internet Movie Database accepts no responsibility for the contents of the
review and has no editorial control. Unless stated otherwise, the copyright
belongs to the author.
Please direct comments/criticisms of the review to relevant newsgroups.
Broken URLs inthe reviews are the responsibility of the author.
The formatting of the review is likely to differ from the original due
to ASCII to HTML conversion.
Related links: index of all rec.arts.movies.reviews reviews


The Ultimate Python Seaborn Tutorial: Gotta Catch ‘Em All
In this step-by-step Seaborn tutorial, you’ll learn how to use one of Python’s most convenient libraries for data visualization.
For those who’ve tinkered with Matplotlib before, you may have wondered, “why does it take me 10 lines of code just to make a decent-looking histogram?”
Well, if you’re looking for a simpler way to plot attractive charts, then you’ll love Seaborn. We’ll walk you through everything you need to know to get started, and we’ll use a fun Pokémon dataset (which you can download below).
Introduction to Seaborn
Seaborn provides a high-level interface to Matplotlib, a powerful but sometimes unwieldy Python visualization library.
On Seaborn’s official website, they state:
If matplotlib “tries to make easy things easy and hard things possible”, seaborn tries to make a well-defined set of hard things easy too.
We’ve found this to be a pretty good summary of Seaborn’s strengths. In practice, the “well-defined set of hard things” includes:
- Using default themes that are aesthetically pleasing.
- Setting custom color palettes.
- Making attractive statistical plots.
- Easily and flexibly displaying distributions.
- Visualizing information from matrices and DataFrames.
Those last three points are why Seaborn is our tool of choice for Exploratory Analysis. It makes it very easy to “get to know” your data quickly and efficiently.
However, Seaborn is a complement, not a substitute, for Matplotlib. There are some tweaks that still require Matplotlib, and we’ll cover how to do that as well.
How to Learn Seaborn, the Self-Starter Way:
While Seaborn simplifies data visualization in Python, it still has many features. Therefore, the best way to learn Seaborn is to learn by doing.
- First, understand the basics and paradigms of the library.
- Each library approaches data visualization differently, so it’s important to understand how Seaborn “thinks about” the problem.
- Then, fire up a dataset for practice.
- Learning in context is the best way to master a new skill quickly.
- Finally, refer to galleries to spark ideas and documentation to customize your charts.
- Since you’ve already learned the library’s paradigms and had some hands-on practice, you’ll easily find what you need.
This process will give you intuition about what you can do with Seaborn, leaving documentation to serve as further guidance. This is the fastest way to go from zero to proficient.
A quick tip before we begin:
We tried to make this tutorial as streamlined as possible, which means we won’t go into too much detail for any one topic. It’s helpful to have the Seaborn documentation open beside you, in case you want to learn more about a feature.
Seaborn Tutorial Contents
Instead of just showing you how to make a bunch of plots, we’re going to walk through the most important paradigms of the Seaborn library. Along the way, we’ll illustrate each concept with examples.
Here are the steps we’ll cover in this tutorial:
- Installing Seaborn.
- Importing libraries and dataset.
- Seaborn’s plotting functions.
- Scatter Plot
- Customizing with Matplotlib.
- The role of Pandas.
- Box Plot
- Seaborn themes.
- Violin Plot
- Color palettes.
- Swarm Plot
- Overlaying plots.
- Putting it all together.
- Pokédex (mini-gallery).
- Heatmap
- Histogram
- Bar Plot
- Factor Plot
- Density Plot
- Joint Distribution Plot
Step 1: Installing Seaborn.
- Python 3
- Pandas
- Matplotlib
- Seaborn
- Jupyter Notebook (optional, but recommended)
We strongly recommend installing the Anaconda Distribution, which comes with all of those packages. Simply follow the instructions on that download page.
Once you have Anaconda installed, simply start Jupyter (either through the command line or the Navigator app) and open a new notebook
Step 2: Importing libraries and dataset.
Let’s start by importing Pandas, which is a great library for managing relational (i.e. table-format) datasets:
# disable warnings for lecture
import warnings
warnings.filterwarnings('ignore')
# Pandas for managing datasets
import pandas as pd
Next, we’ll import Matplotlib, which will help us customize our plots further.
- Tip: In Jupyter Notebook, you can also include
%matplotlib inline
to display your plots inside your notebook.
# Matplotlib for additional customization
from matplotlib import pyplot as plt
%matplotlib inline
Then, we’ll import the Seaborn library, which is the star of today’s show.
# Seaborn for plotting and styling
import seaborn as sns
Now we’re ready to import our dataset.
- Tip: we gave each of our imported libraries an alias. Later, we can invoke Pandas with
pd
, Matplotlib withplt
, and Seaborn withsns
.
Today, we’ll be using a cool Pokémon dataset (first generation). Here’s the free download:
Dataset for this tutorial.
Once you’ve downloaded the CSV file, you can import it with Pandas.
- Tip: The argument
index_col=0
simply means we’ll treat the first column of the dataset as the ID column.
# Read dataset
df = pd.read_csv('Pokemon.csv', index_col=0)
# Display first 5 observations
df.head()
| Name | Type 1 | Type 2 | Total | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | Stage | Legendary | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| # | ||||||||||||
| 1 | Bulbasaur | Grass | Poison | 318 | 45 | 49 | 49 | 65 | 65 | 45 | 1 | False |
| 2 | Ivysaur | Grass | Poison | 405 | 60 | 62 | 63 | 80 | 80 | 60 | 2 | False |
| 3 | Venusaur | Grass | Poison | 525 | 80 | 82 | 83 | 100 | 100 | 80 | 3 | False |
| 4 | Charmander | Fire | NaN | 309 | 39 | 52 | 43 | 60 | 50 | 65 | 1 | False |
| 5 | Charmeleon | Fire | NaN | 405 | 58 | 64 | 58 | 80 | 65 | 80 | 2 | False |
Step 3: Seaborn’s plotting functions.
One of Seaborn’s greatest strengths is its diversity of plotting functions. For instance, making a scatter plot is just one line of code using the lmplot()
function.
There are two ways you can do so.
- The first way (recommended) is to pass your DataFrame to the
data=
argument, while passing column names to the axes arguments,x=
andy=
. - The second way is to directly pass in Series of data to the axes arguments.
For example, let’s compare the Attack and Defense stats for our Pokémon:
# Recommended way
sns.lmplot(x='Attack', y='Defense', data=df)
<seaborn.axisgrid.FacetGrid at 0x11e0f2d68>
By the way, Seaborn doesn’t have a dedicated scatter plot function, which is why you see a diagonal line. We actually used Seaborn’s function for fitting and plotting a regression line.
Thankfully, each plotting function has several useful options that you can set. Here’s how we can tweak the lmplot()
:
- First, we’ll set
fit_reg=False
to remove the regression line, since we only want a scatter plot. - Then, we’ll set
hue='Stage'
to color our points by the Pokémon’s evolution stage. This hue argument is very useful because it allows you to express a third dimension of information using color.
# Scatterplot arguments
sns.lmplot(x='Attack', y='Defense', data=df,
fit_reg=False, # No regression line
hue='Stage') # Color by evolution stage
<seaborn.axisgrid.FacetGrid at 0x125183fd0>
# Scatterplot arguments
sns.lmplot(x='Attack', y='Defense', data=df,
fit_reg=False, # No regression line
hue='Type 1') # Color by evolution stage
<seaborn.axisgrid.FacetGrid at 0x12023ca58>
Looking better, but we can improve this scatter plot further. For example, all of our Pokémon have positive Attack and Defense values, yet our axes limits fall below zero.
Let’s see how we can fix that…
Step 4: Customizing with Matplotlib.
Remember, Seaborn is a high-level interface to Matplotlib. From our experience, Seaborn will get you most of the way there, but you’ll sometimes need to bring in Matplotlib.
Setting your axes limits is one of those times, but the process is pretty simple:
- First, invoke your Seaborn plotting function as normal.
- Then, invoke Matplotlib’s customization functions. In this case, we’ll use its
ylim()
andxlim()
functions.
Here’s our new scatter plot with sensible axes limits:
# Plot using Seaborn
sns.lmplot(x='Attack', y='Defense', data=df,
fit_reg=False,
hue='Stage')
# Tweak using Matplotlib
plt.ylim(0, None)
plt.xlim(0, None)
(0,<PHONE_NUMBER>001028)
Step 5: The role of Pandas.
Even though this is a Seaborn tutorial, Pandas actually plays a very important role. You see, Seaborn’s plotting functions benefit from a base DataFrame that’s reasonably formatted.
For example, let’s say we wanted to make a box plot for our Pokémon’s combat stats:
plt.figure(figsize = (8, 8))
# Boxplot
sns.boxplot(data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x120c257f0>
Well, that’s a reasonable start, but there are some columns we’d probably like to remove:
- We can remove the Total since we have individual stats.
- We can remove the Stage and Legendary columns because they aren’t combat stats.
In turns out that this isn’t easy to do within Seaborn alone. Instead, it’s much simpler to pre-format your DataFrame.
Let’s create a new DataFrame called stats_df
that only keeps the stats columns:
plt.figure(figsize = (8, 8))
# Pre-format DataFrame
stats_df = df.drop(['Total', 'Stage', 'Legendary'], axis=1)
# New boxplot using stats_df
sns.boxplot(data=stats_df)
<matplotlib.axes._subplots.AxesSubplot at 0x1093ec128>
Step 6: Seaborn themes.
Another advantage of Seaborn is that it comes with decent style themes right out of the box. The default theme is called ‘darkgrid’.
Next, we’ll change the theme to ‘whitegrid’ while making a violin plot.
- Violin plots are useful alternatives to box plots.
- They show the distribution (through the thickness of the violin) instead of only the summary statistics.
For example, we can visualize the distribution of Attack by Pokémon’s primary type:
plt.figure(figsize = (12, 12))
# Set theme
sns.set_style('whitegrid')
# Violin plot
sns.violinplot(x='Type 1', y='Attack', data=df)
<matplotlib.axes._subplots.AxesSubplot at 0x1212f76d8>
As you can see, Dragon types tend to have higher Attack stats than Ghost types, but they also have greater variance.
Now, Pokémon fans might find something quite jarring about that plot: The colors are nonsensical. Why is the Grass type colored pink or the Water type colored orange? We must fix this!
Step 7: Color palettes.
Fortunately, Seaborn allows us to set custom color palettes. We can simply create an ordered Python list of color hex values.
Let’s use Bulbapedia to help us create a new color palette:
pkmn_type_colors = ['#78C850', # Grass
'#F08030', # Fire
'#6890F0', # Water
'#A8B820', # Bug
'#A8A878', # Normal
'#A040A0', # Poison
'#F8D030', # Electric
'#E0C068', # Ground
'#EE99AC', # Fairy
'#C03028', # Fighting
'#F85888', # Psychic
'#B8A038', # Rock
'#705898', # Ghost
'#98D8D8', # Ice
'#7038F8', # Dragon
]
Wonderful. Now we can simply use the palette=
argument to recolor our chart.
plt.figure(figsize = (10, 10))
# Violin plot with Pokemon color palette
sns.violinplot(x='Type 1', y='Attack', data=df,
palette=pkmn_type_colors) # Set color palette
<matplotlib.axes._subplots.AxesSubplot at 0x121a6c048>
Much better!
Violin plots are great for visualizing distributions. However, since we only have 151 Pokémon in our dataset, we may want to simply display each point.
That’s where the swarm plot comes in. This visualization will show each point, while “stacking” those with similar values:
plt.figure(figsize = (10, 10))
# Swarm plot with Pokemon color palette
sns.swarmplot(x='Type 1', y='Attack', data=df,
palette=pkmn_type_colors)
<matplotlib.axes._subplots.AxesSubplot at 0x121a5bd68>
That’s handy, but can’t we combine our swarm plot and the violin plot? After all, they display similar information, right?
Step 8: Overlaying plots.
The answer is yes.
It’s pretty straightforward to overlay plots using Seaborn, and it works the same way as with Matplotlib. Here’s what we’ll do:
- First, we’ll make our figure larger using Matplotlib.
- Then, we’ll plot the violin plot. However, we’ll set
inner=None
to remove the bars inside the violins. - Next, we’ll plot the swarm plot. This time, we’ll make the points black so they pop out more.
- Finally, we’ll set a title using Matplotlib.
# Set figure size with matplotlib
plt.figure(figsize=(10,6))
# Create plot
sns.violinplot(x='Type 1',
y='Attack',
data=df,
inner=None, # Remove the bars inside the violins
palette=pkmn_type_colors)
sns.swarmplot(x='Type 1',
y='Attack',
data=df,
color='k', # Make points black
alpha=0.7) # and slightly transparent
# Set title with matplotlib
plt.title('Attack by Type')
Text(0.5,1,'Attack by Type')
Awesome, now we have a pretty chart that tells us how Attack values are distributed across different Pokémon types. But what it we want to see all of the other stats as well?
Step 9: Putting it all together.
Well, we could certainly repeat that chart for each stat. But we can also combine the information into one chart… we just have to do some data wrangling with Pandas beforehand.
First, here’s a reminder of our data format:
stats_df.head()
| Name | Type 1 | Type 2 | HP | Attack | Defense | Sp. Atk | Sp. Def | Speed | |
|---|---|---|---|---|---|---|---|---|---|
| # | |||||||||
| 1 | Bulbasaur | Grass | Poison | 45 | 49 | 49 | 65 | 65 | 45 |
| 2 | Ivysaur | Grass | Poison | 60 | 62 | 63 | 80 | 80 | 60 |
| 3 | Venusaur | Grass | Poison | 80 | 82 | 83 | 100 | 100 | 80 |
| 4 | Charmander | Fire | NaN | 39 | 52 | 43 | 60 | 50 | 65 |
| 5 | Charmeleon | Fire | NaN | 58 | 64 | 58 | 80 | 65 | 80 |
As you can see, all of our stats are in separate columns. Instead, we want to “melt” them into one column.
To do so, we’ll use Pandas’s melt()
function. It takes 3 arguments:
- First, the DataFrame to melt.
- Second, ID variables to keep (Pandas will melt all of the other ones).
- Finally, a name for the new, melted variable.
Here’s the output:
# Melt DataFrame
melted_df = pd.melt(stats_df,
id_vars=["Name", "Type 1", "Type 2"], # Variables to keep
var_name="Stat") # Name of melted variable
melted_df.sort_values('Name').head(10)
| Name | Type 1 | Type 2 | Stat | value | |
|---|---|---|---|---|---|
| 364 | Abra | Psychic | NaN | Defense | 15 |
| 213 | Abra | Psychic | NaN | Attack | 20 |
| 817 | Abra | Psychic | NaN | Speed | 90 |
| 666 | Abra | Psychic | NaN | Sp. Def | 55 |
| 515 | Abra | Psychic | NaN | Sp. Atk | 105 |
| 62 | Abra | Psychic | NaN | HP | 25 |
| 443 | Aerodactyl | Rock | Flying | Defense | 65 |
| 594 | Aerodactyl | Rock | Flying | Sp. Atk | 60 |
| 745 | Aerodactyl | Rock | Flying | Sp. Def | 75 |
| 292 | Aerodactyl | Rock | Flying | Attack | 105 |
All 6 of the stat columns have been “melted” into one, and the new Stat column indicates the original stat (HP, Attack, Defense, Sp. Attack, Sp. Defense, or Speed). For example, it’s hard to see here, but Bulbasaur now has 6 rows of data.
In fact, if you print the shape of these two DataFrames…
print( stats_df.shape )
print( melted_df.shape )
(151, 9)
(906, 5)
…you’ll find that melted_df
has 6 times the number of rows as stats_df
.
Now we can make a swarm plot with melted_df
.
- But this time, we’re going to set
x='Stat'
andy='value'
so our swarms are separated by stat. - Then, we’ll set
hue='Type 1'
to color our points by the Pokémon type.
plt.figure(figsize=(14,10))
# Swarmplot with melted_df
sns.swarmplot(x='Stat', y='value', data=melted_df,
hue='Type 1')
<matplotlib.axes._subplots.AxesSubplot at 0x121f24390>
Finally, let’s make a few final tweaks for a more readable chart:
- Enlarge the plot.
- Separate points by hue using the argument
split=True
. - Use our custom Pokemon color palette.
- Adjust the y-axis limits to end at 0.
- Place the legend to the right.
# 1. Enlarge the plot
plt.figure(figsize=(14,10))
sns.swarmplot(x='Stat',
y='value',
data=melted_df,
hue='Type 1',
split=True, # 2. Separate points by hue
palette=pkmn_type_colors) # 3. Use Pokemon palette
# 4. Adjust the y-axis
plt.ylim(0, 260)
# 5. Place legend to the right
plt.legend(bbox_to_anchor=(1, 1), loc=2)
<matplotlib.legend.Legend at 0x1224d1240>
Step 10: Pokédex (mini-gallery).
We’re going to conclude this tutorial with a few quick-fire data visualizations, just to give you a sense of what’s possible with Seaborn.
10.1 - Heatmap
Heatmaps help you visualize matrix-like data.
plt.figure(figsize=(8,6))
# Calculate correlations
corr = stats_df.corr()
# Heatmap
sns.heatmap(corr)
<matplotlib.axes._subplots.AxesSubplot at 0x122892908>
10.2 - Histogram
Histograms allow you to plot the distributions of numeric variables.
plt.figure(figsize=(8,6))
# Distribution Plot (a.k.a. Histogram)
sns.distplot(df.Attack)
<matplotlib.axes._subplots.AxesSubplot at 0x122ac08d0>
10.3 - Bar Plot
Bar plots help you visualize the distributions of categorical variables.
plt.figure(figsize=(8,6))
# Count Plot (a.k.a. Bar Plot)
sns.countplot(x='Type 1', data=df, palette=pkmn_type_colors)
# Rotate x-labels
plt.xticks(rotation=-45)
(array([ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]),
<a list of 15 Text xticklabel objects>)
10.4 - Factor Plot
Factor plots make it easy to separate plots by categorical classes.
# Factor Plot
g = sns.factorplot(x='Type 1',
y='Attack',
data=df,
hue='Stage', # Color by stage
col='Stage', # Separate by stage
kind='swarm') # Swarmplot
# Rotate x-axis labels
g.set_xticklabels(rotation=-45)
# Doesn't work because only rotates last plot
# plt.xticks(rotation=-45)
<seaborn.axisgrid.FacetGrid at 0x121f0fac8>
10.5 - Density Plot
Density plots display the distribution between two variables.
plt.figure(figsize=(8,6))
# Density Plot
sns.kdeplot(df.Attack, df.Defense)
<matplotlib.axes._subplots.AxesSubplot at 0x122f6ba90>
10.6 - Joint Distribution Plot
Joint distribution plots combine information from scatter plots and histograms to give you detailed information for bi-variate distributions.
plt.figure(figsize=(8,6))
# Joint Distribution Plot
sns.jointplot(x='Attack', y='Defense', data=df)
<seaborn.axisgrid.JointGrid at 0x122fc2e80>
<Figure size 576x432 with 0 Axes>
Congratulations… you’ve made it to the end of this Python Seaborn tutorial!
We’ve just concluded a tour of key Seaborn paradigms and showed you many examples along the way. Feel free to use this page along with the official Seaborn gallery as references for your projects going forward.


Notifying Translators
Once a page is ready to be translated, translators can be notified using the localization settings section for the page. Users with permissions to the Languages module can also perform this task. Translators and Administrators only.
- Navigate to the page that is ready for translation.
- Select Page Localization from the Edit Page menu of the ControlBar.
- Click the Notify Translators button. This will display the comment window.
- In the Send notification to Translators text box, enter a message that will be sent to translators.
- Click the Send button.


Student Roster
Search Students
Student List
No Matches
{{item.name}}
delete
Save
Without Permission Slips
{{item.name}}
- received permission slip -
With Permission Slips
{{item.name}}


--- layout: page title: "About" header-img: "img/usingyourimagination_USC.JPG" ---
This site is about something . . . .
say more
Image source: USC Library. Using your imagination, Pomona, 1999More info


What brands of food do you stock?
We stock premium dry dog food from Eukanuba, Hill's, Pedigree and Royal Canin.
Do you monitor the quality of the food?
Yes, we're constantly monitoring changes in recipes and other dietary information in order to make sure your dog gets the highest quality meals.
What if I need to transition my dog into a new feeding program? Can you help?
It's a well known fact that changing food on a dog can be a difficult time. We're happy to create a graduated mix plan to transition your dog from one food to another.
What does a healthy dog look like / what are the signs of a healthy dog?
You can easily check your dog's health by following these great tips by our friends at Peace of Mind Canine.