Chapter 6 Data Wrangling: dplyr
Data scientists, according to interviews and expert estimates, spend from 50 percent to 80 percent of their time mired in the mundane labor of collecting and preparing data, before it can be explored for useful information. - NYTimes (2014)
6.1 Overview of dplyr
We are going to introduce you to data wrangling in R first with the tidyverse. The tidyverse is a new suite of packages that match a philosophy of data science developed by Hadley Wickham and the RStudio team. I find it to be a more straight-forward way to learn R. We will also show you by comparison what code will look like in “Base R”, which means, in R without any additional packages (like the “tidyverse” package) installed. I like David Robinson’s blog post on the topic of teaching the tidyverse first.
For some things, base-R is more straight forward, and we’ll show you that too. Whenever we use a function that is from the tidyverse, we will prefix it so you’ll know for sure.
Objectives
- learn about tidy data
- learn
dplyr
withgapminder
data - practice RStudio-GitHub workflow
Resources
Today’s materials are again borrowing from some excellent sources, including:
- Jenny Bryan’s lectures from STAT545 at UBC: Introduction to dplyr
- Hadley Wickham and Garrett Grolemund’s R for Data Science
- Software Carpentry’s R for reproducible scientific analysis materials: Dataframe manipulation with dplyr
- First developed for Software Carpentry at UCSB
- RStudio’s data wrangling cheatsheet
- RStudio’s data wrangling webinar
6.2 Prerequisites
R Skill Level: Beginner - you’ve got basics of R down and are ready to wrangle your data.
We will use the dplyr
package, which will have been installed with:
install.packages('tidyverse')
6.3 Tidy Data
Hadley Wickham, RStudio’s Chief Scientist, has been building R packages for data wrangling and visualization based on the idea of tidy data.
Tidy data has a simple convention: put variables in the columns and observations in the rows.
The mpg
dataset we were working with this morning was an example of tidy data. When data are tidy, you are set up to work with it for your analyses, plots, etc.
Right now we are going to use dplyr
to wrangle this tidyish data set (the transform part of the cycle), and then come back to tidying messy data using tidyr
once we’ve had some fun wrangling. These are both part of the tidyverse
package that we’ve already installed:
And actually, Hadley Wickham and RStudio have created a ton of packages that help you at every step of the way here. This is from one of Hadley’s recent presentations:
6.3.1 Setup
We’ll do this in a new RMarkdown file.
Here’s what to do:
- Clear your workspace (Session > Restart R)
- New File > R Markdown…
- Save as
gapminder-wrangle.Rmd
- Delete the irrelevant text and write a little note to yourself about how we’ll be wrangling gapminder data using dplyr. You can edit the title too if you need to.
6.3.2 load tidyverse
(which has dplyr
inside)
In your R Markdown file, let’s make sure we’ve got our libraries loaded. Write the following:
library(tidyverse) ## install.packages("tidyverse")
This is becoming standard practice for how to load a library in a file, and if you get an error that the library doesn’t exist, you can install the package easily by running the code within the comment (highlight install.packages("tidyverse")
and run it).
6.4 Explore the gapminder data.frame
We will work with some of the data from the Gapminder project.
The data are on GitHub. Navigate there by going to:
github.com > ohi-science > data-science-training > data > gapminder.csv
or by copy-pasting this in the browser: https://github.com/OHI-Science/data-science-training/blob/master/data/gapminder.csv
Have a look at the data. It’s a .csv file, which you’ve probably encountered before, but GitHub has formatted it nicely so it’s easy to look at. You can see that for every country and year, there are several columns with data in them.
6.4.1 read data with readr::read_csv()
We can read this data into R directly from GitHub, without downloading it. We can do that by clicking on the Raw button on the top-right of the data. This displays it as the raw csv file, without formatting. Copy the url:
https://raw.githubusercontent.com/jules32/2017-11-30-MBARI/gh-pages/data/gapminder.csv
Now, let’s go back to RStudio. In our R Markdown, let’s read this csv file and name the variable “gapminder”. We will use the read_csv()
function from the readr
package (part of the tidyverse, so it’s already installed!).
## read gapminder csv. Note the readr:: prefix identifies which package it's in
gapminder <- readr::read_csv('https://raw.githubusercontent.com/jules32/2017-11-30-MBARI/gh-pages/data/gapminder.csv')
Let’s inspect:
## explore the gapminder dataset
gapminder # this is super long! Let's inspect in different ways
Let’s use head
and tail
:
head(gapminder) # shows first 6
tail(gapminder) # shows last 6
head(gapminder, 10) # shows first X that you indicate
tail(gapminder, 12) # guess what this does!
str()
will provide a sensible description of almost anything: when in doubt, just str()
some of the recently created objects to get some ideas about what to do next.
str(gapminder) # ?str - displays the structure of an object
gapminder
is a data.frame
. We aren’t going to get into the other types of data receptacles today (‘arrays’, ‘matrices’), because working with data.frames is what you should primarily use. Why?
- data.frames package related variables neatly together, great for analysis
- most functions, including the latest and greatest packages actually require that your data be in a data.frame
- data.frames can hold variables of different flavors such as
- character data (country or continent names; “Characters (chr)”)
- quantitative data (years, population; “Integers (int)” or “Numeric (num)”)
- categorical information (male vs. female)
We can also see the gapminder
variable in RStudio’s Environment pane (top right)
More ways to learn basic info on a data.frame.
names(gapminder)
dim(gapminder) # ?dim dimension
ncol(gapminder) # ?ncol number of columns
nrow(gapminder) # ?nrow number of rows
We can combine using c()
to reverse-engineer dim()
! Just a side-note here, but I wanted to introduce you to c()
: we’ll use it later.
c(nrow(gapminder), ncol(gapminder)) # ?c combines values into a vector or list.
A statistical overview can be obtained with summary()
summary(gapminder)
6.4.2 Look at the variables inside a data.frame
To specify a single variable from a data.frame, use the dollar sign $
. The $
operator is a way to extract of replace parts of an object–check out the help menu for $
. It’s a common operator you’ll see in R.
gapminder$lifeExp # very long! hard to make sense of...
head(gapminder$lifeExp) # can do the same tests we tried before
str(gapminder$lifeExp) # it is a single numeric vector
summary(gapminder$lifeExp) # same information, just formatted slightly differently
6.5 dplyr
basics
OK, so let’s start wrangling with dplyr.
There are five dplyr
functions that you will use to do the vast majority of data manipulations:
filter()
: pick observations by their values
select()
: pick variables by their names
mutate()
: create new variables with functions of existing variables
summarise()
: collapse many values down to a single summary
arrange()
: reorder the rows
These can all be used in conjunction with group_by()
which changes the scope of each function from operating on the entire dataset to operating on it group-by-group. These six functions provide the verbs for a language of data manipulation.
All verbs work similarly:
- The first argument is a data frame.
- The subsequent arguments describe what to do with the data frame. You can refer to columns in the data frame directly without using
$
. - The result is a new data frame.
Together these properties make it easy to chain together multiple simple steps to achieve a complex result.
6.6 filter()
subsets data row-wise (observations).
You will want to isolate bits of your data; maybe you want to just look at a single country or a few years. R calls this subsetting.
filter()
is a function in dplyr
that takes logical expressions and returns the rows for which all are TRUE
.
Visually, we are doing this (thanks RStudio for your cheatsheet):
Remember your logical expressions from this morning? We’ll use <
and ==
here.
filter(gapminder, lifeExp < 29)
You can say this out loud: “Filter the gapminder data for life expectancy less than 29”. Notice that when we do this, all the columns are returned, but just the rows that have the life expectancy less than 29. We’ve subsetted by row.
Let’s try another: “Filter the gapminder data for the country Mexico”.
filter(gapminder, country == "Mexico")
How about if we want two country names? We can’t use the ==
operator here, because it can only operate on one thing at a time. We will use the %in%
operator:
filter(gapminder, country %in% c("Mexico", "Peru"))
How about if we want Mexico in 2002? You can pass filter different criteria:
filter(gapminder, country == "Mexico", year == 2002)
6.7 Your turn
What is the mean life expectancy of Sweden? Hint: do this in 2 steps by assigning a variable and then using the mean()
function.
Then, sync to Github.com (pull, stage, commit, push).
6.7.1 Answer
x <- filter(gapminder, country == "Sweden")
mean(x$lifeExp)
6.8 Meet the new pipe %>%
operator
Before we go any further, we should exploit the new pipe operator that dplyr
imports from the magrittr
package by Stefan Bache. This is going to change your data analytical life. You no longer need to enact multi-operation commands by nesting them inside each other. And we won’t need to make temporary variables like we did in the Sweden example above. This new syntax leads to code that is much easier to write and to read: it actually tells the story of your analysis.
Here’s what it looks like: %>%
. The RStudio keyboard shortcut: Ctrl + Shift + M (Windows), Cmd + Shift + M (Mac).
Let’s demo then I’ll explain:
gapminder %>% head()
This is equivalent to head(gapminder)
. This pipe operator takes the thing on the left-hand-side and pipes it into the function call on the right-hand-side – literally, drops it in as the first argument.
Never fear, you can still specify other arguments to this function! To see the first 3 rows of Gapminder, we could say head(gapminder, 3)
or this:
gapminder %>% head(3)
I’ve advised you to think “gets” whenever you see the assignment operator, <-
. Similarly, you should think “and then” whenever you see the pipe operator, %>%
.
You are probably not impressed yet, but the magic will soon happen.
Fun break: check out this gif about %>% from Twitter.
6.9 select()
subsets data column-wise (variables)
Back to dplyr
…
Use select()
to subset the data on variables or columns.
Visually, we are doing this (thanks RStudio for your cheatsheet):
Here’s a conventional call. Again, see that we can select multiple columns just with a comma, after we specify the data frame (gapminder).
select(gapminder, year, lifeExp)
But using what we just learned, with a pipe, we can do this:
gapminder %>% select(year, lifeExp)
Let’s write it again but using multiple lines so it’s nicer to read. And let’s add a second pipe operator to pipe through head
:
gapminder %>%
select(year, lifeExp) %>%
head(4)
Think: “Take gapminder
, then select the variables year and lifeExp, then show the first 4 rows.”
Being able to read a story out of code like this is really game-changing.
6.9.1 Revel in the convenience
Let’s take the gapminder data and filter for the country Cambodia, and select 4 of the columns: country, year, pop, gdpPercap.
gapminder %>%
filter(country == "Cambodia") %>%
select(country, year, pop, gdpPercap)
But entering each column by hand can be tedious, especially since there are fewer columns we don’t want. So instead, we can do:
gapminder %>%
filter(country == "Cambodia") %>%
select(-continent, -lifeExp) # you can use - to deselect columns
6.10 mutate()
adds new variables
Alright, let’s keep going.
Let’s say we needed to add an index column so we know which order these data came in. Let’s not make a new variable, let’s add a column to our gapminder data frame. How do we do that? With the mutate()
function.
Visually, we are doing this (thanks RStudio for your cheatsheet):
We will name our new column index. We will name the new column ‘index’; and we assign it with a single =
. Notice that we can use the nrow
function within our mutate call:
gapminder %>%
mutate(index = 1:nrow(gapminder))
OK, let’s do another example. Imagine we wanted to recover each country’s GDP. After all, the Gapminder data has a variable for population and GDP per capita.
gapminder %>%
mutate(gdp = pop * gdpPercap)
6.10.1 Your turn
Find the maximum gdpPercap of Egypt and Vietnam Create a new column.
Then, sync to Github.com (pull, stage, commit, push).
<IP_ADDRESS> Answer
gapminder %>%
select(-continent, -lifeExp) %>% # not super necessary but to simplify
filter(country == "Egypt") %>%
mutate(gdp = pop * gdpPercap) %>%
mutate(max_gdp = max(gdp))
## you can also create multiple variables within the same mutate(), and line them up so they are easier to read:
gapminder %>%
select(-continent, -lifeExp) %>% # not super necessary but to simplify
filter(country == "Vietnam") %>%
mutate(gdp = pop * gdpPercap,
max_gdp = max(gdp))
With the things we know so far, the answers you have are maybe a bit limiting. First, We had to act on Egypt and Vietnam separately, and repeat the same code. Copy-pasting like this is also super error prone.
And second, this max_gdpPercap
column is pretty redundant, because it’s a repeated value a ton of times. Sometimes this is exactly what you want! You are now set up nicely to maybe take a proportion of gdpPercap/max_gdpPercap for each year or something. But maybe you just wanted that max_gdpPercap for something else. Let’s keep going…
6.11 group_by()
operates on groups
Let’s tackle that first issue first. So how do we less painfully calculate the max gdpPercap for all countries?
Visually, we are doing this (thanks RStudio for your cheatsheet):
gapminder %>%
group_by(country) %>%
mutate(gdp = pop * gdpPercap,
max_gdp = max(gdp)) %>%
ungroup() # if you use group_by, also use ungroup() to save heartache later
So instead of filtering for a specific country, we’ve grouped by country, and then done the same operations. It’s hard to see; let’s look at a bunch at the tail:
gapminder %>%
group_by(country) %>%
mutate(gdp = pop * gdpPercap,
max_gdp = max(gdp)) %>%
ungroup() %>%
tail(30)
OK, this is great. But what if this what we needed, a max_gdp value for each country. We don’t need that kind of repeated value for each of the max_gdp values. Here’s the next function:
6.11.1 summarize()
with group_by()
We want to operate on a group, but actually collapse or distill the output from that group. The summarize()
function will do that for us.
Visually, we are doing this (thanks RStudio for your cheatsheet):
Here we go:
gapminder %>%
group_by(country) %>%
mutate(gdp = pop * gdpPercap) %>%
summarize(max_gdp = max(gdp)) %>%
ungroup()
How cool is that! summarize()
will actually only keep the columns that are grouped_by or summarized. So if we wanted to keep other columns, we’d have to do it another way (we’ll get into it tomorrow).
6.12 arrange()
orders columns
This is ordered alphabetically, which is cool. But let’s say we wanted to order it in ascending order for max_gdp
. The dplyr function is arrange()
.
gapminder %>%
group_by(country) %>%
mutate(gdp = pop * gdpPercap) %>%
summarize(max_gdp = max(gdp)) %>%
ungroup() %>%
arrange(max_gdp)
6.12.1 Your turn
- arrange your data frame in descending order (opposite of what we’ve done). Expect that this is possible:
?arrange
- save your data frame as a variable
- find the maximum life expectancy for countries in Asia. What is the earliest year you encounter? The latest? Hint: you can use or
base::max
anddplyr::arrange()
… - Knit your RMarkdown file, and sync it to GitHub (pull, stage, commit, push)
<IP_ADDRESS> Answer (no peeking!)
gapminder %>%
filter(continent == 'Asia') %>%
group_by(country) %>%
filter(lifeExp == max(lifeExp)) %>%
arrange(year)
6.13 All together now
We have done a pretty incredible amount of work in a few lines. Our whole analysis is this. Imagine the possibilities from here. It’s very readable: you see the data as the first thing, it’s not nested. Then, you can read the verbs. This is the whole thing, with explicit package calls from readr::
and dplyr::
:
## gapminder-wrangle.R
## J. Lowndes<EMAIL_ADDRESS>## load libraries
library(tidyverse) ## install.packages('tidyverse')
## read in data
gapminder <- readr::read_csv('https://raw.githubusercontent.com/jules32/2017-11-30-MBARI/gh-pages/data/gapminder.csv')
## summarize
gap_max_gdp <- gapminder %>%
dplyr::select(-continent, -lifeExp) %>% # or select(country, year, pop, gdpPercap)
dplyr::group_by(country) %>%
dplyr::mutate(gdp = pop * gdpPercap) %>%
dplyr::summarize(max_gdp = max(gdp)) %>%
dplyr::ungroup()
I actually am borrowing this “All together now” from Tony Fischetti’s blog post How dplyr replaced my most common R idioms). With that as inspiration, this is how what we have just done would look like in Base R.
6.13.1 Compare to base R
Let’s compare with some base R code to accomplish the same things. Base R requires subsetting with the [rows, columns]
notation. This notation is something you’ll see a lot in base R. the brackets [ ]
allow you to extract parts of an object. Within the brackets, the comma separates rows from columns.
If we don’t write anything after the comma, that means “all columns”. And if we don’t write anything before the comma, that means “all rows”.
Also, the $
operator is how you access specific columns of your dataframe. You can also add new columns like we will do with mex$gdp
below.
Instead of calculating the max for each country like we did with dplyr
above, here we will just calculate the max for one country, Mexico. Tomorrow we will learn how to do it for all the countries, like we did with dplyr::group_by()
.
## gapminder-wrangle.R --- baseR
## J. Lowndes<EMAIL_ADDRESS>gapminder <- read.csv('https://raw.githubusercontent.com/jules32/2017-11-30-MBARI/gh-pages/data/gapminder.csv', stringsAsFactors = FALSE)
x1 <- gapminder[ , c('country', 'year', 'pop', 'gdpPercap') ]# subset columns
mex <- x1[x1$country == "Mexico", ] # subset rows
mex$gdp <- mex$pop * mex$gdpPercap # add new columns
mex$max_gdp <- max(mex$gdp)
Note too that the chain operator %>%
that we used with the tidyverse
lets us get away from the temporary variable x1.
6.13.2 Your Turn
Get your RMarkdown file cleaned up and sync it for the last time today!
<IP_ADDRESS> Answers
…
6.14 Key Points
- Data manipulation functions in
dplyr
allow you tofilter()
by rows andselect()
by columns, create new columns withmutate()
, andgroup_by()
unique column values to applysummarize()
for new columns that define aggregate values across groupings. - The “then” operator
%>%
allows you to chain successive operations without needing to define intermediary variables for creating the most parsimonious, easily read analysis.


my name is zainab albadarin iam a 29 years old , and also i am a mother of mohammed and ameera and i am interested in computational chemistry and solve chemical issues using computer and i am interested in coding
i have graduated from Jordan University of Science and Technology with a Master degree in inorganic chemistry with a G.P.A of (3.5), Rate: Excellent


InSynerger provides cloud computing-based power management services
by Chloe Liao, Taipei; Adam Hwang, DIGITIMESTaiwan-based InSynerger Technology has introduced cloud computing power management services by virtue of IoT, big data analysis and AI for non-residential users, according to company president Polon Chuang.
InSynerger, spun off from government-sponsored Information Industry Institute (III) in 2017, uses IoT sensors to collect power consumption data from machines and equipment, and provides cloud computing-based platforms for users to improve power use efficiency, Chuang said, adding power consumption data can be used in analysis to detect abnormal operating conditions for machines and equipment and optimize manufacturing processes.
Based on analysis of historical data on power consumption and relevant data such as output and working days, InSynerger predicts monthly power demand as reference for users to decide on optimal monthly contract capacity for electricity supply with state-run Taiwan Power Company (Taipower), Chuang indicated.
InSynerger helps users prevent power use from exceeding supply determined in the contract, Chuang said.
InSynerger is cooperating with Taipower to develop a cloud computing-based ADR (automated demand response) platform to enable Taipower to reach smart real-time adjustment in distribution and supply of power based on actual demand.


Exams
On this page, you can see your registered courses, deregister courses, and enroll in additional courses for the current semester. Choose from the following tab bar what you would like to do:
This table lists the courses that you have registered for Information Design in the current summer semester 2020.You can deregister a courses by selecting it from the list below and clicking on the button "Deregister Selected Courses".
| Status | Name | ID | ECTS | Lecturer | Area | Exam Type | Exam Date |
|---|---|---|---|---|---|---|---|
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | 20.07.2020 | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | 03.08.2020 | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | 20.07.2020 | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | 03.08.2020 | |
| Bachelorkolloquium | 332520 | 3 | Prof. Dr. Jörg Westbomke | Mandatory Course | PL | 30.07.2020 |
These are the courses that you can enroll for Information Design in the current summer semester 2020. You can enroll a courses by selecting it from the list below and clicking on the button "Enroll in Selected Courses".
| Status | Name | ID | ECTS | Lecturer | Area | Exam Type |
|---|---|---|---|---|---|---|
| Bachelor Thesis | 59384 | 12 | Prof. Ralph Tille | Thesis | FA | |
| Internship | 64364 | 30 | Prof. Ralph Tille | Internship | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA |
| Status | Name | ID | ECTS | Lecturer | Area | Exam Type |
|---|---|---|---|---|---|---|
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA | |
| Mobile Medien | 334050a | 5 | Prof. Dr. Jörg Westbomke | Specializations | PA |
| Status | Name | ID | ECTS | Lecturer | Area | Exam Type |
|---|---|---|---|---|---|---|
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA | |
| App Design | 53423 | 5 | Prof. Ralph Tille | Project | PA |


log4javascript basic demo
NB. Since the demo below uses pop-up windows, you will need to disable any pop-up blockers you may have for it to work.
This demo demonstrates the default logger. For more options, please see the demos area.
Enter a log message below and click on one of the buttons to log your message at your desired level. You can then filter by log level, toggle word-wrapping and perform text and regular expression searches on the log entries.
Generate random log entries


meatspace
`Prev `__
M
`Next `__
--------------
**meatspace**: /meet´spays/, n.
The physical world, where the meat lives — as opposed to
`*cyberspace* <../C/cyberspace.html>`__. Hackers are actually more
willing to use this term than ‘cyberspace’, because it's not speculative
— we already have a running meatspace implementation (the universe).
Compare `*RL* <../R/RL.html>`__.
--------------
+----------------------------------+----------------------------+-----------------------------+
| `Prev `__ | `Up <../M.html>`__ | `Next `__ |
+----------------------------------+----------------------------+-----------------------------+
| McQuary limit | `Home <../index.html>`__ | meatware |
+----------------------------------+----------------------------+-----------------------------+


The scheduler forbids any action which is the result of sending a message to a process with the registered name<EMAIL_ADDRESS>This scheduler is used in the example on page to steer a simulation algorithm, which is followed by running a model checking algorithm (@mce_alg_safety@). The idea is that the simulation part should explore the initial startup of the system, forbidding any action that involves actually requesting resources from the @locker@ process. Once there is no schedulable transition (except the ones involving sends to the locker) the simulation phase ends, and model checking begins.


| Name | Total Lines | Lines of Code | Total Coverage | Code Coverage |
|---|---|---|---|---|
| gems/gems/dm-paperclip-2.1.4/lib/dm-paperclip.rb | 241 | 108 | 87.97%
|
76.85%
|
Code reported as executed by Ruby looks like this...and this: this line is also marked as covered.Lines considered as run by rcov, but not reported by Ruby, look like this,and this: these lines were inferred by rcov (using simple heuristics).Finally, here's a line marked as not executed.
1 # Paperclip allows file attachments that are stored in the filesystem. All graphical |
2 # transformations are done using the Graphics/ImageMagick command line utilities and |
3 # are stored in Tempfiles until the record is saved. Paperclip does not require a |
4 # separate model for storing the attachment's information, instead adding a few simple |
5 # columns to your table. |
6 # |
7 # Author:: Jon Yurek |
8 # Copyright:: Copyright (c) 2008 thoughtbot, inc. |
9 # License:: MIT License (http://www.opensource.org/licenses/mit-license.php) |
10 # |
11 # Paperclip defines an attachment as any file, though it makes special considerations |
12 # for image files. You can declare that a model has an attached file with the |
13 # +has_attached_file+ method: |
14 # |
15 # class User < ActiveRecord::Base |
16 # has_attached_file :avatar, :styles => { :thumb => "100x100" } |
17 # end |
18 # |
19 # user = User.new |
20 # user.avatar = params[:user][:avatar] |
21 # user.avatar.url |
22 # # => "/users/avatars/4/original_me.jpg" |
23 # user.avatar.url(:thumb) |
24 # # => "/users/avatars/4/thumb_me.jpg" |
25 # |
26 # See the +has_attached_file+ documentation for more details. |
27 |
28 require 'tempfile' |
29 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'upfile') |
30 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'iostream') |
31 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'geometry') |
32 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'thumbnail') |
33 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'storage') |
34 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'attachment') |
35 |
36 # Only include validations if dm-validations is loaded |
37 require File.join(File.dirname(__FILE__), 'dm-paperclip', 'validations') unless defined?(DataMapper::Validate).nil? |
38 |
39 module Paperclip |
40 VERSION = "2.1.4" |
41 class << self |
42 # Provides configurability to Paperclip. There are a number of options available, such as: |
43 # * whiny_thumbnails: Will raise an error if Paperclip cannot process thumbnails of |
44 # an uploaded image. Defaults to true. |
45 # * image_magick_path: Defines the path at which to find the +convert+ and +identify+ |
46 # programs if they are not visible to Rails the system's search path. Defaults to |
47 # nil, which uses the first executable found in the search path. |
48 def options |
49 @options ||= { |
50 :whiny_thumbnails => true, |
51 :image_magick_path => nil |
52 } |
53 end |
54 |
55 def path_for_command command #:nodoc: |
56 path = [options[:image_magick_path], command].compact |
57 File.join(*path) |
58 end |
59 end |
60 |
61 class PaperclipError < StandardError #:nodoc: |
62 end |
63 |
64 class NotIdentifiedByImageMagickError < PaperclipError #:nodoc: |
65 end |
66 |
67 module Resource |
68 def self.included(base) |
69 base.class_eval <<-RUBY, __FILE__, __LINE__ + 1 |
70 class_variable_set(:@@attachment_definitions,nil) unless class_variable_defined?(:@@attachment_definitions) |
71 def self.attachment_definitions |
72 @@attachment_definitions |
73 end |
74 |
75 def self.attachment_definitions=(obj) |
76 @@attachment_definitions = obj |
77 end |
78 RUBY |
79 base.extend Paperclip::ClassMethods |
80 end |
81 end |
82 |
83 module ClassMethods |
84 |
85 # +has_attached_file+ gives the class it is called on an attribute that maps to a file. This |
86 # is typically a file stored somewhere on the filesystem and has been uploaded by a user. |
87 # The attribute returns a Paperclip::Attachment object which handles the management of |
88 # that file. The intent is to make the attachment as much like a normal attribute. The |
89 # thumbnails will be created when the new file is assigned, but they will *not* be saved |
90 # until +save+ is called on the record. Likewise, if the attribute is set to +nil+ is |
91 # called on it, the attachment will *not* be deleted until +save+ is called. See the |
92 # Paperclip::Attachment documentation for more specifics. There are a number of options |
93 # you can set to change the behavior of a Paperclip attachment: |
94 # * +url+: The full URL of where the attachment is publically accessible. This can just |
95 # as easily point to a directory served directly through Apache as it can to an action |
96 # that can control permissions. You can specify the full domain and path, but usually |
97 # just an absolute path is sufficient. The leading slash must be included manually for |
98 # absolute paths. The default value is "/:class/:attachment/:id/:style_:filename". See |
99 # Paperclip::Attachment#interpolate for more information on variable interpolaton. |
100 # :url => "/:attachment/:id/:style_:basename:extension" |
101 # :url => "http://some.other.host/stuff/:class/:id_:extension" |
102 # * +default_url+: The URL that will be returned if there is no attachment assigned. |
103 # This field is interpolated just as the url is. The default value is |
104 # "/:class/:attachment/missing_:style.png" |
105 # has_attached_file :avatar, :default_url => "/images/default_:style_avatar.png" |
106 # User.new.avatar_url(:small) # => "/images/default_small_avatar.png" |
107 # * +styles+: A hash of thumbnail styles and their geometries. You can find more about |
108 # geometry strings at the ImageMagick website |
109 # (http://www.imagemagick.org/script/command-line-options.php#resize). Paperclip |
110 # also adds the "#" option (e.g. "50x50#"), which will resize the image to fit maximally |
111 # inside the dimensions and then crop the rest off (weighted at the center). The |
112 # default value is to generate no thumbnails. |
113 # * +default_style+: The thumbnail style that will be used by default URLs. |
114 # Defaults to +original+. |
115 # has_attached_file :avatar, :styles => { :normal => "100x100#" }, |
116 # :default_style => :normal |
117 # user.avatar.url # => "/avatars/23/normal_me.png" |
118 # * +whiny_thumbnails+: Will raise an error if Paperclip cannot process thumbnails of an |
119 # uploaded image. This will ovrride the global setting for this attachment. |
120 # Defaults to true. |
121 # * +convert_options+: When creating thumbnails, use this free-form options |
122 # field to pass in various convert command options. Typical options are "-strip" to |
123 # remove all Exif data from the image (save space for thumbnails and avatars) or |
124 # "-depth 8" to specify the bit depth of the resulting conversion. See ImageMagick |
125 # convert documentation for more options: (http://www.imagemagick.org/script/convert.php) |
126 # Note that this option takes a hash of options, each of which correspond to the style |
127 # of thumbnail being generated. You can also specify :all as a key, which will apply |
128 # to all of the thumbnails being generated. If you specify options for the :original, |
129 # it would be best if you did not specify destructive options, as the intent of keeping |
130 # the original around is to regenerate all the thumbnails then requirements change. |
131 # has_attached_file :avatar, :styles => { :large => "300x300", :negative => "100x100" } |
132 # :convert_options => { |
133 # :all => "-strip", |
134 # :negative => "-negate" |
135 # } |
136 # * +storage+: Chooses the storage backend where the files will be stored. The current |
137 # choices are :filesystem and :s3. The default is :filesystem. Make sure you read the |
138 # documentation for Paperclip::Storage::Filesystem and Paperclip::Storage::S3 |
139 # for backend-specific options. |
140 def has_attached_file name, options = {} |
141 include InstanceMethods |
142 |
143 self.attachment_definitions = {} if self.attachment_definitions.nil? |
144 self.attachment_definitions[name] = {:validations => []}.merge(options) |
145 |
146 property_options = options.delete_if { |k,v| ![ :public, :protected, :private, :accessor, :reader, :writer ].include?(key) } |
147 |
148 property "#{name}_file_name".to_sym, String, property_options |
149 property "#{name}_content_type".to_sym, String, property_options |
150 property "#{name}_file_size".to_sym, Integer, property_options |
151 property "#{name}_updated_at".to_sym, DateTime, property_options |
152 |
153 after :save, :save_attached_files |
154 before :destroy, :destroy_attached_files |
155 |
156 define_method name do |*args| |
157 a = attachment_for(name) |
158 (args.length > 0) ? a.to_s(args.first) : a |
159 end |
160 |
161 define_method "#{name}=" do |file| |
162 attachment_for(name).assign(file) |
163 end |
164 |
165 define_method "#{name}?" do |
166 ! attachment_for(name).original_filename.blank? |
167 end |
168 |
169 unless defined?(DataMapper::Validate).nil? |
170 add_validator_to_context(opts_from_validator_args([name]), [name], Paperclip::Validate::CopyAttachmentErrors) |
171 end |
172 end |
173 |
174 unless defined?(DataMapper::Validate).nil? |
175 |
176 # Places ActiveRecord-style validations on the size of the file assigned. The |
177 # possible options are: |
178 # * +in+: a Range of bytes (i.e. +1..1.megabyte+), |
179 # * +less_than+: equivalent to :in => 0..options[:less_than] |
180 # * +greater_than+: equivalent to :in => options[:greater_than]..Infinity |
181 # * +message+: error message to display, use :min and :max as replacements |
182 def validates_attachment_size(*fields) |
183 opts = opts_from_validator_args(fields) |
184 add_validator_to_context(opts, fields, Paperclip::Validate::SizeValidator) |
185 end |
186 |
187 # Adds errors if thumbnail creation fails. The same as specifying :whiny_thumbnails => true. |
188 def validates_attachment_thumbnails name, options = {} |
189 self.attachment_definitions[name][:whiny_thumbnails] = true |
190 end |
191 |
192 # Places ActiveRecord-style validations on the presence of a file. |
193 def validates_attachment_presence(*fields) |
194 opts = opts_from_validator_args(fields) |
195 add_validator_to_context(opts, fields, Paperclip::Validate::RequiredFieldValidator) |
196 end |
197 |
198 # Places ActiveRecord-style validations on the content type of the file assigned. The |
199 # possible options are: |
200 # * +content_type+: Allowed content types. Can be a single content type or an array. Allows all by default. |
201 # * +message+: The message to display when the uploaded file has an invalid content type. |
202 def validates_attachment_content_type(*fields) |
203 opts = opts_from_validator_args(fields) |
204 add_validator_to_context(opts, fields, Paperclip::Validate::ContentTypeValidator) |
205 end |
206 |
207 end |
208 |
209 end |
210 |
211 module InstanceMethods #:nodoc: |
212 def attachment_for name |
213 @attachments ||= {} |
214 @attachments[name] ||= Attachment.new(name, self, self.class.attachment_definitions[name]) |
215 end |
216 |
217 def each_attachment |
218 self.class.attachment_definitions.each do |name, definition| |
219 yield(name, attachment_for(name)) |
220 end |
221 end |
222 |
223 def save_attached_files |
224 #logger.info("[paperclip] Saving attachments.") |
225 each_attachment do |name, attachment| |
226 attachment.send(:save) |
227 end |
228 end |
229 |
230 def destroy_attached_files |
231 #logger.info("[paperclip] Deleting attachments.") |
232 each_attachment do |name, attachment| |
233 attachment.send(:queue_existing_for_delete) |
234 attachment.send(:flush_deletes) |
235 end |
236 end |
237 end |
238 |
239 end |
240 |
241 File.send(:include, Paperclip::Upfile) |
Generated on Thu Nov 12 16:05:07 +0530 2009 with rcov 0.9.6


{% extends "base.html" %} {% block content %}
This site is run by Democracy Club who are a UK based Community interest company (or CIC), Company number 09461226
We make the following promises about your personal information as a user of the site:
We store your IP address for our logs. We also store the postcode entered on the site, purely for statistical use, and the postcode is never stored against any other personal information of any sort.
We also use Google Analytics to aggregate and track data about usage of the site; you can use a browser plugin to opt out of having data collected by Google Analytics.


‘Harriet’ Screenwriter Reveals Julia Roberts Was Suggested For Harriet Tubman Role
by Akinwale AkinyoadeGregory Allen Howard, the screenwriter of ‘Harriet’ has opened up that a Harriet Tubman biopic was almost produced 25-years-ago.
Although this sounds like an exciting news, he also made the shocking reveal that a studio executive had no idea that Tubman was black and even suggested Hollywood sweetheart, Julia Roberts for the role of Tubman.
Harriet Tubman was an American abolitionist and political activist. Born into slavery, Tubman escaped and subsequently made some 13 missions to rescue approximately 70 enslaved people, including family and friends, using the network of antislavery activists and safe houses known as the Underground Railroad.
Writing about the new film in a Los Angeles Times, he wrote:
“Fortunately, there was a single black person in that studio meeting 25 years ago who told him that Harriet Tubman was a black woman.”
But it was his response to that simple statement of fact that would prove just how ridiculously out-of-touch at least some portions of Hollywood apparently were even as recently as 1994. According to Howard,
“The president replied, ‘That was so long ago. No one will know that.'”
Considering Harriet Tubman is one of the cornerstones of American history where it relates to the institution of slavery, you’d certainly hope people know she was not a white woman, and knew it then, too.
Howard who decided to hold onto the script told Focus Features.
“When I started on ‘Harriet,’ many people dealing with black material were writing history lessons — which I hated,” “I remember someone asking, ‘Is Harriet Tubman really supposed to be a superhero?’ That’s exactly what I wanted.”
Howard’s vision is an action-adventure film with mass appeal, as opposed to one only target history aficionados, and he credits the groundbreaking success of “Black Panther” and “12 Years a Slave” for pushing the narrative forward in Hollywood as to what kinds of stories can be told with black leads.
Cynthia Erivo portrays Tubman in Howard’s “Harriet,” in theaters now.
American actress, comedian, author, and television personality. Whoopi Goldberg doesn’t have problem with Cynthia Erivo playing Harriet Tubman, despite the fact that’s she’s British.
While out in Los Angeles Wednesday, “The View” co-host weighed in on the controversy over Erivo’s casting as the famous American abolitionist.
“Well, I feel as long as she’s African, and black she might have some feel for it,” Goldberg said. “But who amongst the actors isn’t going to have to do the work? So, I’m sure there’s a lot of controversy but you know good actors are good actors.”


Home
About
Contact
Droppelion
See it in action
Selected product:
{{ product | json }}
Clear selection
×
Close
Create product modal
Product name
Producer
Product Code


TECHNOLOGY
Developing technologies to help keep you safe on the road.
Prevention
Safety technology to prevent accidents.
Protection
Safety technology to protect people.
Safety is built into the DNA of every Renault. The entire Renault range is designed to provide protection to those travelling in the vehicle.
The vehicle’s structure protects occupants by absorbing much of the impact energy, while cabin-based retention systems soak up the rest of the energy.
Renault’s third-generation System for Restraint and Protection (SRP) is a safety innovation which is still unique on the market, and our range of passenger protection systems includes active anti-submarining airbags, high-performance rear impact absorbing seats and headrests, dual side impact sensors and advanced child safety systems.
System for Restraint and Protection
A complete protection system for each seat and each occupant.
Active anti-submarining airbag
Collision protection which is equally effective for both 3 and 5 door cars.
Rear impact absorbing seats and headrests
Maximum protection against whiplash.
Side impact protection
A world first in side-impact protection.
Side impact protection
A world first in side-impact protection.
Side impact protection
A world first in side-impact protection.
Side impact protection
A world first in side-impact protection.
Side impact protection
A world first in side-impact protection.
Side impact protection
A world first in side-impact protection.
Correction
Safety technology to assist.
Renault's technologically advanced driver assistance systems are designed to compensate for driver errors and to provide critical, potentially life-saving intervention in extreme driving situations.
Available on many models, this equipment includes optimized braking with ABS and emergency brake assist (EBA); ESC (electronic stability control) with CSV understeer control; and the Four Control chassis with four-wheel steering which provides unparalleled steering precision.
Emergency Brake Assist (EBA)
Emergency brake assist compensates for deficiencies in the driver’s action on the brake pedal. Drivers in emergency situations tend to apply insufficient pressure, or release braking pressure too soon. Emergency brake assist remedies both of these deficiencies. Other experimental studies show that emergency brake assist can reduce stopping distances by between 5 and 9 metres on dry roads (source: LAB).
Electronic Stability Control (ESC)
ESC (Electronic Stability Control), also known as ESP (Electronic Stability Program, a registered trademark), helps the driver control the vehicle if it starts to stray from the chosen cornering line, but without taking control out of the driver’s hands. On Renault models, ESC is enhanced by an additional understeer control function which corrects understeer in emergency situations.
Child safety
Car safety for children.
As far as child safety is concerned, nothing is too much for Renault. Because children are more fragile and vulnerable than adults, and to better understand how to protect them in serious collisions, Renault participated in the European research programmes CHILD and CREST, based chiefly on the observations made from 669 real-life car accidents with children on-board.
Thanks to this work, Renault has been able to develop its own testing method to endow child seats with the same level of safety as adult seating systems.
For each new car, Renault ensures that seats can be correctly fitted and that they meet particularly rigorous protection requirements.


widget - Megawidget bundle
This package provides megawidgets based on the snit oo system (snidgets). It makes use of the Tile/Ttk themed widget set.
commands:
options:
options:
options:
options:
options:
options:
options:
options:
options:
options:
options:
package require widget::superframe ; # or widget::all pack [widget::superframe .f -type separator -text "SuperFrame:"]
This document, and the package it describes, will undoubtedly contain bugs and other problems. Please report such in the category widget of the Tklib Trackers. Please also report any ideas for enhancements you may have for either package and/or documentation.
bundle, calendar, dateentry, dialog, megawidget, menu, panelframe, ruler, screenruler, scrolledwindow, snit, statusbar, superframe, toolbar, widget
Widget


PDFObject Example: Invoking conditional JavaScript upon successful embed (onclick)
Click this link to embed the PDF.
PDFObject.com


Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe
Recipe


The Geofabric
Home
API
About
Contracted Catchments
River Regions
Drainage Divisions
{% block content %}{% endblock %}


 A mutual fund investment could potentially be one such. The procedure for gifting mutual funds is a little unique. Mutual funds do not accept payments from third parties.
This essentially means that one cannot invest in a scheme using a cheque that has been issued by another person. However, when it comes to gifting a mutual fund investment to a minor child by following prescribed rules, the same is permissible.
Third-party payments are accepted by mutual funds in case of payment on behalf of a minor. This is subject to a limit of ₹50,000. Therefore, parents, grandparents and other immediate family members can invest in a mutual fund in the name of minor children.
Steps to get you started
Start a mutual fund investment in the name of the child. The parent/guardian will have to open a mutual fund folio in the name of the minor child.
It is important to note that the investment will be held solely in the name of the minor. Since the minor is not legally allowed to take financial decisions, there will have to be a designated parent or guardian who will be the account’s custodian.
The KYC formalities have to be completed by the parent or the guardian. In the case of a third party (grandparent or other immediate family) making an investment on behalf of the minor, a declaration form needs to be submitted, which will have details about the bank account of the person making the investment and their /her relationship with the minor. The third-party has to be KYC-compliant. The form must be signed by the third party and the parent/guardian of the minor child.
Required documents
The birth certificate or the passport of the child can be used for proof of age or date of birth and for the relationship between the parent and the minor.
For a guardian, a notorised copy of the court order appointing the legal guardianship is necessary. You can also start an SIP for the child. In this case, the parent/guardian needs to give the ACH (Automated Clearing House) mandate for direct transfer from their bank account.
For the period that the child is a minor, the MF account will be operated by the parent or legal guardian. Once the child turns 18, the folio will be frozen for operation by the parent or legal guardian. Thereafter, the person in whose name the folio was opened, can operate the folio. Additionally, in the case of an SIP, the contributions by the parent/guardian/third-party will be suspended once the child becomes a major.
At the time of redemption, the beneficiary will have to do a fresh KYC and submit the necessary documents. Once the KYC of the beneficiary has been completed, the account status will be changed from minor to major.
Gifting of mutual funds can have certain tax implications. It is advisable to ask your tax consultant about such investments.
The writer is Senior Fund Manager, Equities, BNP Paribas Mutual Fund
- Get Free Trial
- Hurry! Prices Increase Soon
Existing users, please Sign in here
Thank you for being a loyal user of Portfolio.
Portfolio will be a paid section hereon.
Please Subscribe to get access to one of our early bird packs. Or click on Free Trial to get 14 days free trial.
What You'll Get
-
Web + Mobile
Access exclusive content of the Hindu Businessline across desktops, tablet and mobile device.
-
Exclusive Portfolio and Investment Advice, Banking, Lifestyle and Specials
Get diverse set of perspectives from our trusted experts on Portfolio, Banking, Economy, Environment and others.
-
Ad free experience
Experience cleaner site with zero ads and faster load times.
-
Personalised dashboard
Customize your preference and get a personalized recommendation of stories based on your interest.
- Get Free Trial
- Hurry! Prices Increase Soon
Existing users, please Sign in here


A Datasource is a technology or system that stores data. Some examples include:
In order to help you identify some datasources, use this list of helper questions:
While ideally we would prefer to know every system you use that stores data, we recognize it may be overwhelming and cause an extra burden for some departments to list every single piece of software they use that stores data. In those situations, we are asking you to use your judgement -- if this is something that gets PRA'd or something that holds information you think may be useful to someone in another department please put that system in as a datasource.
It's important to understand that we are not looking for a listing of every spreadsheet / Access DB you, your department or your colleagues own or use.
The spreadsheets we would like to ask you to add as Datasources are the type that are:
This is not an exhaustive list of attributes that would make a spreadsheet a datasource, but we ask you to use your best judgement based on the examples below.
If you are hesitant about whether to include a spreadsheet / Access DB in the list, feel free to email Maksim, or err on the side of caution and include it (unless doing so will require an inordinate amount of work such as adding 100 spreadsheets to the list). It will be weeded out before Step 2 begins.
If there's a report that you run from another system that ends up being put into a spreadsheet, that spreadsheet is not a datasource. However, please include that spreadsheet as a dataset in Step 2 (Sheet #2 in the Google Doc).
If there's a report that you periodically prepare for another department (for example budget reports per department that roll up to a budget report compiled by FM), you do NOT need to identify that spreadsheet as a datasource or a dataset. However, we are asking you to use your judgement here -- if this is something that gets PRA'd and your department (as opposed to FM in this example) compiles the response to the PRA or something that you think may be useful to someone in another department that is not receiving the report, please put that in as a dataset and the system where it comes from as a datasource.
There are some judgment calls required here and we will follow-up with you before reporting a status update on our inventory efforts if it appears your submittal included too much or too little information.


Your reading list
Title
by
author
(Isbn
)
Description
No Description
You have no books in your book list
Add a book
Title:
Author:
ISBN:
Description:
Description
No Description


{{book?.description}} Categories: {{book?.genre.category}}, {{book?.genre.name}} Published: {{book?.published | filterDateMoment:'from' }}
{{book?.description}}
{{p.content}}
If you like this book, we recommend you check theses emerging titles


Connecting over WiFi...
If nothing happens, try reloading the page.
Or maybe the $2 CPU got stuck. It does that often


Normally we know the date we were born but it is hard for us to remember the day whether it was on a monday or a friday or any other day.
Akan names are derived from Ghanian culture. Frequently in Ghana, children are given their first name as a day name which corresponds to the day in the week as they were born.By knowing the day your were born you can also get to know you Akan name.


--- layout: post date: 2010-06-25 time: "09:00:00" authors: ["Greg Wilson"] title: Final Episode of Regular Expressions Lecture Now Online tags: ["Content"] ---
The fifth and final episode of our lecture on regular expressions is now online. In this episode, we work through a new problem—extracting bibliographic citations from papers—and introduce a few new tools along the way. Please let us know what you think.


Algorithm
public enum Algorithm
Enumerates available algorithms
-
Advanced Encryption Standard
Declaration
Swift
case AES,
-
Data Encryption Standard
Declaration
Swift
DES,
-
Triple DES
Declaration
Swift
TripleDES,
-
CAST
Declaration
Swift
CAST,
-
RC2
Declaration
Swift
RC2,
-
Blowfish
Declaration
Swift
Blowfish
-
Blocksize, in bytes, of algorithm.
Declaration
Swift
public func blockSize() -> Int


EVO HTML to PDF Converter can embed the fonts in the generated PDF document to ensure the PDF document is using the same fonts on any computer where the document is displayed.
At the top of the demo you can choose the HTML document to convert which can be:
-
HTML Page URL or Local File to Convert. The URL must be accessible from the computer where the converter runs. If the page requires authentication or if you are using a proxy server to access Internet
then you have to set the converter properties accordingly as described in documentation
-
HTML String to Convert. When you convert a HTML string you also have the option to specify a base URL that will be used
by converter to resolve the relative URLs found in the HTML string to fully qualified URLs. If your HTML string uses only fully qualified URLs then this parameter is not necessary
The options you can set in this demo are:
-
Embed Fonts. Using this option you can enable or disable the fonts embedding in the generated PDF document


| Alert |
Alert |
| Badge |
Badge |
| Box |
Card; Border, spacing, and color utilities |
| Breadcrumb |
Breadcrumbs |
| Button |
Button |
| Checkboxes |
Checkbox |
| Dropdown |
Dropdown |
| File input |
File input |
| Footer |
Footer |
| Grid |
Grid |
| Header |
Header |
| Input group |
Input group |
| Links |
Call to action; Link hub; Sidenav; Typography utilities |
| Lists |
List |
| Loading indicator |
Loading indicator |
| Media object |
Flex utilities |
| Menu |
Subnav |
| Modal |
Dialog |
| Pagination |
Pagination |
| Panel |
Card; Link hub; Border, spacing, and color utilities |
| Radio buttons |
Radio input |
| Segmented button |
Button |
| Select element |
Select input |
| Step indicator |
Step indicator |
| Tabs |
Tabs |
| Text inputs |
Text input; Textarea |
| Timeline |
Timeline |
| Add-on: Collapsible |
Accordion; Disclosure |
| Add-on: Datepicker |
Datepicker (forthcoming) |
| Add-on: Shell |
Layouts |
| Add-on: Switch |
Switch |


We won the TechCrunch Disrupt 2017 and the special Company Award from SAP Hybris. The idea was Quick Insurance - the easiest way to purchase an insurance product for all your valuable stuff. Let’s say you go skiing for a week with a very expensive camera. In just a few taps, you can insure your camera for a week from your phone.
A key issue for Zurich was to address risks related to driver distraction, thus reducing accidents and saving lives. Zurich’s own jury selected team SafeDrive as their winner, finding their solution based on image recognition to prevent driver distraction, held to be – dare we say it? – the ‘smart’ approach.


Beth Underdown was born in Rochdale and studied English Literature at the University of York. After training as an editor at Phaidon Press, Beth graduated with distinction from the University of Manchester’s Creative Writing MA.
Her first book The Witchfinder’s Sister is set just over the border in Manningtree and based on the life of the 1640s Suffolk-born witchfinder Matthew Hopkins. Beth’s interest in seventeenth-century England was sparked by the work of her great-uncle David Underdown, a foremost historian of the early modern period. She came across a brief mention of Matthew Hopkins while reading a book about midwifery, igniting an interest which turned into an all-consuming hunt for the elusive truth about this infamous killer.
1. Who were your literary influences as you were growing up?
I read Shakespeare’s works when I was eight or nine. I think I was trying to make some kind of point, and it was probably a classic instance of understanding individual words being quite a different thing from understanding a whole text. I loved Austen and the Brontes as a teenager. I read Dodie Smith’s I Capture The Castle, Pat Barker’s Regeneration trilogy and Margaret Atwood’s The Handmaid’s Tale at ages when I was just about ready for them, and each of those books had a big impact on me.
2. Matthew Hopkins was a notorious and evil figure. How did you even begin to find some good in a man who murdered so many women?
I began with thinking that I don’t believe someone could have committed the dreadful acts that Hopkins did if they were happy and contented. If a person isn’t happy, then somewhere along the line there’s a reason why – and I think for writers and readers, that’s where a character’s humanity lives. That’s where you start.
3. Your book is meticulously researched. At what point did you feel the characters start to emerge, particularly Alice?
Bridget was actually the first character to emerge fully. She came over from another project – a couple of chapters of quite a different seventeenth-century novel that I had started and quickly realised wasn’t going anywhere. But Bridget was too noisy to be left behind, and she quickly felt right among the cast of the book I went on to write.
Alice arrived fairly early on as well: bits and pieces of things she thought or felt came to me almost as if someone else had said them. But after that there was a lot of work to do in learning about her and rounding her out.
4. That last sentence is chilling…
Thank you! I admit I felt a bit gleeful writing that one.
5. Can you share anything about your latest project?
My next book is still historical, but set in the more recent past. There are still dark and tense elements to it, but it’s much more about friendship, much more about love. Since I don’t know what’s good for me, the next book is set, once again, a very long drive away from where I live!
6. Do you have a message for your readers in Suffolk Libraries?
Mostly, I’d like to say thank you for reading! I hope my book speaks to you, and feels like a decent telling of this piece of your local history. I’ve loved doing events in the area where the book is set – every audience has been so engaged, and lots of people have their own snippets and anecdotes about Matthew Hopkins and the witch trials, which are great to hear.
7. Given a time machine and the ability to go backwards or forwards what date would you set the clock for and why?
I think it would have been cool to be young in the seventies, when it was maybe a bit easier to be hopeful about the possibility of changing the world hugely for the better. But, purely in terms of the clothes, probably the Victorian period (although I’d have needed a reformer for a husband).
8. Can you describe yourself in three words?
I’m afraid not!


Cardio Monitoring
MediCure theme functionality that was developed with health and medical websites in thought, with all the must-have features included.
Medical Treatment
A fantastic set of 23 custom shortcodes lets you easlily and fast create a highly unique and interactive content for your medical website.
Emergency Help
Custom Services post type allows you display a variety of medical services for a large hospital as well as for a small private clinic.
Emergency Help
Custom Services post type allows you display a variety of medical services for a large hospital as well as for a small private clinic.
Latest Services
-
Pediatric Clinic
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features...
Gynecological Clinic
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Laboratory Analysis
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Cardiac Clinic
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
-
Diagnosis Clinic
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Rehabilitation Therapy
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Medical Counseling
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Psychological Counseling
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought, with all the compulsory for these sites features included.
Latest News
Center for Medical Technology Innovation
Medicure HTML theme was created to offer a perfect solution for medical websites. It features functionality that was developed with health and medicine niche websites in thought.
Nutritional Personal Consultation
You can create a clinic website with Medicure theme, but you can as well use it for many other types of webstes, as it is highly flexible in customization.
Testimonials
-
Frederick
If you are choosing a medical center, Medicure is the one I would recommend. Here you are offered medical treatment of a reliable quality, and a full range of services is offered by a team of professional doctors. Caring staff, new equipment and helpful therapy - definitely, this is a medical center of my choice!
57 years
-
Jeff Blake
Fantastic service and really helpful and caring personnel. I was impressed by pleasant atmosphere and the general assistance. My doctor offered me a very effective treatment and I really did feel significant improvement really soon. I followed all the prescriptions and now I feel great. Greatly thankful to all the staff, and I would definitely recommend this medical center to anyone who medic aid.
32 years
-
Rebecca Martins
My doctor offered me a very effective treatment and I really did feel significant improvement really soon. I followed all the prescriptions and now I feel great. Greatly thankful to all the staff, and I would definitely recommend this medical center to anyone who medic aid. Fantastic service and really helpful and caring personnel. I was impressed by pleasant atmosphere and the general assistance.
29 years
-
Gregory Newman
My doctor offered me a very effective treatment and I really did feel significant improvement really soon. I followed all the prescriptions and now I feel great. Greatly thankful to all the staff, and I would definitely recommend this medical center to anyone who medic aid. Fantastic service and really helpful and caring personnel. I was impressed by pleasant atmosphere and the general assistance.
27 years
Our Doctors
Dr. Karen Dawson
Pediatric Clinic
Dr. Jack Simmons
Cardiac Clinic
Dr. Jack Zerriper
Rehabilitation Therapy
Dr. Michael Linden
Laryngological Clinic


Error!
Try it:
```js run let user = { name: “John”, go: function() { alert(this.name) } }
(user.go)() // error! ```
The error message in most browsers does not give us much of a clue about what went wrong.
The error appears because a semicolon is missing after user = {...}
.
JavaScript does not auto-insert a semicolon before a bracket (user.go)()
, so it reads the code like:
js no-beautify let user = { go:... }(user.go)()
Then we can also see that such a joint expression is syntactically a call of the object { go: ... }
as a function with the argument (user.go)
. And that also happens on the same line with let user
, so the user
object has not yet even been defined, hence the error.
If we insert the semicolon, all is fine:
```js run let user = { name: “John”, go: function() { alert(this.name) } }!;/!
(user.go)() // John ```
Please note that parentheses around (user.go)
do nothing here. Usually they setup the order of operations, but here the dot .
works first anyway, so there’s no effect. Only the semicolon thing matters.


| Package | com.flashdynamix.motion.effects |
| Class | public dynamic class PerlinDisplacementEffect |
| Inheritance | PerlinDisplacementEffect DisplacementEffect FilterEffect flash.utils.Proxy |
| Implements | IEffect |
| Property | Defined by | ||
|---|---|---|---|
| baseX : int = 30
Frequency to use in the x direction.
For example, to generate a noise that is sized for a 64 x 128 image, pass the pixel width of 64 for the baseX value. | PerlinDisplacementEffect | ||
| baseY : int = 40
Frequency to use in the y direction.
For example, to generate a noise that is sized for a 64 x 128 image, pass the pixel height of 128 for the baseY value. | PerlinDisplacementEffect | ||
| channelOptions : uint = 1.0
The Channels which are rendered with the perlin noise :
| PerlinDisplacementEffect | ||
| filter : BitmapFilter
The BitmapFilter to apply onto the BitmapData.
| FilterEffect | ||
| fractalNoise : Boolean = false
If the value is true, the method generates fractal noise; otherwise, it generates turbulence.
| PerlinDisplacementEffect | ||
| grayScale : Boolean = false
Sets the perlin noise to render in grayscale.
| PerlinDisplacementEffect | ||
| mapBmd : BitmapData
The displacement BitmapData to be used.
| DisplacementEffect | ||
| mapPoint : Point
The position of the displacement mapBmd.
| DisplacementEffect | ||
| movement : String [write-only]
Sets the movement type which will be applied on the displacement
These options include :
| PerlinDisplacementEffect | ||
| pt : Point
The Point from which to apply the BitmapFilter
| FilterEffect | ||
| radiusX : Number = 3
The radiusX in pixels to be applied on to the displacement when the movement type is ORBIT.
| PerlinDisplacementEffect | ||
| radiusY : Number = 3
The radiusY in pixels to be applied on to the displacement when the movement type is ORBIT.
| PerlinDisplacementEffect | ||
| seed : int = 1
The random seed number to generate the perlin noise.
| PerlinDisplacementEffect | ||
| speedX : Number = 0.01
The x speed direction the displacement is offsetted by on each render.
The direction depends on the movement type. When the movement type is ORBIT it effects the speed of rotation in the x direction. When the movement type is DIRECTION it effects the offset speed in the x direction. | PerlinDisplacementEffect | ||
| speedY : Number = 0.01
The y speed direction the displacement is offsetted by on each render.
| PerlinDisplacementEffect | ||
| stitch : Boolean = true
If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.
| PerlinDisplacementEffect |
| Method | Defined by | ||
|---|---|---|---|
|
PerlinDisplacementEffect(width:int = 500, height:int = 500, scaleX:Number = 3, scaleY:Number = 3, octives:int = 2)
| PerlinDisplacementEffect | ||
|
render(bmd:BitmapData):void
Renders the PerlinDisplacementEffect on to the specified BitmapData.
| PerlinDisplacementEffect |
| Constant | Defined by | ||
|---|---|---|---|
| DIRECTION : String = "direction" [static]
An option for the movement option on the displacement
This will move the displacement in the x,y direction specified by the speedX and speedY. | PerlinDisplacementEffect | ||
| ORBIT : String = "orbit" [static]
An option for the movement option on the displacement.
This will move the displacement in an orbit path along the radiusX and radiusY. Rotating in an x direction and y direction specified by the speedX and speedY. | PerlinDisplacementEffect |
| baseX | property |
public var baseX:int = 30
Frequency to use in the x direction.
For example, to generate a noise that is sized for a 64 x 128 image, pass the pixel width of 64 for the baseX value.
| baseY | property |
public var baseY:int = 40
Frequency to use in the y direction.
For example, to generate a noise that is sized for a 64 x 128 image, pass the pixel height of 128 for the baseY value.
| channelOptions | property |
public var channelOptions:uint = 1.0
The Channels which are rendered with the perlin noise :
| fractalNoise | property |
public var fractalNoise:Boolean = false
If the value is true, the method generates fractal noise; otherwise, it generates turbulence. An image with turbulence has visible discontinuities in the gradient that can make it better approximate sharper visual effects like flames and ocean waves.
| grayScale | property |
public var grayScale:Boolean = false
Sets the perlin noise to render in grayscale.
| movement | property |
movement:String
[write-only]
Sets the movement type which will be applied on the displacement
These options include :
public function set movement(value:String):void
| radiusX | property |
public var radiusX:Number = 3
The radiusX in pixels to be applied on to the displacement when the movement type is ORBIT.
| radiusY | property |
public var radiusY:Number = 3
The radiusY in pixels to be applied on to the displacement when the movement type is ORBIT.
| seed | property |
public var seed:int = 1
The random seed number to generate the perlin noise.
| speedX | property |
public var speedX:Number = 0.01
The x speed direction the displacement is offsetted by on each render.
The direction depends on the movement type.
When the movement type is ORBIT it effects the speed of rotation in the x direction.
When the movement type is DIRECTION it effects the offset speed in the x direction.
| speedY | property |
public var speedY:Number = 0.01
The y speed direction the displacement is offsetted by on each render.
The direction depends on the movement type.
When the movement type is ORBIT it effects the speed of rotation in the y direction.
When the movement type is DIRECTION it effects the offset speed in the y direction.
| stitch | property |
public var stitch:Boolean = true
If the value is true, the method attempts to smooth the transition edges of the image to create seamless textures for tiling as a bitmap fill.
| PerlinDisplacementEffect | () | constructor |
public function PerlinDisplacementEffect(width:int = 500, height:int = 500, scaleX:Number = 3, scaleY:Number = 3, octives:int = 2)
Parameters
width:int (default = 500 ) — The width in pixels to render the perlin noise.
|
|
height:int (default = 500 ) — The height in pixels to render the perlin noise.
|
|
scaleX:Number (default = 3 ) — The multiplier to use to scale the x displacement result from the map calculation.
|
|
scaleY:Number (default = 3 ) — The multiplier to use to scale the y displacement result from the map calculation.
|
|
octives:int (default = 2 ) — Number of octaves or individual noise functions to combine to create this noise.
|
| render | () | method |
public override function render(bmd:BitmapData):void
Renders the PerlinDisplacementEffect on to the specified BitmapData.
Parametersbmd:BitmapData |
| DIRECTION | constant |
public static const DIRECTION:String = "direction"
An option for the movement option on the displacement
This will move the displacement in the x,y direction specified by the speedX and speedY.
| ORBIT | constant |
public static const ORBIT:String = "orbit"
An option for the movement option on the displacement.
This will move the displacement in an orbit path along the radiusX and radiusY.
Rotating in an x direction and y direction specified by the speedX and speedY.


Plane¶
Geometrical Planes.
Contains¶
Plane
-
class
sympy.geometry.plane.
Plane
[source]¶ A plane is a flat, two-dimensional surface. A plane is the two-dimensional analogue of a point (zero-dimensions), a line (one-dimension) and a solid (three-dimensions). A plane can generally be constructed by two types of inputs. They are three non-collinear points and a point and the plane’s normal vector.
Examples
>>> from sympy import Plane, Point3D >>> from sympy.abc import x >>> Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2)) Plane(Point3D(1, 1, 1), (-1, 2, -1)) >>> Plane((1, 1, 1), (2, 3, 4), (2, 2, 2)) Plane(Point3D(1, 1, 1), (-1, 2, -1)) >>> Plane(Point3D(1, 1, 1), normal_vector=(1,4,7)) Plane(Point3D(1, 1, 1), (1, 4, 7))
Attributes
p1 normal_vector -
angle_between
(o)[source]¶ Angle between the plane and other geometric entity.
Parameters: LinearEntity3D, Plane. Returns: angle : angle in radians Notes
This method accepts only 3D entities as it’s parameter, but if you want to calculate the angle between a 2D entity and a plane you should first convert to a 3D entity by projecting onto a desired plane and then proceed to calculate the angle.
Examples
>>> from sympy import Point3D, Line3D, Plane >>> a = Plane(Point3D(1, 2, 2), normal_vector=(1, 2, 3)) >>> b = Line3D(Point3D(1, 3, 4), Point3D(2, 2, 2)) >>> a.angle_between(b) -asin(sqrt(21)/6)
-
arbitrary_point
(t=None)[source]¶ Returns an arbitrary point on the Plane; varying \(t\) from 0 to 2*pi will move the point in a circle of radius 1 about p1 of the Plane.
Returns: Point3D Examples
>>> from sympy.geometry.plane import Plane >>> from sympy.abc import t >>> p = Plane((0, 0, 0), (0, 0, 1), (0, 1, 0)) >>> p.arbitrary_point(t) Point3D(0, cos(t), sin(t)) >>> _.distance(p.p1).simplify() 1
-
static
are_concurrent
(*planes)[source]¶ Is a sequence of Planes concurrent?
Two or more Planes are concurrent if their intersections are a common line.
Parameters: planes: list Returns: Boolean Examples
>>> from sympy import Plane, Point3D >>> a = Plane(Point3D(5, 0, 0), normal_vector=(1, -1, 1)) >>> b = Plane(Point3D(0, -2, 0), normal_vector=(3, 1, 1)) >>> c = Plane(Point3D(0, -1, 0), normal_vector=(5, -1, 9)) >>> Plane.are_concurrent(a, b) True >>> Plane.are_concurrent(a, b, c) False
-
distance
(o)[source]¶ Distance beteen the plane and another geometric entity.
Parameters: Point3D, LinearEntity3D, Plane. Returns: distance Notes
This method accepts only 3D entities as it’s parameter, but if you want to calculate the distance between a 2D entity and a plane you should first convert to a 3D entity by projecting onto a desired plane and then proceed to calculate the distance.
Examples
>>> from sympy import Point, Point3D, Line, Line3D, Plane >>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1)) >>> b = Point3D(1, 2, 3) >>> a.distance(b) sqrt(3) >>> c = Line3D(Point3D(2, 3, 1), Point3D(1, 2, 2)) >>> a.distance(c) 0
-
equation
(x=None, y=None, z=None)[source]¶ The equation of the Plane.
Examples
>>> from sympy import Point3D, Plane >>> a = Plane(Point3D(1, 1, 2), Point3D(2, 4, 7), Point3D(3, 5, 1)) >>> a.equation() -23*x + 11*y - 2*z + 16 >>> a = Plane(Point3D(1, 4, 2), normal_vector=(6, 6, 6)) >>> a.equation() 6*x + 6*y + 6*z - 42
-
intersection
(o)[source]¶ The intersection with other geometrical entity.
Parameters: Point, Point3D, LinearEntity, LinearEntity3D, Plane Returns: List Examples
>>> from sympy import Point, Point3D, Line, Line3D, Plane >>> a = Plane(Point3D(1, 2, 3), normal_vector=(1, 1, 1)) >>> b = Point3D(1, 2, 3) >>> a.intersection(b) [Point3D(1, 2, 3)] >>> c = Line3D(Point3D(1, 4, 7), Point3D(2, 2, 2)) >>> a.intersection(c) [Point3D(2, 2, 2)] >>> d = Plane(Point3D(6, 0, 0), normal_vector=(2, -5, 3)) >>> e = Plane(Point3D(2, 0, 0), normal_vector=(3, 4, -3)) >>> d.intersection(e) [Line3D(Point3D(78/23, -24/23, 0), Point3D(147/23, 321/23, 23))]
-
is_coplanar
(o)[source]¶ Returns True if \(o\) is coplanar with self, else False.
Examples
>>> from sympy import Plane, Point3D >>> o = (0, 0, 0) >>> p = Plane(o, (1, 1, 1)) >>> p2 = Plane(o, (2, 2, 2)) >>> p == p2 False >>> p.is_coplanar(p2) True
-
is_parallel
(l)[source]¶ Is the given geometric entity parallel to the plane?
Parameters: LinearEntity3D or Plane Returns: Boolean Examples
>>> from sympy import Plane, Point3D >>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6)) >>> b = Plane(Point3D(3,1,3), normal_vector=(4, 8, 12)) >>> a.is_parallel(b) True
-
is_perpendicular
(l)[source]¶ is the given geometric entity perpendicualar to the given plane?
Parameters: LinearEntity3D or Plane Returns: Boolean Examples
>>> from sympy import Plane, Point3D >>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6)) >>> b = Plane(Point3D(2, 2, 2), normal_vector=(-1, 2, -1)) >>> a.is_perpendicular(b) True
-
normal_vector
¶ Normal vector of the given plane.
Examples
>>> from sympy import Point3D, Plane >>> a = Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2)) >>> a.normal_vector (-1, 2, -1) >>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 4, 7)) >>> a.normal_vector (1, 4, 7)
-
p1
¶ The only defining point of the plane. Others can be obtained from the arbitrary_point method.
See also
Examples
>>> from sympy import Point3D, Plane >>> a = Plane(Point3D(1, 1, 1), Point3D(2, 3, 4), Point3D(2, 2, 2)) >>> a.p1 Point3D(1, 1, 1)
-
parallel_plane
(pt)[source]¶ Plane parallel to the given plane and passing through the point pt.
Parameters: pt: Point3D Returns: Plane Examples
>>> from sympy import Plane, Point3D >>> a = Plane(Point3D(1, 4, 6), normal_vector=(2, 4, 6)) >>> a.parallel_plane(Point3D(2, 3, 5)) Plane(Point3D(2, 3, 5), (2, 4, 6))
-
perpendicular_line
(pt)[source]¶ A line perpendicular to the given plane.
Parameters: pt: Point3D Returns: Line3D Examples
>>> from sympy import Plane, Point3D, Line3D >>> a = Plane(Point3D(1,4,6), normal_vector=(2, 4, 6)) >>> a.perpendicular_line(Point3D(9, 8, 7)) Line3D(Point3D(9, 8, 7), Point3D(11, 12, 13))
-
perpendicular_plane
(*pts)[source]¶ Return a perpendicular passing through the given points. If the direction ratio between the points is the same as the Plane’s normal vector then, to select from the infinite number of possible planes, a third point will be chosen on the z-axis (or the y-axis if the normal vector is already parallel to the z-axis). If less than two points are given they will be supplied as follows: if no point is given then pt1 will be self.p1; if a second point is not given it will be a point through pt1 on a line parallel to the z-axis (if the normal is not already the z-axis, otherwise on the line parallel to the y-axis).
Parameters: pts: 0, 1 or 2 Point3D Returns: Plane Examples
>>> from sympy import Plane, Point3D, Line3D >>> a, b = Point3D(0, 0, 0), Point3D(0, 1, 0) >>> Z = (0, 0, 1) >>> p = Plane(a, normal_vector=Z) >>> p.perpendicular_plane(a, b) Plane(Point3D(0, 0, 0), (1, 0, 0))
-
projection
(pt)[source]¶ Project the given point onto the plane along the plane normal.
Parameters: Point or Point3D Returns: Point3D Examples
>>> from sympy import Plane, Point, Point3D >>> A = Plane(Point3D(1, 1, 2), normal_vector=(1, 1, 1))
The projection is along the normal vector direction, not the z axis, so (1, 1) does not project to (1, 1, 2) on the plane A:
>>> b = Point(1, 1) >>> A.projection(b) Point3D(5/3, 5/3, 2/3) >>> _ in A True
But the point (1, 1, 2) projects to (1, 1) on the XY-plane:
>>> XY = Plane((0, 0, 0), (0, 0, 1)) >>> XY.projection((1, 1, 2)) Point3D(1, 1, 0)
-
projection_line
(line)[source]¶ Project the given line onto the plane through the normal plane containing the line.
Parameters: LinearEntity or LinearEntity3D Returns: Point3D, Line3D, Ray3D or Segment3D Notes
For the interaction between 2D and 3D lines(segments, rays), you should convert the line to 3D by using this method. For example for finding the intersection between a 2D and a 3D line, convert the 2D line to a 3D line by projecting it on a required plane and then proceed to find the intersection between those lines.
Examples
>>> from sympy import Plane, Line, Line3D, Point, Point3D >>> a = Plane(Point3D(1, 1, 1), normal_vector=(1, 1, 1)) >>> b = Line(Point(1, 1), Point(2, 2)) >>> a.projection_line(b) Line3D(Point3D(4/3, 4/3, 1/3), Point3D(5/3, 5/3, -1/3)) >>> c = Line3D(Point3D(1, 1, 1), Point3D(2, 2, 2)) >>> a.projection_line(c) Point3D(1, 1, 1)
-


From Python3 onwards
map
no longer returns a list but a mapObject
, thus the answer will look something like
>>> map(lambda x:x.strip(),l)
<map object at 0x7f00b1839fd0>
You can read more about it here
map()
andfilter()
return iterators. If you really need alist
, a quick fix is e.g.list(map(...))
So now what are the ways of getting trough this?
Case 1 - The list
call over map
with a lambda
map
returns an iterator. list
is a function that can convert an iterator to a list. Hence you will need to wrap a list
call around map
. So the answer now becomes,
>>> l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n']
>>> list(map(lambda x:x.strip(),l))
['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3']
Very good, we get the output. Now we check the amount of time it takes for this piece of code to execute.
$ python3 -m timeit "l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n'];list(map(lambda x:x.strip(),l))"
100000 loops, best of 3: 2.22 usec per loop
2.22 microseconds. That is not so bad. But are there more efficient ways?
Case 2 - The list
call over map
withOUT a lambda
lambda
is frowned upon by many in the Python community (including Guido). Apart from that it will greatly reduce the speed of the program. Hence we need to avoid that as much as possible. The toplevel function str.strip
. Comes to our aid here.
The map
can be re-written without using lambda
using str.strip
as
>>> list(map(str.strip,l))
['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3']
And now for the times.
$ python3 -m timeit "l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n'];list(map(str.strip,l))"
1000000 loops, best of 3: 1.38 usec per loop
Fantastic. You can see the efficiency differences between the two ways. It is nearly 60% faster. Thus the approach without using a lambda
is a better choice here.
Case 3 - Following Guidelines, The Regular way
Another important point from What’s New In Python 3.0 is that it advices us to avoid map
where possible.
Particularly tricky ismap()
invoked for the side effects of the function; the correct transformation is to use a regularfor
loop (since creating a list would just be wasteful).
So we can solve this problem without a map
by using a regular for
loop.
The trivial way of solving (the brute-force) would be:-
>>> l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n']
>>> final_list = []
>>> for i in l:
... final_list.append(i.strip())
...
>>> final_list
['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3']
The timing setup
def f():
l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n']
final_list = []
for i in l:
final_list.append(i.strip())
import timeit
print(min(timeit.repeat("f()","from __main__ import f")))
And the result.
1.5322505849981098
As you can see the brute-force is a bit slower here. But it is definitely more readable to a common programmer than a map
clause.
Case 4 - List Comprehensions
A list comprehension here is also possible and is the same as in Python2.
>>> [i.strip() for i in l]
['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3']
Now for the timings:
$ python3 -m timeit "l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n'];[i.strip() for i in l]"
1000000 loops, best of 3: 1.28 usec per loop
As you can see the list-comprehension is more effective than map
(even that without a lambda
). Hence the thumb rule in Python3 is to use a list comprehension instead of map
Case 5 - In-Place mechanisms and Space Efficiency (T-M-T)
A final way is to make the changes in-place within the list itself. This will save a lot of memory space. This can be done using enumerate
.
>>> l = ['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3\n']
>>> for i,s in enumerate(l):
... l[i] = s.strip()
...
>>> l
['Name1', '7.3', '6.9', '6.6', '6.6', '6.1', '6.4', '7.3']
The timing result would be 1.4806894720022683
. But however this way is space effective.
Conclusion
A comparitive list of timings (Both Python 3.4.3 and Python 3.5.0)
| Case | method | Py3.4 | Place | Py3.5 | Place |
|---|---|---|---|---|---|
| 1 | map with lambda | 2.22u | 5 | 2.85u | 5 |
| 2 | map w/o lambda | 1.38u | 2 | 2.00u | 2 |
| 3 | brute-force | 1.53u | 4 | 2.22u | 4 |
| 4 | list comp | 1.28u | 1 | 1.25u | 1 |
| 5 | in-place | 1.48u | 3 | 2.14u | 3 |
Finally note that the list-comprehension is the best way and the map
using lambda
is the worst. But again --- ONLY IN PYTHON3


JBattleCity
Your browser does not support Java applets
Use arrows for moving and Caps Lock for shooting


Try out our Premium Member services: Virtual Legal Assistant, Query Alert Service and an ad-free experience. Free for one month and pay only if you like it.
1 IN THE HIGH COURT OF KARNATAKA AT BANGALORE DATED THIS THE 30TH DAY OF JULY 2014 PRESENT THE HON'BLE MR.JUSTICE N.KUMAR AND THE HON'BLE MR.JUSTICE B.MANOHAR WP No.14000/2008 (GM-POL-PIL) BETWEEN: 1. U.K.District Consumers & Citizen Welfare Association, R/b.its President, Sri.K.R.Desai, Advocate & Notary, Age 51 years, S/o.R.U.Desai, R/a.Sadashivgad, Karwar- 581 301. Uttara Kannada District. 2. The Fundamental Facilities & Anti-Corruption Awarness Society, Karwar, R/b. by its President, Sri.Vishwamber.K.Talekar, Age 65 years, S/o.Komarse Talekar, R/a.Main Road, Karwar - 581 301. Uttara Kannada District. 2 3. Karnataka Sanvarakshana Sangh, R/b.its President, Mr.Prabhakar Mhalsekar, Age 60 years, s/o.Sairu Mahasekar, Mhalsa Road, Kajubag, Karwar - 581 301. Uttara Kannada District. 4. Mr.Vijay Kumar.G.Patil, Age 67 years, S/o.Ganesh Patil, Social Worker, Aligadda, Baithol, Karwar - 581 301. Uttara Kannada District. 5. Binga Citizen Forum, R/b.Honourary Secretary, Mr.Vishnu Harikantra, Age 54 years, Occ: Fisherman, Aligadda, Baithol, Karwar - 581 301. Uttara Kannada District. 6. Sri.M.K.Pandrekar, Age 52 years, S/o.Khema Pandrekar, Social Worker, Kodibag, Karwar - 581 303. Uttara Kannada District. 7. Mr.Datta Govind Vetalkar, Age 52 years, 3 S/o.Govind Vetallor, Social Worker, Occ: Fisherman, Belekeri, Ankola, Uttara Kannada District. 8. Dr.M.M.Sayed, Age 65 years, S/o.Khedar Basha, Belekeri, Ankola, Uttara Kannada District. 9. Mr.Ashok Pednekar, Age 54 years, S/o.Budya Pednekar, Social Worker, Belekerei, Ankola, Uttara Kannada District. 10. Sri.V.K.Nayak, Age 75 years, S/o.Krishna Nayak, Binga Village, Karwar- 581 301. Uttara Kannada District. ...PETITIONERS (By Sri.Prasad.A.Pednekar, Adv., for P1, P6 & P9; Sri.Harish Bhandary, Adv., as Amicus Curiae; Smt.Sujatha, AGA for R1) AND: 1. State of Karnataka, Rep. by its Chief Secretary, Department of Ecology, Environment & Forests, Vidhana Soudha, Dr.Ambedkar Veedhi, Bangalore - 01. 4 2. Karnataka State Environment Pollution Control Board, Rep. by its Secretary, M.G.Road, Bangalore. 3. Union of India, Ministry of Environment & Forests, Dept. Of Environment, Forests & Wildlife, New Delhi. 4. Deputy Commissioner and District Magistrate, Uttara Kannada District, Karwar - 581 301. 5. The Adhyaksha, Zilla Panchayat, Uttara Kannada District, Karwar Taluk, Karwar - 581 301. 6. The Adyaksha, Taluk Panchayat, Ankola Taluk, Ankola - 581 115. Uttara Kannada District. 7. Regional Transport Officer, Karwar - 581 301. Uttara Kannada District. 8. Executive Engineer., National Highway, Karwar - 581 301. 5 Uttara Kannada District. 9. Regional Officer, KSPCB, Karwar - 581 301. Uttara Kannada District. 10. Deputy Director, Department of Mines & Geology, Karwar - 581 301. Uttara Kannada District. 11. Director of Ports, I.W.T.Karwar - 581 301. Uttara Kannada District. 12. The Port Officer, Karwar, Uttara Kannada District. 13. Balekeri Grama Panchayat, Balekeri, Ankola Taluk, Ankola, Uttara Kannada District. 14. The Superintendent of Police, Karwar - 581 301. Uttara Kannada District. 15. M/s.Alvares & Thomas Stevarders, Fowarders & Customs House Agent, Old Port Office, Baithkol, Karwar - 581 301. R/b.Mr.Gabried Sydney Manager, Karwar Office, Karwar - 581 301. 6 Uttara Kannada District. 16. M/s.J.M.Baxi & Co., Shopping Agents & Stevarders, Shri.Datta Prasad Complex, Ground Floor, Dr.Pikle Road, Karwar - 581 301. Uttara Kannada District. 17. M/s.Dream Logistics Company (India) Pvt. Ltd., Transporters, Handling Contractors & Exporters, Opp: Karwar Port Gate, Baithkol, Karwar - 581 301. Uttara Kannada District. 18. M/s.Muneer Enterprises, Aligadda, Baithkol, Uttara Kannada District. R/b.Mr.Musheer Ahmed, Manager, Karwar Branch. 19. M/s.VSL Minig Company, Aligadda, Baithkol, Karwar - 581 301. Uttara Kannada District. 20. M/s.Core Minerals, Aligadda, Baithkola, Karwar - 581 301. Uttara Kannada District. R/b.Ms.Jayashree, Manager, 7 Karwar Branch. 21. M/s.Suvan Logistics Company Shipping & Clearing Agents, Mahimangalam Complex, Sai Mandir Road, Karwar - 581 301. Uttara Kannada District. R/b.Ms.Pradeep Hulgekar, Manager, Karwar Branch. 22. M/s.M.S.P.L. C/o.Port Officer, Baithkol, Karwar - 581 301. Uttara Kannada District. 23. M/s.Kikra Logistics, C/o.Port Officer, Karwar - 581 301. Uttara Kannada District. 24. M/s.Adani Enterprises Ltd., Belekeri Port, Ankola, Uttara Kannada District. 25. M/s.Mallikarjun Shipping (P) Ltd. Belekeri Post, Ankola, Uttara Kannada District. 26. M/s.Salgaonkar Mining Industries Ltd., Belekeri Post, Ankola, 8 Uttara Kannada District. 27. M/s.Rajmahal Silks, Belekeri Port, Ankola, Uttara Kannada District. 28. Under Secretary, Government of Karnataka, Mines, Commerce & Industries Department, Vidhana Soudha, Dr.Ambedkar Veedhi, Bangalore - 01. 29. The Commissioner for Mines & Geological Resources, Mines & Geology Department, Khanija Bhavan, Devaraj Urs Road, Bangalore - 560 001. 30. National Highways Authority of India, Ministry of Shipping, Road Transport & Highways, Rep. by its Secretary, G 5 & 6, Sector - 10. Dwarka, New Delhi - 110075. ...RESPONDENTS (As per Order dated 17.6.10 petition against Respondent Nos.19, 20 & 23 are dismissed) (By Sri.Gururaj Joshi, Adv., for R2; Sri.Jagadish Chandra Hulsoor, Adv., for R3; R4 Served; 9 Sri.Ashok.N.Nayak, Adv., for R5; R6, R7, R8, R9, R10, R11, R12, R13 & R14 are served; Sri.Dayanand.S.Naik, Adv., for R15 to R18, R21 & 27; R19, 20 & 23 are deleted vide court dated 17.6.2010; Sri.K.Shashikiran Shetty, Adv., for R22; Sri.B.Pramod, Adv., for R24; Smt.Akka Mahadevi Hiremath, Adv., for R25; Sri.Basava Prabhu.S.Patil, Assts., for R26; R28, 29 are Served; Singhania & Partners, Adv., for R30) ****** This writ petition is filed under Articles 226 and 227 of the Constitution of India praying to direct the respondent No.11 and 12 not to permit the respondents 15 to 27 or others to stack and transport the iron and manganese ore within the territory of Karwar Post and Belekeri port Area in any mode and etc., This WP coming on for Orders this day, N.KUMAR. J., made the following: ORDER
This writ petition is filed by way of public interest litigation by the residents of Uttara Kannada District in the State of Karnataka complaining of violation of their fundamental right as well as violation of the provisions of 10 the Environment (Protection) Act, 1986 and the provisions of the Air (Prevention and Control of Pollution) Act, 1981. They sought the following prayers:
1. Grant a writ of mandamus directing the respondent No.11 and 12 not to permit the respondents 15 to 27 or any others to stack and transport the Iron and Manganese Ore within the territory of Karwar post and Belekeri Port area in any mode.
2. Kindly grant a Writ of Injunction restraining the respondent firms 15 to 27 and others from running the business of transportation, movement and stacking of iron ore and manganese ore in Uttara Kannada District.
3. Grant a Writ of Mandamus directing the respondents to implement the govt. notification dated 21.9.2005, No.CL31: MMM 2005 in its letter and spirit.
4. Grant a writ of injunction restraining respondents 11 and 12 or any other from giving 11 permission to the respondents 15 to 27 firms for further expansion of areas used for dumping ore.
5. Grant a writ of mandamus directing the respondents to evict the respondents 15 to 27 or any others carrying on similar such business on from Belade Island, Ankola District coast forthwith;
6. Grant a writ of mandamus directing the respondents to maintain Belade Islands as a natural island.
7. Grant a writ of mandamus directing the respondents 15 to 27 to pay compensation to the surrounding residents on the principle of "polluter pays".
8. Kindly pass any other writ or order as the Hon'ble Court deems fit in the circumstances of the case in the interest of justice, by moulding the relief/s.
2. This petition was instituted on 6.11.2008. After service of notice, the respondents have entered 12 appearance. From time to time, interim orders were passed by this Court against the authorities to act in terms of the aforesaid provisions of the Act. Accordingly, they have acted. The learned counsel for the petitioners submits prayer Nos.1, 2, 3, 4, 5 and 8 do not survive for consideration as all these prayers have been complied with. Now their grievance is only regarding prayer Nos.6 and 7.
3. During the pendency of this writ petition, the Parliament has enacted the National Green Tribunal Act, 2010 providing for the establishment of the National Green Tribunal for the effective and expeditious disposal of cases relating to environmental protection and conservation of forests and other natural resources including enforcement of any legal right relating to environment and giving relief and compensation for damages to persons and property and for matters connected therewith or incidental thereto. In pursuance of the said Act, the Central Government has established the National Green Tribunal presided by a 13 retired Judge of the Supreme Court of India. Taking note of this law, the Hon'ble Apex Court in the case of BHOPAL GAS PEEDITH MAHILA UDYOG SANGATHAN & Ors., vs. UNION OF INDIA & Ors., reported in (2012) 8 SCC page 326, at paras 40 and 41 has held as under:-
"40. Keeping in view the provisions and scheme of the National Green Tribunal Act, 2010 (for short the 'NGT Act') particularly Sections 14, 29, 30 and 38(5), it can safely be concluded that the environmental issues and matters covered under the NGT Act, Schedule 1 should be instituted and litigated before the National Green Tribunal (for short 'NGT'). Such approach may be necessary to avoid likelihood of conflict of orders between the High Courts and the NGT. Thus, in unambiguous terms, we direct that all the matters instituted after coming into force of the NGT Act and which are covered under the provisions of the NGT Act and/or in Schedule I to the NGT Act shall stand transferred and can be instituted only before the NGT. This will help in rendering expeditious and specialized 14 justice in the field of environment to all concerned.
41. We find it imperative to place on record a caution for consideration of the courts of competent jurisdiction that the cases filed and pending prior to coming into force of the NGT Act, involving questions of environmental laws and/or relating to any of the seven statutes specified in Schedule 1 of the NGT Act, should also be dealt with the specialized tribunal, that is the NGT, created under the provisions of the NGT Act. The Courts may be well advised to direct transfer of such cases to the NGT in its discretion, as it will be in the fitness of administration of justice."
4. The National Green Tribunal Act came into force in the year 2010. Schedule I to the National Green Tribunal Act reads as under:-
[See sections 14(1), 15(1), 17(1)(a), 17(2), 19(4)(j) and 34(1)]
1. The Water (Prevention and Control of Pollution Act, 1974;
15
2. The Water (Prevention and Control of Pollution) Cess Act, 1977;
3. The Forest (Conservation) Act, 1980;
4. The Air (Prevention and Control of Pollution Act, 1981;
5. The Environment (Protection) Act, 1986;
6. The Public Liability Insurance Act, 1991;
7. The Biological Diversity Act, 2002.
5. The subject matter of this case falls within the enactment mentioned in Schedule I to the National Green Tribunal Act. As the National Green Tribunal Act came into force after the institution of proceedings, in view of the aforesaid observation of the Hon'ble Supreme Court of India, this writ petition has to be transferred to the National Green Tribunal constituted under the National Green Tribunal Act.
In these circumstances, we pass the following order: (1) For the reasons stated above, the writ petition is disposed of.
16(2) The High Court registry is directed to transfer this writ petition to the National Green Tribunal constituted under the National Green Tribunal Act 2010.
Sd/-
JUDGE Sd/-
JUDGE Bss.