Using CodeIgniter’s Model¶
Models¶
Models provide a way to interact with a specific table in your database. They come out of the box with helper methods for much of the standard ways you would need to interact with a database table, including finding records, updating records, deleting records, and more.
Accessing Models¶
Models are typically stored in the app/Models
directory. They should have a namespace that matches their
location within the directory, like namespace App\Models
.
You can access models within your classes by creating a new instance or using the model()
helper function.
// Create a new class manually
$userModel = new \App\Models\UserModel();
// Create a new class with the model function
$userModel = model('App\Models\UserModel', false);
// Create a shared instance of the model
$userModel = model('App\Models\UserModel');
// Create shared instance with a supplied database connection
// When no namespace is given, it will search through all namespaces
// the system knows about and attempt to located the UserModel class.
$db = db_connect('custom');
$userModel = model('UserModel', true, $db);
CodeIgniter’s Model¶
CodeIgniter does provide a model class that provides a few nice features, including:
- automatic database connection
- basic CRUD methods
- in-model validation
- automatic pagination
- and more
This class provides a solid base from which to build your own models, allowing you to rapidly build out your application’s model layer.
Creating Your Model¶
To take advantage of CodeIgniter’s model, you would simply create a new model class
that extends CodeIgniter\Model
:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
// ...
}
This empty class provides convenient access to the database connection, the Query Builder, and a number of additional convenience methods.
Connecting to the Database¶
When the class is first instantiated, if no database connection instance is passed to the constructor,
it will automatically connect to the default database group, as set in the configuration. You can
modify which group is used on a per-model basis by adding the DBGroup property to your class.
This ensures that within the model any references to $this->db
are made through the appropriate
connection.
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $DBGroup = 'group_name';
}
You would replace “group_name” with the name of a defined database group from the database configuration file.
Configuring Your Model¶
The model class has a few configuration options that can be set to allow the class’ methods to work seamlessly for you. The first two are used by all of the CRUD methods to determine what table to use and how we can find the required records:
<?php
namespace App\Models;
use CodeIgniter\Model;
class UserModel extends Model
{
protected $table = 'users';
protected $primaryKey = 'id';
protected $useAutoIncrement = true;
protected $returnType = 'array';
protected $useSoftDeletes = true;
protected $allowedFields = ['name', 'email'];
protected $useTimestamps = false;
protected $createdField = 'created_at';
protected $updatedField = 'updated_at';
protected $deletedField = 'deleted_at';
protected $validationRules = [];
protected $validationMessages = [];
protected $skipValidation = false;
}
$table
Specifies the database table that this model primarily works with. This only applies to the built-in CRUD methods. You are not restricted to using only this table in your own queries.
$primaryKey
This is the name of the column that uniquely identifies the records in this table. This
does not necessarily have to match the primary key that is specified in the database, but
is used with methods like find()
to know what column to match the specified value to.
Note
All Models must have a primaryKey specified to allow all of the features to work as expected.
$useAutoIncrement
Specifies if the table uses an auto-increment feature for $primaryKey
. If set to false
then you are responsible for providing primary key value for every record in the table. This
feature may be handy when we want to implement 1:1 relation or use UUIDs for our model.
Note
If you set $useAutoIncrement
to false
then make sure to set your primary
key in the database to unique
. This way you will make sure that all of Model’s features
will still work the same as before.
$returnType
The Model’s CRUD methods will take a step of work away from you and automatically return the resulting data, instead of the Result object. This setting allows you to define the type of data that is returned. Valid values are ‘array’, ‘object’, or the fully qualified name of a class that can be used with the Result object’s getCustomResultObject() method.
$useSoftDeletes
If true, then any delete* method calls will set deleted_at
in the database, instead of
actually deleting the row. This can preserve data when it might be referenced elsewhere, or
can maintain a “recycle bin” of objects that can be restored, or even simply preserve it as
part of a security trail. If true, the find* methods will only return non-deleted rows, unless
the withDeleted() method is called prior to calling the find* method.
This requires either a DATETIME or INTEGER field in the database as per the model’s
$dateFormat setting. The default field name is deleted_at
however this name can be
configured to any name of your choice by using $deletedField property.
$allowedFields
This array should be updated with the field names that can be set during save, insert, or update methods. Any field names other than these will be discarded. This helps to protect against just taking input from a form and throwing it all at the model, resulting in potential mass assignment vulnerabilities.
$useTimestamps
This boolean value determines whether the current date is automatically added to all inserts and updates. If true, will set the current time in the format specified by $dateFormat. This requires that the table have columns named ‘created_at’ and ‘updated_at’ in the appropriate data type.
$createdField
Specifies which database field to use for data record create timestamp.
Leave it empty to avoid updating it (even if $useTimestamps
is enabled)
$updatedField
Specifies which database field should use for keep data record update timestamp. Leave it empty to avoid update it (even useTimestamps is enabled)
$dateFormat
This value works with $useTimestamps and $useSoftDeletes to ensure that the correct type of date value gets inserted into the database. By default, this creates DATETIME values, but valid options are: datetime, date, or int (a PHP timestamp). Using ‘useSoftDeletes’ or ‘useTimestamps’ with an invalid or missing dateFormat will cause an exception.
$validationRules
Contains either an array of validation rules as described in How to save your rules or a string containing the name of a validation group, as described in the same section. Described in more detail below.
$validationMessages
Contains an array of custom error messages that should be used during validation, as described in Setting Custom Error Messages. Described in more detail below.
$skipValidation
Whether validation should be skipped during all inserts
and updates
. The default
value is false, meaning that data will always attempt to be validated. This is
primarily used by the skipValidation()
method, but may be changed to true
so
this model will never validate.
$beforeInsert $afterInsert $beforeUpdate $afterUpdate $afterFind $afterDelete
These arrays allow you to specify callback methods that will be run on the data at the time specified in the property name.
$allowCallbacks
Whether the callbacks defined above should be used.
Working With Data¶
Finding Data¶
Several functions are provided for doing basic CRUD work on your tables, including find(), insert(), update(), delete() and more.
find()
Returns a single row where the primary key matches the value passed in as the first parameter:
$user = $userModel->find($user_id);
The value is returned in the format specified in $returnType.
You can specify more than one row to return by passing an array of primaryKey values instead of just one:
$users = $userModel->find([1,2,3]);
If no parameters are passed in, will return all rows in that model’s table, effectively acting like findAll(), though less explicit.
findColumn()
Returns null or an indexed array of column values:
$user = $userModel->findColumn($column_name);
$column_name should be a name of single column else you will get the DataException.
findAll()
Returns all results:
$users = $userModel->findAll();
This query may be modified by interjecting Query Builder commands as needed prior to calling this method:
$users = $userModel->where('active', 1)
->findAll();
You can pass in a limit and offset values as the first and second parameters, respectively:
$users = $userModel->findAll($limit, $offset);
first()
Returns the first row in the result set. This is best used in combination with the query builder.
$user = $userModel->where('deleted', 0)
->first();
withDeleted()
If $useSoftDeletes is true, then the find* methods will not return any rows where ‘deleted_at IS NOT NULL’. To temporarily override this, you can use the withDeleted() method prior to calling the find* method.
// Only gets non-deleted rows (deleted = 0)
$activeUsers = $userModel->findAll();
// Gets all rows
$allUsers = $userModel->withDeleted()
->findAll();
onlyDeleted()
Whereas withDeleted() will return both deleted and not-deleted rows, this method modifies the next find* methods to return only soft deleted rows:
$deletedUsers = $userModel->onlyDeleted()
->findAll();
Saving Data¶
insert()
An associative array of data is passed into this method as the only parameter to create a new row of data in the database. The array’s keys must match the name of the columns in a $table, while the array’s values are the values to save for that key:
$data = [
'username' => 'darth',
'email' =><EMAIL_ADDRESS>];
$userModel->insert($data);
update()
Updates an existing record in the database. The first parameter is the $primaryKey of the record to update. An associative array of data is passed into this method as the second parameter. The array’s keys must match the name of the columns in a $table, while the array’s values are the values to save for that key:
$data = [
'username' => 'darth',
'email' =><EMAIL_ADDRESS>];
$userModel->update($id, $data);
Multiple records may be updated with a single call by passing an array of primary keys as the first parameter:
$data = [
'active' => 1
];
$userModel->update([1, 2, 3], $data);
When you need a more flexible solution, you can leave the parameters empty and it functions like the Query Builder’s update command, with the added benefit of validation, events, etc:
$userModel
->whereIn('id', [1,2,3])
->set(['active' => 1])
->update();
save()
This is a wrapper around the insert() and update() methods that handle inserting or updating the record automatically, based on whether it finds an array key matching the $primaryKey value:
// Defined as a model property
$primaryKey = 'id';
// Does an insert()
$data = [
'username' => 'darth',
'email' =><EMAIL_ADDRESS>];
$userModel->save($data);
// Performs an update, since the primary key, 'id', is found.
$data = [
'id' => 3,
'username' => 'darth',
'email' =><EMAIL_ADDRESS>];
$userModel->save($data);
The save method also can make working with custom class result objects much simpler by recognizing a non-simple object and grabbing its public and protected values into an array, which is then passed to the appropriate insert or update method. This allows you to work with Entity classes in a very clean way. Entity classes are simple classes that represent a single instance of an object type, like a user, a blog post, job, etc. This class is responsible for maintaining the business logic surrounding the object itself, like formatting elements in a certain way, etc. They shouldn’t have any idea about how they are saved to the database. At their simplest, they might look like this:
namespace App\Entities;
class Job
{
protected $id;
protected $name;
protected $description;
public function __get($key)
{
if (property_exists($this, $key))
{
return $this->$key;
}
}
public function __set($key, $value)
{
if (property_exists($this, $key))
{
$this->$key = $value;
}
}
}
A very simple model to work with this might look like:
use CodeIgniter\Model;
class JobModel extends Model
{
protected $table = 'jobs';
protected $returnType = '\App\Entities\Job';
protected $allowedFields = [
'name', 'description'
];
}
This model works with data from the jobs
table, and returns all results as an instance of App\Entities\Job
.
When you need to persist that record to the database, you will need to either write custom methods, or use the
model’s save()
method to inspect the class, grab any public and private properties, and save them to the database:
// Retrieve a Job instance
$job = $model->find(15);
// Make some changes
$job->name = "Foobar";
// Save the changes
$model->save($job);
Note
If you find yourself working with Entities a lot, CodeIgniter provides a built-in Entity class that provides several handy features that make developing Entities simpler.
Deleting Data¶
delete()
Takes a primary key value as the first parameter and deletes the matching record from the model’s table:
$userModel->delete(12);
If the model’s $useSoftDeletes value is true, this will update the row to set deleted_at
to the current
date and time. You can force a permanent delete by setting the second parameter as true.
An array of primary keys can be passed in as the first parameter to delete multiple records at once:
$userModel->delete([1,2,3]);
If no parameters are passed in, will act like the Query Builder’s delete method, requiring a where call previously:
$userModel->where('id', 12)->delete();
purgeDeleted()
Cleans out the database table by permanently removing all rows that have ‘deleted_at IS NOT NULL’.
$userModel->purgeDeleted();
Validating Data¶
For many people, validating data in the model is the preferred way to ensure the data is kept to a single
standard, without duplicating code. The Model class provides a way to automatically have all data validated
prior to saving to the database with the insert()
, update()
, or save()
methods.
The first step is to fill out the $validationRules
class property with the fields and rules that should
be applied. If you have custom error message that you want to use, place them in the $validationMessages
array:
class UserModel extends Model
{
protected $validationRules = [
'username' => 'required|alpha_numeric_space|min_length[3]',
'email' => 'required|valid_email|is_unique[users.email]',
'password' => 'required|min_length[8]',
'pass_confirm' => 'required_with[password]|matches[password]'
];
protected $validationMessages = [
'email' => [
'is_unique' => 'Sorry. That email has already been taken. Please choose another.'
]
];
}
The other way to set the validation rules to fields by functions,
-
setValidationRule
($field, $fieldRules)¶ Parameters: - $field (string) –
- $fieldRules (array) –
This function will set the field validation rules.
Usage example:
$fieldName = 'username'; $fieldRules = 'required|alpha_numeric_space|min_length[3]'; $model->setValidationRule($fieldName, $fieldRules);
-
setValidationRules
($validationRules)¶ Parameters: - $validationRules (array) –
This function will set the validation rules.
Usage example:
$validationRules = [ 'username' => 'required|alpha_numeric_space|min_length[3]', 'email' => [ 'rules' => 'required|valid_email|is_unique[users.email]', 'errors' => [ 'required' => 'We really need your email.', ], ], ]; $model->setValidationRules($validationRules);
The other way to set the validation message to fields by functions,
-
setValidationMessage
($field, $fieldMessages)¶ Parameters: - $field (string) –
- $fieldMessages (array) –
This function will set the field wise error messages.
Usage example:
$fieldName = 'name'; $fieldValidationMessage = [ 'required' => 'Your name is required here', ]; $model->setValidationMessage($fieldName, $fieldValidationMessage);
-
setValidationMessages
($fieldMessages)¶ Parameters: - $fieldMessages (array) –
This function will set the field messages.
Usage example:
$fieldValidationMessage = [ 'name' => [ 'required' => 'Your baby name is missing.', 'min_length' => 'Too short, man!', ], ]; $model->setValidationMessages($fieldValidationMessage);
Now, whenever you call the insert()
, update()
, or save()
methods, the data will be validated. If it fails,
the model will return boolean false. You can use the errors()
method to retrieve the validation errors:
if ($model->save($data) === false)
{
return view('updateUser', ['errors' => $model->errors()]);
}
This returns an array with the field names and their associated errors that can be used to either show all of the errors at the top of the form, or to display them individually:
<?php if (! empty($errors)) : ?>

<?php foreach ($errors as $field => $error) : ?>

<?= $error ?>

<?php endforeach ?>

<?php endif ?>
If you’d rather organize your rules and error messages within the Validation configuration file, you can do that
and simply set $validationRules
to the name of the validation rule group you created:
class UserModel extends Model
{
protected $validationRules = 'users';
}
Retrieving Validation Rules¶
You can retrieve a model’s validation rules by accessing its validationRules
property:
$rules = $model->validationRules;
You can also retrieve just a subset of those rules by calling the accessor method directly, with options:
$rules = $model->getValidationRules($options);
The $options
parameter is an associative array with one element,
whose key is either “except” or “only”, and which has as its
value an array of fieldnames of interest.:
// get the rules for all but the "username" field
$rules = $model->getValidationRules(['except' => ['username']]);
// get the rules for only the "city" and "state" fields
$rules = $model->getValidationRules(['only' => ['city', 'state']]);
Validation Placeholders¶
The model provides a simple method to replace parts of your rules based on data that’s being passed into it. This
sounds fairly obscure but can be especially handy with the is_unique
validation rule. Placeholders are simply
the name of the field (or array key) that was passed in as $data surrounded by curly brackets. It will be
replaced by the value of the matched incoming field. An example should clarify this:
protected $validationRules = [
'email' => 'required|valid_email|is_unique[users.email,id,{id}]'
];
In this set of rules, it states that the email address should be unique in the database, except for the row that has an id matching the placeholder’s value. Assuming that the form POST data had the following:
$_POST = [
'id' => 4,
'email' =><EMAIL_ADDRESS>];
then the {id}
placeholder would be replaced with the number 4, giving this revised rule:
protected $validationRules = [
'email' => 'required|valid_email|is_unique[users.email,id,4]'
];
So it will ignore the row in the database that has id=4
when it verifies the email is unique.
This can also be used to create more dynamic rules at runtime, as long as you take care that any dynamic keys passed in don’t conflict with your form data.
Protecting Fields¶
To help protect against Mass Assignment Attacks, the Model class requires that you list all of the field names
that can be changed during inserts and updates in the $allowedFields
class property. Any data provided
in addition to these will be removed prior to hitting the database. This is great for ensuring that timestamps,
or primary keys do not get changed.
protected $allowedFields = ['name', 'email', 'address'];
Occasionally, you will find times where you need to be able to change these elements. This is often during testing, migrations, or seeds. In these cases, you can turn the protection on or off:
$model->protect(false)
->insert($data)
->protect(true);
Working With Query Builder¶
You can get access to a shared instance of the Query Builder for that model’s database connection any time you need it:
$builder = $userModel->builder();
This builder is already set up with the model’s $table. If you need access to another table you can pass it in as a parameter, but be aware that this will not return a shared instance:
$groupBuilder = $userModel->builder('groups');
You can also use Query Builder methods and the Model’s CRUD methods in the same chained call, allowing for very elegant use:
$users = $userModel->where('status', 'active')
->orderBy('last_login', 'asc')
->findAll();
Note
You can also access the model’s database connection seamlessly:
$user_name = $userModel->escape($name);
Runtime Return Type Changes¶
You can specify the format that data should be returned as when using the find*() methods as the class property, $returnType. There may be times that you would like the data back in a different format, though. The Model provides methods that allow you to do just that.
Note
These methods only change the return type for the next find*() method call. After that, it is reset to its default value.
asArray()
Returns data from the next find*() method as associative arrays:
$users = $userModel->asArray()->where('status', 'active')->findAll();
asObject()
Returns data from the next find*() method as standard objects or custom class intances:
// Return as standard objects
$users = $userModel->asObject()->where('status', 'active')->findAll();
// Return as custom class instances
$users = $userModel->asObject('User')->where('status', 'active')->findAll();
Processing Large Amounts of Data¶
Sometimes, you need to process large amounts of data and would run the risk of running out of memory. To make this simpler, you may use the chunk() method to get smaller chunks of data that you can then do your work on. The first parameter is the number of rows to retrieve in a single chunk. The second parameter is a Closure that will be called for each row of data.
This is best used during cronjobs, data exports, or other large tasks.
$userModel->chunk(100, function ($data)
{
// do something.
// $data is a single row of data.
});
Model Events¶
There are several points within the model’s execution that you can specify multiple callback methods to run. These methods can be used to normalize data, hash passwords, save related entities, and much more. The following points in the model’s execution can be affected, each through a class property: $beforeInsert, $afterInsert, $beforeUpdate, $afterUpdate, $afterFind, and $afterDelete.
Defining Callbacks¶
You specify the callbacks by first creating a new class method in your model to use. This class will always receive a $data array as its only parameter. The exact contents of the $data array will vary between events, but will always contain a key named data that contains the primary data passed to the original method. In the case of the insert* or update* methods, that will be the key/value pairs that are being inserted into the database. The main array will also contain the other values passed to the method, and be detailed later. The callback method must return the original $data array so other callbacks have the full information.
protected function hashPassword(array $data)
{
if (! isset($data['data']['password']) return $data;
$data['data']['password_hash'] = password_hash($data['data']['password'], PASSWORD_DEFAULT);
unset($data['data']['password'];
return $data;
}
Specifying Callbacks To Run¶
You specify when to run the callbacks by adding the method name to the appropriate class property (beforeInsert, afterUpdate, etc). Multiple callbacks can be added to a single event and they will be processed one after the other. You can use the same callback in multiple events:
protected $beforeInsert = ['hashPassword'];
protected $beforeUpdate = ['hashPassword'];
Additionally, each model may allow (default) or deny callbacks class-wide by setting its $allowCallbacks property:
protected $allowCallbacks = false;
You may also change this setting temporarily for a single model call sing the allowCallbacks()
method:
$model->allowCallbacks(false)->find(1); // No callbacks triggered
$model->find(1); // Callbacks subject to original property value
Event Parameters¶
Since the exact data passed to each callback varies a bit, here are the details on what is in the $data parameter passed to each event:
| Event | $data contents |
|---|---|
| beforeInsert | data = the key/value pairs that are being inserted. If an object or Entity class is passed to the insert method, it is first converted to an array. |
| afterInsert | id = the primary key of the new row, or 0 on failure. data = the key/value pairs being inserted. result = the results of the insert() method used through the Query Builder. |
| beforeUpdate | id = the array of primary keys of the rows being updated. data = the key/value pairs that are being inserted. If an object or Entity class is passed to the insert method, it is first converted to an array. |
| afterUpdate | id = the array of primary keys of the rows being updated. data = the key/value pairs being updated. result = the results of the update() method used through the Query Builder. |
| beforeFind | The name of the calling method, whether a singleton was requested, and these additional fields: |
|
No additional fields |
|
id = the primary key of the row being searched for. |
|
limit = the number of rows to find. offset = the number of rows to skip during the search. |
| afterFind | Same as beforeFind but including the resulting row(s) of data, or null if no result found. |
| beforeDelete | Varies by delete* method. See the following: |
|
id = primary key of row being deleted. purge = boolean whether soft-delete rows should be hard deleted. |
| afterDelete | id = primary key of row being deleted. purge = boolean whether soft-delete rows should be hard deleted. result = the result of the delete() call on the Query Builder. data = unused. |
Modifying Find* Data¶
The beforeFind
and afterFind
methods can both return a modified set of data to override the normal response
from the model. For afterFind
any changes made to data
in the return array will automatically be passed back
to the calling context. In order for beforeFind
to intercept the find workflow it must also return an additional
boolean, returnData
:
protected $beforeFind = ['checkCache'];
// ...
protected function checkCache(array $data)
{
// Check if the requested item is already in our cache
if (isset($data['id']) && $item = $this->getCachedItem($data['id']]))
{
$data['data'] = $item;
$data['returnData'] = true;
return $data;
// ...
Manual Model Creation¶
You do not need to extend any special class to create a model for your application. All you need is to get an instance of the database connection and you’re good to go. This allows you to bypass the features CodeIgniter’s Model gives you out of the box, and create a fully custom experience.
<?php
namespace App\Models;
use CodeIgniter\Database\ConnectionInterface;
class UserModel
{
protected $db;
public function __construct(ConnectionInterface &$db)
{
$this->db = &$db;
}
}


Do you have competition you detest, do you want to make a defacement page and .... get this .... blame someone else for the attack LOL... Then book us discretely in your retainer and we will Dark Basin the S*** out of your competition.
Please note that due to COVID-19, we ar eextremely busy with our backlog and as such we may not be able tofulfill your orders in a timely manner ,,, please be patient with us as we will run our job bookings in a FIFO manner
Please note bc1qxy2kgdygjrsqtzq2n0yrf2493p83kkfjhx0wlh is our bitcoin wallet. Do not Google our wallet as we had some bad press it fake... Send us your details and we will be sure to complete your intended mission once funds have been cleared.


My name is David Perez. I took this course to learn a new paradim of
Web Full Stack Development. My main goal is learn as much as possible the Front-End,
as well as, Back-End server side. If you have any questions or comments to how
improve my knowledge let me know. Thanks and Good Luck.
If you need more information follow up me here: https://www.linkedin.com/in/davedevelopmentusa/


Twitter @macloo
Flickr macloo
GitHub macloo
This reminds me of 1994, when I learned HTML. Except now, we can round our corners. And make a wrapper div that changes width to fit your device's screen size. Still, then as now, simple pages provide a kind of satisfaction that over-the-top pages never do.
Minimalism. I like it.


FIRST ALERT: Strong low pressure system expected to bring dangerous winds
by Dave OliverAMARILLO, Texas (KFDA) - We are tracking a very strong low pressure system that will affect our region tomorrow.
This system will generate some intense wind and could cause sustained winds in the 30-40 mph range with gusts over 6 0mph.
A High Wind Watch has been issued as well as a Fire Weather Watch for most of our area.
Loose items and decorations should be secured around your home and travel could be very dangerous for high profile vehicles.
The threat for wildfires will be significant and precautions should be taken to prevent starting fires.
Stay updated with the latest information on the winter weather with our First Alert Weather Team here.
Get weather coverage all winter long on the NewsChannel 10 app. You can download that here.
You can also watch NewsChannel 10 live on Roku and Amazon Fire 24/7.
Do you have weather photos you want to share with us? Upload them here to be featured on our website and in our apps:


Welcome to captcha portal, we have redirected you to this page for showcasing captcha example! Hope you wold like this!


The Geometry Library contains geometry classes and algorithms, which
are separated from each other. This page describes the geometry
classes.
Geometry classes are templatized in many ways:
point coordinate values can be defined using numeric types as
double,
float or
int.
Linestrings can have points of the type above,
types derived from these point types or point types defined by the library user. Points are contained in containers of
type std::vector or another std:: container type.
OGC made standards on those geometries, and called them
simple
features.
The Geometry Library follows the OGC names for the naming of
the classes.
The Geometry Library defines the following OGC geometries:
point |
A point, having coordinates of type T Currently x() and y(), will be changed based on boost list discussions! |
linestring |
An ordered series of points of type
P. The linestring is default a std::vector of points, but can also
be a std::list or std::deque of points |
linear_ring |
An ordered and closed series of
points of type P. As with the linestring, it is default but not always
a std::vector |
polygon |
An outer ring and zero, one or more
inner
rings (holes).
|
multi_point |
A collection of points
|
multi_linestring |
A collection of linestrings (for
example: the output of the clipping of one linestring can result in a
multi_linestring)
|
multi_polygon |
A collection of polygons
|
The following geometry types are used in the Geometry Library, but not
defined by OGC:
circle |
A circle (consisting of a center
and a radius, used for selections (within) ) |
box |
A box (consisting of a minimum
point and a maximum point, used for selections and clipping) |
segment |
A line from point "first" to point
"second", used in some algorithms |
There is one traits class:
geometry_traits |
Defines the type used as
coordinates, and the type used for the points, with their names
coordinate_type
and point_type |
WILL BE CHANGED! THERE WILL BE MORE GENERIC POINT CONCEPT/BASECLASS and specializations for x/y and lat/lon or other
The point is defined like this:
template <typename
T>
class point
{
public :
typedef T
coordinate_type;
// rest omitted, will be changed
};
The point that is defined by the Geometry Library contains methods to
access and modify coordinates, which can be doubles, floats,
ints or another numeric type. Furthermore there are some constructors
available and there are some operators to compare points. Basically
that's everything there is.
However, that doesn't mean that other points are not possible. A user can
derive points from this point to add for example an SRID
(spatial reference ID), a property map, or anything
else. Or a user can implement point class with, for
example, latitude and longitude. Those classes are accepted by the
algorithms which are in the library, as long as they support
the methods above. In fact they don't need to support them
all: if only algorithms are used which access coordinate values, such
as
within,
then the two methods which modify coordinate values are not necessary.
If there are no algorithms used which sort the points, they don't have
to be defined. The compiler will tell if the class fits the algorithm.
The usage of points is trivial:
geometry::point<double>
p1;
geometry::point<double>
p2(3.14, 8.2);
geometry::point<char>
p3(5, 8);
// will be changed!
geometry::point<double>::coordinate_type
x = p1.x();
The geometry traits class is a small class defining two member
types. All geometry classes, but point, are derived from the geometry
traits class.
template <typename P>
class geometry_traits
{
public :
typedef P point_type;
typedef typename
P::coordinate_type coordinate_type;
};
A linestring is an ordered series of points. Here is an example of a
linestring with 5 points.
You might expect a
shorter name
line
here, but the name
linestring
is defined by OGC and the Geometry Library follows this definition.
The Geometry Library defines a linestring, by design, as small as
possible, it is a container of points and for the rest an empty class:
template <typename P, template
<typename,typename> class V = std::vector,
template<typename> class A = std::allocator>
class linestring : public V, public geometry_traits

{
};
The definition might seem somewhat cryptic, therefore it can be seen as this definition, its default:
template <typename P>
class linestring : public
std::vector

{
};
It is just a vector or another container of points, and
contains the two member types point_type
and coordinate_type
defined by the geometry traits class.
A linestring can be used like this:
geometry::linestring<geometry::point<double>
> ls;
ls.push_back(geometry::point<double>(1.2,
5.8));
Because a linestring is a container, you can call the
std:: algorithms on containers.
In most cases you will first do a typedef of the point type
you want to use:
typedef
MyPoint<double> P;
geometry::linestring
 ls;
If you prefer other container types you can use a linestring like this:
geometry::linestring
 ls1;
geometry::linestring
 ls2;
A polygon contains an outer ring and zero, one or more inner rings.
Inner
rings are, in general, also called holes, donuts, or interior
of in the polygon. The outer
ring
is the exterior boundary. The example below shows a polygon with one
inner ring.
Rings in polygons are normally directed:
the outer ring is clockwise, the inner rings are counterclockwise.
Some algorithms depend on this order and there is an algorithm to
ensure that a polygon has the right order.
The interface is the following:
template <typename P, template <typename,typename>
class V = std::vector, template<typename> class A =
std::allocator>
class polygon : public
geometry_traits

{
public :
// Member types
typedef linear_ring
 ring_type;
typedef V<ring_type ,
A<ring_type > > inner_container_type;
const ring_type& outer() const;
const inner_container_type &
inners() const;
ring_type& outer();
inner_container_type & inners();
void clear();
};
A polygon can be used like this:
geometry::polygon<geometry::point<double>
>
polygon;
polygon.outer().push_back(geometry::point<double>(1.2,
5.8));
A multi point is a set of points, for example a constellation. As a
linestring, it is empty.
template <typename P, template <typename,typename>
class V = std::vector, template<typename> class A =
std::allocator>
class multi_point : public V, public geometry_traits

{
};
However, it is not the same as a linestring: you can not calculate the length, for example.
A multi linestring is a set of linestrings, for example a road.
template <typename L, template <typename,typename>
class V = std::vector, template<typename> class A =
std::allocator>
class multi_linestring : public
V<L, A<L> >, public
geometry_traits<typename L::point_type>
{
public:
typedef L linestring_type;
};
A multi polygons is a set of polygons, for example the state Hawaii.
This is a multi polygon, containing two polygons:
A multi polygon is defined as follows:
template <typename Y, template <typename,typename>
class V = std::vector, template<typename> class A =
std::allocator>
class multi_polygon : public V<Y,
A<Y> >, public geometry_traits<typename
Y::point_type>
{
public :
typedef Y polygon_type;
};
A box is not defined as such by OGC but useful in many algorithms. The
Geometry Library defines a box by a minimum point and a maximum point.
template <typename P>
class box : public
geometry_traits

{
box();
box(const P& min,
const P& max)
//
Constructor with an option, for example geometry::init_inverse
box(init option);
const P& min() const;
const P& max() const;
P& min();
P& max();
};
The main purpose of a circle is to be able to select, for example,
points or lines with a circle. There is no full support on circle in
most algorithms, you cannot intersect polygons with circles for example.
A circle consists a point and a radius.
template <typename P, typename T>
class circle :
geometry_traits

{
public :
typedef T radius_type;
circle();
circle(const P&
center, const T& radius);
circle(const
coordinate_type& x, const coordinate_type& y, const
T& radius);
const P& center()
const;
const T radius() const;
void radius(const T&
r);
P& center();
};


{{formatTime(consoleLog.timestamp)}}{{ consoleLog.message }}
If this is the error contact the pages administrators
LogoutCouldnt register eventsoruce to remote server. This could be caused by a connection problem with your device, or the server is down. For more info check the doc page for this error.


|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object jml.optimization.LBFGS
public class LBFGS
A Java implementation for the limited-memory BFGS algorithm. It is a general algorithm interface, only gradient and objective function value are needed to compute outside the class.
A simple example:
double epsilon = ...; // Convergence tolerance
RealMatrix W = ...; // Initial matrix (vector) you want to optimize
RealMatrix G = ...; // Gradient at the initial matrix (vector) you want to optimize
double fval = ...; // Initial objective function value
boolean flags[] = null;
while (true) {
  flags = LBFGS.run(G, fval, epsilon, W); // Update W in place
  if (flags[0]) // flags[0] indicates if L-BFGS converges
    break;
  fval = ...; // Compute the new objective function value at the updated W
  if (flags[1]) // flags[1] indicates if gradient at the updated W is required
    G = ...; // Compute the gradient at the new W
}
| Field Summary | |
|---|---|
private static double |
alpha
|
private static double |
beta
|
private static boolean |
converge
If the algorithm converges or not. |
private static double |
fval
The last objective function value. |
private static org.apache.commons.math.linear.RealMatrix |
G
Current gradient. |
private static org.apache.commons.math.linear.RealMatrix |
G_pre
Last gradient. |
private static boolean |
gradientRequired
If gradient is required for the next step. |
private static double |
H
|
private static java.util.ArrayList<java.lang.Double> |
J
An array holding the sequence of objective function values. |
private static int |
k
Iteration counter. |
private static int |
m
|
private static org.apache.commons.math.linear.RealMatrix |
p
Decreasing step. |
private static double |
rou_k
|
private static java.util.LinkedList<java.lang.Double> |
rou_ks
|
private static org.apache.commons.math.linear.RealMatrix |
s_k
|
private static java.util.LinkedList<org.apache.commons.math.linear.RealMatrix> |
s_ks
|
private static int |
state
State for the automata machine. |
private static double |
t
Step length for backtracking line search. |
private static org.apache.commons.math.linear.RealMatrix |
X
Current matrix variable that we want to optimize. |
private static org.apache.commons.math.linear.RealMatrix |
X_pre
Last matrix variable that we want to optimize. |
private static org.apache.commons.math.linear.RealMatrix |
y_k
|
private static java.util.LinkedList<org.apache.commons.math.linear.RealMatrix> |
y_ks
|
private static double |
z
A temporary variable holding the inner product of the decreasing step p and the gradient G, it should be always non-positive. |
| Constructor Summary | |
|---|---|
LBFGS()
|
| Method Summary | |
|---|---|
static boolean[] |
run(org.apache.commons.math.linear.RealMatrix Grad_t,
double fval_t,
double epsilon,
org.apache.commons.math.linear.RealMatrix X_t)
Main entry for the LBFGS algorithm. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
private static org.apache.commons.math.linear.RealMatrix G
private static org.apache.commons.math.linear.RealMatrix G_pre
private static org.apache.commons.math.linear.RealMatrix X
private static org.apache.commons.math.linear.RealMatrix X_pre
private static org.apache.commons.math.linear.RealMatrix p
private static double fval
private static boolean gradientRequired
private static boolean converge
private static int state
private static double t
private static double z
private static int k
private static double alpha
private static double beta
private static int m
private static double H
private static org.apache.commons.math.linear.RealMatrix s_k
private static org.apache.commons.math.linear.RealMatrix y_k
private static double rou_k
private static java.util.LinkedList<org.apache.commons.math.linear.RealMatrix> s_ks
private static java.util.LinkedList<org.apache.commons.math.linear.RealMatrix> y_ks
private static java.util.LinkedList<java.lang.Double> rou_ks
private static java.util.ArrayList<java.lang.Double> J
| Constructor Detail |
|---|
public LBFGS()
| Method Detail |
|---|
public static boolean[] run(org.apache.commons.math.linear.RealMatrix Grad_t, double fval_t, double epsilon, org.apache.commons.math.linear.RealMatrix X_t)
Grad_t
- gradient at original X_t, required on the
first revocationfval_t
- objective function value on original X_tepsilon
- convergence precisionX_t
- current matrix variable to be optimized, will be
updated in place to a better solution point with
lower objective function value
boolean
array with two elements: {converge, gradientRequired}
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |


This demo demonstrates the Custom element DateTimeInput's range selection mode. Click on a date to select the start date and then click on another cell to select the end date.


Search Images
5.1 Search for an Image
If you want to search the specific picture you want to view, click search picture button from the profile page.
To achieve this search a key words search bar and time period search bar are provided.
Also provided, are radio buttons which allows you to select the sort order. The orders are:
- Most recent first, Most recent last, Most relevant and popularity.
To search, you can choose to search by:
- Keywords, search by time period or search by both conditions.
- The result will be displayed in the order that you selected.
- For more details of the Most relevant order, it is specified by
the rank function, the higher value the rank function is,the higher the picture will be displayed
- We set highest weight on subject, medium weight on place and lowest weight on descriptions
*Remember to complete at least one of the search boxes and check one of the orders provided


I. LANGUAGE:Values
EVERYTHING has a type. But scala has type inference
val a = "string"
//val a:String
val b = List(("to" , ("Where", "go?")))
// b: List[(String, (String, String))] <-- sugared
// b: List[Tuple2[String, Tuple2[String, String]]]
No-dot notation is acceptable
val a = 3
val b = 4
a.+(b) == a + b //true
I. LANGUAGE:Operators
Using special characters for function names, override arithmetical operation is acceptable
case class Path(path:String) {
def /(d:String):String = {
path+"/"+d
}
}
println(Path("/home") / "user1")
I. LANGUAGE:Import
import b.B
class HelloWorld{
import a.A
def sum = A+B
}
I. LANGUAGE:everything has a type
val cake = if(x>1) 25
What type does cake have?
Any
I. LANGUAGE:prefer immutable
Is list changed?
No, to make it changeable you need to use class mutable.List
val list = List("mimi")
"lily" :: list
Using immutable List is still effective, as soon as you use effective operations
Elements are reused
I. LANGUAGE: companion objects
and apply
Companion objects are object and class with same name
Companion can access private methods of other companion
Should be declared in a same file
class Lol (reason:String) {
private def getReason = reason
}
object Lol{
def apply(s:String):Lol = {
new Lol(s)
}
def analyzeState(lol:Lol) {
if(lol.getReason == "irony"){
println("cool")
} else {
println("not cool")
}
}
}
I. LANGUAGE: companion objects
and apply
...
val myLol = Lol("irony")
println(myLol)
Lol.analyzeState(myLol)//cool
Lol.analyzeState(Lol("happiness"))//not cool
I. LANGUAGE:pattern matching
With some magic of extracting...
val head :: tail = List("hello", "world","any")
print(head+"-")
tail match {
case b :: c => print(b+":"+c)
}
What is a result?
I. LANGUAGE:IF
val desire = if(person.gender="male") "beer" else "strawberry"
What is functional about it?
It returns a value, so it has type, so it is a function
I. LANGUAGE:FOR
Many standard classes can work nicely with for
for(i<- 1 to 20) print(i)
// (1 to 20) : Range.Inclusive
for(value<- valueOption)
print("will be printed out if i was set"+i)
// valueOption: Option[Int]
val lolypop =
for (f1<- future1, f2<- future2) yield f1+f2
//future1 and future2 :Future[Int]
I. LANGUAGE: FOR
for is more complex than you think. It's a syntactic sugar over function
composition
for (bound <- list) yield f(bound)
// is
list map f
//lets try to rewrite it back
val btw = for{
a <- list1; b <- list2
} yield a+b
How can we translate this?
// nice, isn't it?
btw = list1.map(a => list2.map(b=>a+b))
I. LANGUAGE: FOR
for is an universal computation evaluator. lets refactor 'callback nightmare' of asynchronous computations
def currentUser: Future[User] = ???
def getBasket(user: User): Future[Basket] = ???
def addSteamBox(basket: Basket): Future[Int] = ???
def sendResponse(msg:String) {}
val userFuture = currentUser
userFuture.onSuccess{
case user => {
val basketFuture = getBasket(user)
basketFuture.onSuccess{
case basket => {
val itemsCountFuture = addSteamBox(basket)
itemsCountFuture.onSuccess{
case itemsCount => {
sendResponse("Items: "+itemsCount)
}
}
itemsCountFuture.onFailure{
case e => sendResponse(e.toString)
}
}
}
basketFuture.onFailure{
case e => sendResponse(e.toString)
}
}
}
userFuture.onFailure{
case e => sendResponse(e.toString)
}
I. LANGUAGE: FOR
Because of for magic we can do
val result = for {
user <- currentUser
basket <- getBasket(user)
itemsCount <- addSteamBox(basket)
} yield {
sendResponse("Items: "+itemsCount)
}
for (e <- result.failed){
sendResponse(e.toString)
}
Spolier alert:
for has a type, it is a function
I.LANGUAGE:higher order functions
A function over other function.
It might either take function as a parameter or return a function
def applyFunction(predicate:Int=>Boolean) = {
def sum(v1:Int, v2:Int) = {
( if(predicate(v1)) v1 else 0 + v2).toString
}
sum _
}
def predicate(value:Int):Boolean = value > 10
println(applyFunction(predicate)(25, 40))
println(applyFunction(predicate)(5, 40))
applyFunction is higher order function. What is going to appear on screen?
65
40
I.LANGUAGE:Partial function
In mathematical sense
val div: PartialFunction[(Double, Double), Double] = {
case (x, y) if y != 0 => x /y
}
div.isDefinedAt(1, 0)
false
I.LANGUAGE:Lazy
Of course Scala has this feature
lazy val x = {
print("(computing x) ")
"hey"
}
print("x = ")
println(x)
What is going to be printed?
x = (computing x) "hey"
Real example:
case class Employee(id: Int, name: String, managerId: Int) {
lazy val manager: Employee = Db.get(managerId)
lazy valteam: List[Employee] = Db.team(id)
}
I.LANGUAGE:higher order functions
"pimp my library" pattern is the way collections have huge amount of HOF
map
filter
collect
foldLeft/Right
take
drop
find
takeWhile
dropWhile
slice
sliding(stepSkip, stepTake)
flatten
partition
head/headOpt
tail
count
max/min
maxBy/minBy
sort/sortBy
collectFirst
par
view
force
seq
etc...
II.Types.Creating type
primary constructor
In scala you have a single enter point to a class
object Book{
def fromString(s:String):Book = {
val values = s.split(',')
require(values.length>1)
new Book(values(0), UUID.fromString(values(1)))
}
}
class Book(author: String, id: UUID) {
require(!author.isEmpty)
require(id !=null && id.toString.length>0)
def this(author: String) = {
this(author, UUID.randomUUID())
}
override def toString(): String = {
"Book(" + author + "," + id.toString.take(2) + ")"
}
}
println(new Book("Lermontov"))// Book(Lermontov,3c)
println(new Book("Lomonosov", UUID.randomUUID()))
// Book(Lomonosov,c9)
println(
Book.fromString("Greboedov,1fa6615f-ec61-4255-9307-d628c8e4e4c8"))
// Book(Greboedov,1f)
// new Book("")
II.Types.Case classes
Case classes are domain objects
case class Person(name:String, surname:String="Lee")
Person("Yui") // Person(Yui,Li)
Person("John", "Doe") // Person(John,Doe)
This methods are implemented out of the box for case classes
val p= Person("Bruce")
println(p.name)//Bruce
println(p.toString)//Person(Bruce,Lee)
println(p.hashCode())//980329485
val p2 = p.copy() //deep copy
println(p.copy(name="Brandon")) //Person(Brandon,Lee)
println(p == p2)//true
println(p.eq(p2))//false
println(p.productArity)//2
// + companion object with apply and unapply
II.Types.Extractors
How does pattern matching works?
object Person {
def unapply(p: Person) : Option[Pair[String, String]]
= Some((p.name, p.surname))
}
//..
Person("Nio") match {
case Person("Me", a) => println(a) // Lee
}
Standard monads. The problem
public void activeAccountBalance(id:UUID){
BigDecimal value =
customer.getAccount(id).getActiveBankAccount().getBalance()
}//can you do something like that in real system?
// well maybe you recognize this one?
if(id != null && !id.isEmpty()) {
if(customer != null) {
Account account = customer.getAccount(id);
if(account!= null){
if(account.getActiveBankAccount()!=null){
return account.getActiveBankAccount().getBalance()
}
}
}
}
return null; //Issue is that the code is ugly
You think, maybe early returns are better?
if(id == null || id.isEmpty()) return null;
if(customer == null) return null;
Account account = customer.getAccount(id);
if(account == null) return null;
if (account.getActiveBankAccount() == null) return null;
return account.getActiveBankAccount().getBalance()
UGLY!
My first reaction was: does Scala offer something else is i still use nulls?..
NO
Listen to Mr. Mackey
Option
Lets assume we have data like that, requested from db
val id:UUID = ..//
val customers = Option(
List(
Customer(id,
Option(Accounts(
List(Account(true, Option(BigDecimal("20"))),
Account(false, Option(BigDecimal("25")))))))
)
)
Option
flatMap oneliner
def getActiveAccountBalance(idOption: Option[UUID]):BigDecimal = {
val balanceOpt = idOption.map(id => customers.flatMap(db => db.find(_.id == id).flatMap(c => c.accounts.flatMap(a => a.getActive.flatMap( active=> active.balance)))))
balanceOpt getOrElse BigDecimal(0)
}
Why not map? Why flatMap?
Option[Option[Option[Option[Option[Option[scala.BigDecimal]]]]]]
Option
for
def getActiveAccountBalance(idOption: Option[UUID]):BigDecimal = {
val bOpt = for {
id <-idOption
fromDb <- customers
customer <- fromDb.find(_.id == id)
accounts <- customer.accounts
active <- accounts.getActive
balance <- active.balance
} yield balance
bOpt getOrElse BigDecimal(0)
}
Beautiful


{% extends 'base.html' %} {% block title %} {{ board.name }} - {{ block.super }} {% endblock %} {% block breadcrumb %}
Reservation deleted successfully


{% extends "layout.html" %} {% block page_title %} Confirmation page example {% endblock %} {% block content %} {% include "includes/phase_banner_beta.html" %} {{formData | safe}} Your check code is: 1A7Q5K8S This code is valid for 21 days and can only be used once Print check code {% include "includes/share_codes.html" %} {% endblock %}
Your check code is:
This code is valid for 21 days and can only be used once
Print check code


AJ Almaguer
Projects
Contact
Projects
About
Contact
menu
Projects
{{project.name}}
{{project.description}}
{{keyword.keyword}}
Visit
Github Repo


class ControllerCollector(builtins.object) |
| |
The controller object for data collection pipeline. Responsible
for triggering and monitoring the daily streaming data collection
from all data sources.
:member attributes: logger: logger instance
config: config file path
:member functions: data_collect_pipeline |
| |
Methods defined here:
- __init__(self, config_file)
- Initialize self. See help(type(self)) for accurate signature.
- data_collection_pipeline(self)
- Method to call the data collector modules to retreive latest
data.
: param self
: return ret_val(int)
Data descriptors defined here:
- __dict__
- dictionary for instance variables (if defined)
- __weakref__
- list of weak references to the object (if defined)
|


I work on iPhone product and product marketing as part of the WWPM team at Apple. Previously, I spent time at TED and Vimeo, where I led the product teams behind Vimeo's native applications on mobile and TV, the public API, and the efforts to make Vimeo a platform where 3rd-party developers can be successful.
I graduated from the University of Puget Sound, where I majored in International Political Economy and minored in Business. If you would like to get in touch, shoot me an email or encrypted message.


Preparation time
less than 30 mins
Cooking time
10 to 30 mins
Serves
Serves 4
A simple, great tasting combination of mackerel and fresh greens with a sweet chilli zing.
Place the mackerel on a baking sheet and use a chef's blowtorch to quickly cook the mackerel (alternatively cook them under a very hot grill for a few minutes).
Bring a large saucepan of water to the boil, then add the pak choi and string beans to blanch for 30 seconds. Drain, then transfer into very cold water to stop the cooking. Drain again and pat dry.
 Cook on the hot griddle for a couple of minutes on each side until lightly charred. Remove the pak choi and keep warm. Drizzle a little oil over the string beans and griddle them for a few minutes until lightly charred.
For the chilli jam, put all the chilli jam ingredients, except the sugar and crème fraîche, in a food processor and blend to a smooth purée.
Heat the sugar in a heavy-based saucepan over a low to medium heat until it melts and forms a golden-brown caramel. Do not stir and keep an eye on it so that it doesn’t burn.
Once the sugar has caramelised, carefully pour in the puréed chilli jam mixture and stir well (the mixture will bubble up a lot, so take care). Bring the mixture to the boil, then reduce the heat and simmer for 4-5 minutes, or until sticky and jam-like. Remove from the heat and set aside to cool slightly.
To serve, place a fillet of mackerel on one side of the plate and serve the pak choi and beans on the side. Drizzle the chilli jam over the fish and garnish with the coriander cress and a spoon of crème fraîche.


| First Name : | {{ currentDriver.first_name }} |
|---|---|
| Middle Name : | {{ currentDriver.middle_name }} |
| Last Name : | {{ currentDriver.last_name }} |
| Gender : | {{ currentDriver.gender }} |
| Birth Day : | {{ currentDriver.birthday }} |
| Phone : | {{ currentDriver.phone }} |
| Email : | {{ currentDriver.email}} |
| Address : | {{ currentDriver.current_address }} |
| Employment Date : | {{ currentDriver.employment_date }} |
| Drivers Licence : | {{ currentDriver.driving_licence_class }} |
Are you sure you want to delete Driver with Reg # {{ currentDriver.registration_number }} created at {{ currentDriver.created_at }}
| # | {{ title }} | |||||
|---|---|---|---|---|---|---|
| {{$index+1}} | {{ object.first_name}} | {{ object.middle_name}} | {{ object.last_name}} | {{ object.gender}} | {{ object.phone}} | {{ object.driving_licence_class}} |


vignettes/staining_consistency_report.Rmd
staining_consistency_report.Rmd
The staining consistency report measures variation in the mean expression of a single marker across multiple images. It is used to assess consistency of staining within or across staining runs.
When analyzing slides from a single staining run, this report can highlight inconsistent staining and suggest that autostainer maintenance is needed.
When analyzing slides from multiple runs of an assay, the report can indicate changes in assay performance over time.
The input to this report is a merged cell seg data file from inForm containing data about the samples to measure.
Click the “Browse” button in the “Select Merge Data” section of the GUI. Use the file selection dialog to select the file containing your merge data.
In general, a good result will have a relatively narrow range of mean values, limited outliers beyond the ±1 SD range, and a CV less than 15%.
A wide range of mean values, outliers far outside the ±1 SD range, or CV greater than 15% indicates a possible problem.
If the slides are from a single staining run, the autostainer may need maintenance.
If the slides are from multiple runs, the variation may be due to one of these causes:
This analysis assumes that assay performance has been monitored over time under the same operating conditions, as much as is practicable.


Earth
Mars
Jupiter
Saturn
Planets
NASA
More about NASA
Photo of the Day
Copyright:
Yesterday's Photo
Copyright:


Laravel is built with unit testing in mind. In fact, support for testing with PHPUnit is included out of the box, and a phpunit.xml
file is already setup for your application. In addition to PHPUnit, Laravel also utilizes the Symfony HttpKernel, DomCrawler, and BrowserKit components to allow you to inspect and manipulate your views while testing, allowing to simulate a web browser.
An example test file is provided in the app/tests
directory. After installing a new Laravel application, simply run phpunit
on the command line to run your tests.

To create a test case, simply create a new test file in the app/tests
directory. The test class should extend TestCase
. You may then define test methods as you normally would when using PHPUnit.
class FooTest extends TestCase {
public function testSomethingIsTrue()
{
$this->assertTrue(true);
}
}
You may run all of the tests for your application by executing the phpunit
command from your terminal.
Note: If you define your own
setUp
method, be sure to callparent::setUp
.

When running unit tests, Laravel will automatically set the configuration environment to testing
. Also, Laravel includes configuration files for session
and cache
in the test environment. Both of these drivers are set to array
while in the test environment, meaning no session or cache data will be persisted while testing. You are free to create other testing environment configurations as necessary.

You may easily call one of your routes for a test using the call
method:
$response = $this->call('GET', 'user/profile');
$response = $this->call($method, $uri, $parameters, $files, $server, $content);
You may then inspect the Illuminate\Http\Response
object:
$this->assertEquals('Hello World', $response->getContent());
You may also call a controller from a test:
$response = $this->action('GET', 'HomeController@index');
$response = $this->action('GET', 'UserController@profile', array('user' => 1));
The getContent
method will return the evaluated string contents of the response. If your route returns a View
, you may access it using the original
property:
$view = $response->original;
$this->assertEquals('John', $view['name']);
To call a HTTPS route, you may use the callSecure
method:
$response = $this->callSecure('GET', 'foo/bar');
Note: Route filters are disabled when in the testing environment. To enable them, add
Route::enableFilters()
to your test.
You may also call a route and receive a DOM Crawler instance that you may use to inspect the content:
$crawler = $this->client->request('GET', '/');
$this->assertTrue($this->client->getResponse()->isOk());
$this->assertCount(1, $crawler->filter('h1:contains("Hello World!")'));
For more information on how to use the crawler, refer to its official documentation.

When testing, you may often want to mock a call to a Laravel static facade. For example, consider the following controller action:
public function getIndex()
{
Event::fire('foo', array('name' => 'Dayle'));
return 'All done!';
}
We can mock the call to the Event
class by using the shouldReceive
method on the facade, which will return an instance of a Mockery mock.
public function testGetIndex()
{
Event::shouldReceive('fire')->once()->with('foo', array('name' => 'Dayle'));
$this->call('GET', '/');
}
Note: You should not mock the
Request
facade. Instead, pass the input you desire into thecall
method when running your test.

Laravel ships with several assert
methods to make testing a little easier:
public function testMethod()
{
$this->call('GET', '/');
$this->assertResponseOk();
}
$this->assertResponseStatus(403);
$this->assertRedirectedTo('foo');
$this->assertRedirectedToRoute('route.name');
$this->assertRedirectedToAction('Controller@method');
public function testMethod()
{
$this->call('GET', '/');
$this->assertViewHas('name');
$this->assertViewHas('age', $value);
}
public function testMethod()
{
$this->call('GET', '/');
$this->assertSessionHas('name');
$this->assertSessionHas('age', $value);
}
public function testMethod()
{
$this->call('GET', '/');
$this->assertSessionHasErrors();
// Asserting the session has errors for a given key...
$this->assertSessionHasErrors('name');
// Asserting the session has errors for several keys...
$this->assertSessionHasErrors(array('name', 'age'));
}
public function testMethod()
{
$this->call('GET', '/');
$this->assertHasOldInput();
}

The TestCase
class contains several helper methods to make testing your application easier.
$this->session(['foo' => 'bar']);
$this->flushSession();
You may set the currently authenticated user using the be
method:
$user = new User(array('name' => 'John'));
$this->be($user);
You may re-seed your database from a test using the seed
method:
$this->seed();
$this->seed($connection);
More information on creating seeds may be found in the migrations and seeding section of the documentation.

As you may already know, you can access your Laravel Application
/ IoC Container via $this->app
from any test method. This Application instance is refreshed for each test class. If you wish to manually force the Application to be refreshed for a given method, you may use the refreshApplication
method from your test method. This will reset any extra bindings, such as mocks, that have been placed in the IoC container since the test case started running.


Gateway
BOT
28-Sep-18 02:02 PM
[telegram] <Regnar> All I hear from you is either fud or asking for price predictions a year out. Just because you don't see the value doesn't mean there is none. What you see as a gambling investment others see as the only opportunity to escape tyranny, or circumvent oppression, feed their families, support their causes.
Modern digital fiat money has been weaponized against other people and sometimes their own people to force them to do something, you just don't see it or don't care because that weapon hasn't been used on you yet. (re @Kassu2: Acura you know im right. crypto is just a speculation, gives nothing good to society.)
[telegram] <Regnar> All I hear from you is either fud or asking for price predictions a year out. Just because you don't see the value doesn't mean there is none. What you see as a gambling investment others see as the only opportunity to escape tyranny, or circumvent oppression, feed their families, support their causes, etc
Modern digital fiat money has been weaponized against other people and sometimes their own people to force them to do something, you just don't see it or don't care because that weapon hasn't been used on you yet. (re @Kassu2: Acura you know im right. crypto is just a speculation, gives nothing good to society.)
[telegram] <Regnar> People interested in PIRATE, please ask your questions in their discord.
@piratechain
[telegram] <Regnar> People interested in PIRATE, please ask your questions in their discord or telegram
@piratechain
[telegram] <Kassu2> Touching. (re @Regnar: All I hear from you is either fud or asking for price predictions a year out. Just because you don't see the value doesn't mean there is none. What you see as a gambling investment others see as the only opportunity to escape tyranny, or circumvent oppression, feed their families, support their causes, etc
Modern digital fiat money has been weaponized against other people and sometimes their own people to force them to do something, you just don't see it or don't care because that weapon hasn't been used on you yet.)
[telegram] <Regnar> So you do know, you just dont care. Cool. Now stop spreading fud in here. (re @Kassu2: Touching.)
[telegram] <Mentortechies> Done. Will have 777 Pirates soon. Thanks for the help.
[telegram] <Acura360> niceee (re @Mentortechies: Done. Will have 777 Pirates soon. Thanks for the help.)
[telegram] <Cameron> How long will the pirate offer last for?
[telegram] <Mentortechies> Can I do it twice? lolll
[telegram] <Regnar> No. It's a community member selling his own pirate (at well below market price) to help on board new people. Lol so please only try once (re @Mentortechies: Can I do it twice? lolll)
(edited)
[telegram] <Mentortechies> I understand. (re @Regnar: No. It's a community member selling his own pirate (at well below market price) to help on board new people. Lol so please only try once)
[telegram] <Regnar> Thanks :) (re @Mentortechies: I understand.)
[telegram] <vineetrk> (re @Kassu2: Touching.)
[telegram] <Regnar> ^ see last post. Whale will eventually run out (re @Cameron: How long will the pirate offer last for?)
[telegram] <Regnar> If you are interested in PIRATE please join their telegram here @piratechain
[telegram] <Mentortechies> Is there anywhere we can find informations avec current supply, max supply, etc.
[telegram] <Regnar> I want to try and keep the questions in here to KMD, but not an issue to redirect to PIRATE
[telegram] <Mentortechies> Oh. Joined. I think there is a small lack of informations on Pirate here and there. I was led to Pirate from a twitter post shared here.... but it was refering back to this channel. (re @Regnar: If you are interested in PIRATE please join their telegram here @piratechain)
[telegram] <Regnar> Yea the new telegram was just set up last night(or yesterday? Lol). So we're still working on getting everything figured out for marketing purposes (re @Mentortechies: Oh. Joined. I think there is a small lack of informations on Pirate here and there. I was led to Pirate from a twitter post shared here.... but it was refering back to this channel.)
(edited)


circos.arrow.Rd
Draw arrow which is paralle to the circle
circos.arrow( x1, x2, y = get.cell.meta.data("ycenter", sector.index, track.index), width = get.cell.meta.data("yrange", sector.index, track.index)/2, sector.index = get.current.sector.index(), track.index = get.current.track.index(), arrow.head.length = convert_x(5, "mm", sector.index, track.index), arrow.head.width = width*2, arrow.position = c("end", "start"), tail = c("normal", "point"), border = "black", col = "white", lty = par("lty"), ...)
| x1 | start position of the arrow on the x-axis. |
|---|---|
| x2 | end position of the arrow on the x-axis. |
| y | position of the arrow on the y-axis. Note this is the center of the arrow on y-axis. |
| width | width of the arrow body. |
| sector.index | index of the sector. |
| track.index | index of the track. |
| arrow.head.length | length of the arrow head. Note the value should be smaller than the length of the arrow itself (which is |
| arrow.head.width | width of the arrow head. |
| arrow.position | where is the arrow head on the arrow. |
| tail | the shape of the arrow tail (the opposite side of arrow head). |
| border | border color of the arrow. |
| col | filled color of the arrow. |
| lty | line style of the arrow. |
| ... | pass to |
Note all position values are measured in the data coordinate (the coordinate in each cell).
If you see points overflow warnings, you can set circos.par(points.overflow.warning = FALSE)
to turn it off.
circos.track(ylim = c(0, 1), panel.fun = function(x, y) { circos.arrow(0, 1, y = 0.5, width = 0.4, arrow.head.length = ux(1, "cm"), col = "red", tail = ifelse(CELL_META$sector.index %in% c("a", "c"), "point", "normal")) }, bg.border = NA, track.height = 0.4)circos.clear() ########## cell cycle ########### cell_cycle = data.frame(phase = factor(c("G1", "S", "G2", "M"), levels = c("G1", "S", "G2", "M")), hour = c(11, 8, 4, 1)) color = c("#66C2A5", "#FC8D62", "#8DA0CB", "#E78AC3") circos.par(start.degree = 90) circos.initialize(cell_cycle$phase, xlim = cbind(rep(0, 4), cell_cycle$hour))circos.track(ylim = c(0, 1), panel.fun = function(x, y) { circos.arrow(CELL_META$xlim[1], CELL_META$xlim[2], arrow.head.width = CELL_META$yrange*0.8, arrow.head.length = ux(1, "cm"), col = color[CELL_META$sector.numeric.index]) circos.text(CELL_META$xcenter, CELL_META$ycenter, CELL_META$sector.index, facing = "downward") }, bg.border = NA, track.height = 0.3)


Encodes simple feature ('sf') objects and coordinates, and decodes polylines using the 'Google' polyline encoding algorithm (<https://developers.google.com/maps/documentation/utilities/polylinealgorithm>).
| Version: | 0.7.2 |
| Depends: | R (≥ 3.3.0) |
| Imports: | Rcpp (≥ 0.12.13) |
| LinkingTo: | Rcpp, BH |
| Suggests: | covr, knitr, rmarkdown, sf, testthat |
| Published: | 2018-11-23 |
| Author: | David Cooley [aut, cre], Paulo Barcelos [ctb] (Author of c++ decode_polyline), Chris Muir [ctb] |
| Maintainer: | David Cooley <dcooley at symbolix.com.au> |
| License: | GPL-3 |
| NeedsCompilation: | yes |
| SystemRequirements: | C++11 |
| Materials: | README |
| CRAN checks: | googlePolylines results |
| Reference manual: | googlePolylines.pdf |
| Vignettes: |
Vignette Title |
| Package source: | googlePolylines_0.7.2.tar.gz |
| Windows binaries: | r-devel: googlePolylines_0.7.2.zip, r-release: googlePolylines_0.7.2.zip, r-oldrel: googlePolylines_0.7.2.zip |
| OS X binaries: | r-release: googlePolylines_0.7.2.tgz, r-oldrel: googlePolylines_0.7.2.tgz |
| Old sources: | googlePolylines archive |
| Reverse imports: | googleway, mapdeck |
Please use the canonical form https://CRAN.R-project.org/package=googlePolylines to link to this page.


--- layout: default title: "Mapping data across municipalities in a metro area" ---
Many city challenges are actually region-wide challenges. Yet the lack of usage of standards for many datasets means that it is often time-consuming to do something as simple as making a map of a metropolitan area showing data seamlessly across jurisdictions. For this project, I created an example of a map showing business licenses for both Kansas City and Independence, Missouri:
Of course, this concept isn’t limited to business licenses — in fact, that's probably not even the best use case, it's just the example used here. There could be regional maps of everything from 911 calls to building permits.
If you are wondering why there appear to be some locations outside of these two cities, it has to do with issues in the original data. [Let's double check this!]


--- Title: MOT's in Bath Breadcrumb1_url: section-parking.html Breadcrumb1_title: Parking & Travel ---
We offer a range of services to individuals and taxi/minicab drivers using our state-of-the-art testing equipment and workshop facilities:
| Class | Price | |
|---|---|---|
| Motorcycle | I & II | £29.65 |
| Car/Motorhome | IV | £54.85 |
| Minibus (13 – 16 passenger seats) | V | £59.55 |
| Van (3000kg to 3500kg) | VII | £58.60 |
In addition to its compulsory annual test, it is recommended that you get your commercial or PCV vehicle brakes tested at least three times per year. We offer rolling road brake testing services for vehicles over 3.5T at a cost of £10 (+VAT) per axle.
Please note we only accept payments by debit or credit card.
Price: £96 (+VAT where applicable)
MOT Garage and Fleet Services
Locksbrook Road
Bath
BA1 3EL
Telephone:01225 477314
| Monday | 7:00am | 16:00pm |
|---|---|---|
| Tuesday | 7:00am | 16:00pm |
| Wednesday | 7:00am | 16:00pm |
| Thursday | 7:00am | 16:00pm |
| Friday | 7:00am | 15:00pm |
Monday to Friday: First slot at 7.45am, last slot 3pm (2pm on Fridays)
Earlybird special: Drop off from 7am and collect later.
We also offer free wi-fi in our reception area where you can sit while you wait.


3D prnting is affordable
Triplaxis now offers both PLA and ABS to suit your needs and desires.
* Prices does not apply to Special Materials.
Solid Colors
Translucent Colors
Special Materials
ABS colors are sold based on availability. Drop us a message in the comment box below to check what is currently available.
Other Services
3D Model From RM 5* onwards
Paint Job From RM5* onwards
* Prices are subjected to change based on size and level of details.


About Face-Off
Online Face Recognition
- Many online platforms use your uploaded photos in face recognition systems.
- This includes most social media services (Facebook, Instagram, etc.)
- Oftentimes data is leaked or scraped and can be used in harmful ways (clearview.ai, Cambridge Analytica, etc.)
Hiding Faces From AI
- Face-Off allows you to protect your face data by adding a discrete and strategic distortion layer which hides your face from being recognized by face recognition.
- Note: Face-Off does not guarantee protection, it increases the chances that a face recognition system will not be able to recognize you.
- Note: Face-Off does not stop face detection, a service will still know that a face is there, it just won't know who it belongs to.
How to use Face-Off
1. Upload the photos you plan to upload to social media to Face-Off.
2. Select the faces you wish to hide.
3. Pick the distortion settings for the concealment layer.
4. Download the images when they are finished processing.
5. Upload the new processed images to social media.
Note: Face-Off's face selection feature isn't visible on Safari yet. Please just select all faces if using Safari.

- We do NOT save your data in any form in our algorithms or models.
- Within 1 hour after uploading your images, all of your data is deleted.
- We DO save information about which selections you choose for statistics purposes, though this is anonymous data.
Session Cookies
- Cookies are used only for website functionality purposes and do not contain identifying information like location or IP address.


{% load static %}
Here, you can search for papers and citation contexts given all computer science papers of arXiv.org.
You can search for papers based on a phrase,the title, or the author's name.
You can also search for citation contexts based on the title or author name of a cited paper.
Search for papers which contain a given phrase in the body text.
Search for papers which have a given (incomplete) title.
Search for papers which have been written by a given author or group of authors.
Search for sentences in papers where a paper given by its title is cited.
Search for sentences in papers where another paper given by its author is cited.


Copyright © 2011 Mark R. Greenstreet
Authors: Mark R. Greenstreet (mrg@cs.ubc.ca).
cont_spec() = integer() | float() | {integer(), float()}
A "continue" specification -- a limit on the number of times to call
the function being timed, and/or a limit on the total execution time
for those calls. For example, let CS
be a parameter of
type cont_spec
to t/2
or t/3
,
and let Time_This
be the function whose execution time
is being measured.
CS
is an integer, then it specifies how many times
the Time_This
function should be executed.CS
is a float, then it specifies the total elapsed
time (in seconds) for executing the Time_This
function.
More precisely, the Time_This
function will be
called until this limit is met or exceeded.CS
is a tuple of the form
{N_iter, T_limit}
then the Time_This
function will be executed at most N_iter
times or
until the total elapsed time exceeds T_limit
.Time_This
function returns the
atom 'failed'
it is deemed to have failed. The
t(...)
function will terminate, returning the atom
'failed'
.
contfn() = contfn0() | contfnA()
A "continue" function for the t(...)
functions
contfn0() = fun((N::integer, T_total::float()) -> boolean())
A "continue" function for the t(...)
functions
without an "accumulator" argument.
contfnA() = fun((N::integer, T_total::float(), Acc::term) -> boolean())
A "continue" function for the t(...)
functions
with an "accumulator" argument.
postfn() = postfn0() | postfnA()
Post-processing for the t(...)
functions.
postfn0() = fun((N::integer, T_total::float()) -> term())
Post-processing for the t(...)
functions without an
"accumulator".
postfnA() = fun((N::integer, T_total::float()) -> term())
Post-processing for the t(...)
functions with an
"accumulator".
result_atom() = mean | std | raw | values
result_spec() = result_atom() | [result_atom()]
A "result" specification. The return value of the
t/2
or t/3
function will be an association
list. The tuples to include in the list are specified by the
result_atom
or list of such atoms as described below:
mean
: include a tuple of the form
{mean, Mean}
where Mean
is the
average execution time of the Time_This
function.std
: include a tuple of the form
{std, Std}
where Std
is the (sample)
standard-deviation of the execution times of the
Time_This
function.raw
: include a tuple of the form
{raw, Times}
where Times
is a list
of the elapsed times for the executions of the Time_This
function.values
: include a tuple of the form
{raw, V}
where V
is a list
of the return values from the executions of the
Time_This
function.| elapsed/2 | |
| how_many_runs/2 | determine how many times a function needs to be called to use a total elapsed time in a given interval. |
| log/1 | %% Create a new event log with an entry for PlainString . |
| log/2 | Create or update an event log. |
| log/3 | Generate an event log. |
| perseverate/2 | Call a function multiple times. |
| print_log/1 | Print the contents of an event log to the standard output. |
| t/1 | Measure the mean and standard deviation of the elapsed time for executing a function provided by the caller. |
| t/2 | Measure the execution time of Time_This . |
| t/3 | A wrapper function that calls
t(TimeThis, ContinueFn, AccFn, Acc0, PostFn) . |
| t/5 | Measure the execution time of a function provided by the caller. |
elapsed(T0, T1) -> any()
how_many_runs(F, Tbnds::T) -> integer()
determine how many times a function needs to be called to use a total elapsed time in a given interval. In particular,
how_many_runs(F, {Tlo, Thi})
estimates how many times
to call F
so that the total elapsed time will be
between Tlo
and Thi
.how_many_runs(F, T)
when T
is an integer
of float is equivalent to how_many_runs(F, {T, T})
--
in other words, how_many_runs
tries to get as close
to the target elapsed time, T
as it can. See the
caveats below for the limits of the accuracy of
how_many_runs
Tlo
and Thi
are sufficiently
close to each other there may be no suitable number of calls.F
takes longer than
Thi
, then how_many_runs
will return
the integer 1
.how_many_runs(...)
can be helpful for estimating a
"reasonable" number of executions to use for making time measurements.
In particular, if the execution time of F
is small compared
with the granularity of
erlang:monotonic_time()
,
then how_many_runs(F, ...)
can give a reasonable
choice for how many times to call F
to get meaningful
time measurements.
time_it:perseverate/2
.
log(PlainString) -> event_log()
%% Create a new event log with an entry for PlainString
.
log(Format::Format_or_Log, Data::Data_or_PlainString) -> event_log()
Create or update an event log. There are two ways to call this function:
log(Format::string(), Data::[term()]
Format
and
Data
. The Format
must be a non-empty
string.log(Log::event_log(), PlainString::string()
Log
for PlainString
.log(Log, Format, Data) -> event_log()
Generate an event log.
The parameters Format
and Data
are
as for io_lib:format(Format, Data)
.
The log
function generates a record to record
Format
and Data
along with the pid of the
calling process and the current time. This record is appended to the
log. The log can be printed using the print_log
function.
Notes
event_log()
is a deeplist. Thus, if
Log1
and Log2
are event logs, then so
are [Log1, Log2]
and [Log1 | Log2]
.
This is to facilitate writing functions that return
event_log
's and sending event_log
's
in messages. Merging such logs only requires wrapping them
them up as a list.io_lib:format(Format, Data)
is
deferred to print_log
. This is done to make
calls to the log
function execute as quickly as
possible.Call a function multiple times.
Call the function F
N
times.
If N=0, return 'ok'. Otherwise, return the value from the last
call to F
.
See also: time_it:how_many_runs/2
.
print_log(Log::event_log()) -> ok
Print the contents of an event log to the standard output.
As noted above, an event_log
is a deep list.
print_log
flattens this list and then prints the
events in time order. The time of the first event is taken as 0,
and for other events, the time is reported as the time since the
first event.
t(Time_This) -> [{result_atom(), number()}]
Measure the mean and standard deviation of the elapsed time for
executing a function provided by the caller.
The function will be called repeatedly until the total elapsed time
is at least one second. The return value is an association list
of the form [ {mean, Mean}, {std, Std} ]
where
Mean
is the average elapsed time and Std
is the standard deviation. There is no guarantee of the order of
these two tuples in the list. The function
lists:keyfind/3
should be used to extract specific values.
Failures: If the Time_This
function returns the
atom 'failed'
it is deemed to have failed. The
t(...)
function will terminate, returning the atom
'failed'
.
t(Time_This, How_Long::What) -> Stuff
Measure the execution time of Time_This
.
What
is a cont_spec()
, then
it is interpreted as described for the
cont_spec()
type. The return value of
t(Time_This, What)
is an association list of the form
[{mean, Mean}, {std, Std}]
where Mean
is
the average time of the executions of Time_This
and
Std
is the standard deviation.What
is a result_spec
, it is
interpreted as described for the result_spec()
type.
The Time_This
function will be executed until
the total elapsed time is at least one second.Time_This
function returns the
atom 'failed'
it is deemed to have failed. The
t(...)
function will terminate, returning the atom
'failed'
.
t(Time_This, C::Cont, P::Result) -> term2()
A wrapper function that calls
t(TimeThis, ContinueFn, AccFn, Acc0, PostFn)
.
The Cont
parameter gives the condition for continuing to
execute Time_This
(and gathering data).
Cont
is a function, then it is used as
ContinueFn
in t/5
.Cont
is a cont_spec()
, then
it is interpreted as described for the
cont_spec()
type.Result
parameter describes what value should be
returned.
Result
is a function, then it is used as
PostFn
in t/5
.Result
is a result_spec
, then
it is interpreted as described for the result_spec()
type.Time_This
function returns the
atom 'failed'
it is deemed to have failed. The
t(...)
function will terminate, returning the atom
'failed'
.
t(Time_This, Continue, AccFn, Acc0, PostFn) -> term2()
Measure the execution time of a function provided by the caller.
This is the most general form of the t(...)
functions.
The caller provides functions to determine how many times the
Time_This
function should be called, what data is
accumulated from these calls, and how to process the accumulated
data to produce the final result.
Our parameters:
Time_This
a zero-argument function that is
called repeatedly. The time for each execution is measured
by calling
erlang:monotonic_time()
before and after.
Continue
a boolean valued function that
is called before each invocation of Time_This
.
If Continue
returns true
, then
we keep gathering timing data. Otherwise, we're done.
Continue
can take two or three arguments:
N
is the number of times that
Time_This
has been called;T_Total
is the total time spent in these calls;
and Acc
is the value of the accumulator (see below).
AccFn
and AccIn
implement an
accumulator of the timing values (and optionally the return
values of Time_This
). AccFn
can take from
2 to 5 arguments as described below:
AccFn(AccIn, T_elapsed)
AccFn(AccIn, T_elapsed, V)
AccFn(AccIn, N, T_total, T_elapsed)
AccFn(AccIn, N, T_total, T_elapsed, V)
AccIn
is the result of AccFn
from the previous call. The first time Time_This
is evaluated, AccFn
is called with
AccIn = Acc0
.T_elapsed
is the time that was spent for the
current evaluation of Time_This
.N
is the total number of times that
Time_This
has been called; andT_Total
is the total time spent in these calls.
N
and T_Total
are accumulated by the t(...)
function; thus
AccFn
doesn't need to handle these.
PostFn
compute the final result. In particular
the return value of t(...)
is
PostFn(N, T_Total, AccOut)
where
N
is the total number of times that
Time_This
has been called;T_Total
is the total time spent in these calls;
and AccOut
is the final result from
AccFn
.Generated by EDoc, Jan 25 2017, 12:13:15.


[gecode-users] strange bug in propagation
Grégoire Dooms
dooms at info.ucl.ac.be
Sun Apr 16 14:45:09 CEST 2006
jeremie.vautard wrote:
> Hi !
>
> I encountered a very strange bug while testing my extensively
> defined binary constraint propagator. Under some conditions
> that I havn't really discovered right now (it seems to be at
> least with 3 of my propagators posted, but this is not
> sufficient), I get a segmentation fault after several steps of
> propagation. The most strange is that the instruction causing
> the bug is in the gecode part : gdb tells me the crash occur
> here :
>
> #0 Gecode::Int::IntVarImp::nq_full (this=0x80542f4,
> home=0x8053fa0, m=3) at ././kernel/memory-manager.icc:233
> 233 _next = n;
> (gdb) bt
> #0 Gecode::Int::IntVarImp::nq_full (this=0x80542f4,
> home=0x8053fa0, m=3) at ././kernel/memory-manager.icc:233
> #1 0x0804f047 in ExtensiveBinaryConstraint::check
> (this=0xbf840164, home=0x8053fa0, x=
> {<Gecode::VariableViewBase<Gecode::Int::IntVarImp>> =
> {var = 0x805437c}, <No data fields>}, y=
> {<Gecode::VariableViewBase<Gecode::Int::IntVarImp>> =
> {var = 0x80542f4}, <No data fields>})
> at ./int/var/imp.icc:364
> #2 0x0804f0ed in ExtensiveBinaryPropagator::propagate
> (this=0x807400c, home=0x8053fa0) at QSolve.cc:666
> #3 0xb7f1b218 in Gecode::Space::propagators (this=0x8053fa0)
> at kernel/core.cc:160
> #4 0xb7f1b7a3 in Gecode::Space::status (this=0x8053fa0,
> a=@0x80300c0, pn=@0xbf840254) at kernel/core.cc:254
>
> (The ExtensiveBinaryPropagator propagate() method does nothing
> but call an ExtensiveBinaryConstraint::check(Space* home,
> Intview x,y) method which actually remove the values and
> returns ES_NOFIX, ES_FAILED or ES_SUBSUMED).
>
> Have you even encountered this kind of bug when creating
> propagators ? Do you have an idea of what I can have done
> wrong ? In this particular example, the IntView::nq method is
> called to remove 2 from a [1..4] domain...
>
Here is a (small) check list for mistakes I did and which triggered
segfaults later :
- do you do GECODE_ME_CHECK for each basic and iterator tell on IntViews
? if not the Space might be failed before you do the tell.
You can also assert(! home.failed()); in your check method before you do
the nq tell.
- did you forget to call update on all of your views in the copy
constructor of your propagator ? If you inherit from BinaryPropagator it
is done in its copy constructor and you have to call that copy
constructor in the member initialization list of yours.
Best,
--
Grégoire
More information about the gecode-users
mailing list


Installation¶
This section provides complete details about Bokeh’s required and optional dependencies as well as information about how to install Bokeh in different situations. To get up and running as fast as possible, see the Installation section of the Quickstart.
Supported Platforms¶
Bokeh is officially supported (and continuously tested) on CPython versions 2.7 and 3.5+ only. Other Python versions or implementations may function, possiblly limited capacity, but no guarantees or support is provided.
Required Dependencies¶
For basic usage, have the following libraries installed:
Jinja2 >=2.7
python-dateutil >=2.1
PyYAML >=3.10
numpy >=1.7.1
packaging >=16.8
six >=1.5.2
tornado >=4.3
To use the Bokeh server with Python 2.7, you also must install the Futures package.
Optional Dependencies¶
In addition to the required dependencies above, some additional packages are necessary for certain optional features:
- NodeJS
- Necessary for Extending Bokeh or for defining
CustomJS
implementations in CoffeeScript or TypeScript. - Pandas
- Not strictly necessary for any particular feature, but some usage is simpler when using Pandas e.g. Pandas DataFrames will be converted automatically to Bokeh data sources by glyph functions.
- psutil
- Necessary to enable detailed memory logging in the Bokeh server.
- Sphinx
- Necessary to make use of the
bokeh.sphinxext
Sphinx extension for including Bokeh plots in Sphinx documentation.
Standard Releases¶
These Bokeh dependencies are best obtained via the Anaconda Python Distribution, which was designed to include robust versions of popular libraries for the Python scientific and data analysis stacks.
If you are already an Anaconda user, you can simply run the command:
conda install bokeh
This will install the most recent published Bokeh release from the Anaconda, Inc. package repository, along with all dependencies.
Alternatively, it is possible to install from PyPI using pip
:
pip install bokeh
Sample Data¶
Some of the Bokeh examples rely on sample data that is not included in the Bokeh GitHub repository or released packages, due to their size. Once Bokeh is installed, the sample data can be obtained by executing the following command at a Bash or Windows prompt:
bokeh sampledata
Alternatively, the following statements can be executed in a Python interpreter:
>>> import bokeh.sampledata
>>> bokeh.sampledata.download()
Finally, the location that the sample data is stored can be configured.
By default, data is downloaded and stored to a directory $HOME/.bokeh/data
.
(The directory is created if it does not already exist.) Bokeh looks for
a YAML configuration file at $HOME/.bokeh/config
. The YAML key
sampledata_dir
can be set to the absolute path of a directory where
the data should be stored. For instance adding the following line to the
config file:
sampledata_dir: /tmp/bokeh_data
will cause the sample data to be stored in /tmp/bokeh_data
.
Verifying installation¶
The first check you can make is to make sure you can import bokeh
and
verify bokeh.__version__
from a running python interpreter. If you
execute both of those lines in a python interpreter, the result should
look something like this:
The next check you can make is to produce a very simple plot. Execute the following few lines of python code, either by copying them into a script and executing the script, or by running the lines by hand in a python interpreter:
from bokeh.plotting import figure, output_file, show
output_file("test.html")
p = figure()
p.line([1, 2, 3, 4, 5], [6, 7, 2, 4, 5], line_width=2)
show(p)
This should save a test.html
file locally, and open a browser tab to
view the file. The result should look like this:
Advanced Cases¶
In addition to the standard installation methods above, Bokeh can also be installed in some specialized ways for advanced usage or development.
Source Code¶
Installing Bokeh from source requires rebuilding the BokehJS library from its TypeScript sources. Some additional toolchain support is required. Please consult the Getting Set Up section of the Developer Guide for detailed instructions.
Developer Builds¶
And easier way to obtain the most recent Bokeh updates without having to worry about building Bokeh yourself is to install a developer build. Dev builds are not published on any particular schedule but often come out a few times a month or more.
These builds are being made available on anaconda.org. If you are using Anaconda, you can install with conda by issuing the command from a Bash or Windows command prompt:
conda install -c bokeh/channel/dev bokeh
Alternatively you can install with pip from a Bash or Windows command prompt:
pip install --pre -i https://pypi.anaconda.org/bokeh/channel/dev/simple bokeh --extra-index-url https://pypi.python.org/simple/
We attempt to make sure the developer builds are relatively stable, however please be aware they they are not tested as rigorously as standard releases. Any problems or issues reported on the GitHub issue tracker are appreciated.
BokehJS¶
If you would like to use BokehJS as a standalone JavaScript library, released versions of BokehJS are available for download from CDN at pydata.org, under the following naming scheme:
http://cdn.pydata.org/bokeh/release/bokeh-x.y.z.min.css
http://cdn.pydata.org/bokeh/release/bokeh-widgets-x.y.z.min.css
http://cdn.pydata.org/bokeh/release/bokeh-tables-x.y.z.min.css
for the BokehJS CSS files, and:
http://cdn.pydata.org/bokeh/release/bokeh-x.y.z.min.js
http://cdn.pydata.org/bokeh/release/bokeh-widgets-x.y.z.min.js
http://cdn.pydata.org/bokeh/release/bokeh-tables-x.y.z.min.js
http://cdn.pydata.org/bokeh/release/bokeh-api-x.y.z.min.js
for the BokehJS Javascript files.
Note
The CSS must be loaded before the JavaScript library.
The "-widgets"
files are only necessary if you are using any of the widgets
built into Bokeh in bokeh.models.widgets
in your documents. Similarly, the
"-tables"
files are only necessary if you are using Bokeh data tables in
your document. The "bokeh-api"
files are required to use the BokehJS API,
and must be loaded after the core BokehJS library.
As a concrete example, the links for version 0.12.15
are:
- https://cdn.bokeh.org/bokeh/release/bokeh-0.12.15.min.css
- https://cdn.bokeh.org/bokeh/release/bokeh-widgets-0.12.15.min.css
- https://cdn.bokeh.org/bokeh/release/bokeh-tables-0.12.15.min.css
and