Ccinterfaces.pm
Transaction conversion interfaces inwards for sms, mail etc.
This contains interfaces for mail and SMS to be used by demons It also contains currently abandoned work for touch-tone If there's smart card, it'll go here
Hugh Barnard
Cchooks.pm
(c) Hugh Barnard 2005 GPL Licenced
=cut
package Ccinterfaces; use strict; use vars qw(@ISA @EXPORT); use Exporter; use Data::Dumper; use Cclite; use Cclitedb; use Ccu; ###use Encode qw(encode decode); my $VERSION = 1.00; @ISA = qw(Exporter); @EXPORT = qw(sms_transaction sms_message_parse oscommerce_transaction read_mail_transactions read_csv_transactions );
this is the provisional solution to the multilingual message fragments later, it will go somewhere neater to change these, just substitute a translated hash
=cut
# language of messages decided now by Ccu::decide_language our %messages = readmessages();
This accepts an SMS transaction and reformats it into an ordinary one. It therefore has to do a mobile phone to user name look up, data reformatting etc.
Mobile phone numbers must have the internation prefix 44.... etc. This is to enable wide-area registries at some stage...
This will use up a credit, so mabye it should be configured. This will only go registry-a to registry-a, at present when you say 'at' it's assumed that the to and from registries at the same
Text messaging transfer is allowed home -> remote more expressivity in the message and auth via phone number For example mobile number 1234 text message: -------------------------------------------------------------- 1234: [send|snd] 4 duckets to ddawg at dalston for advertising and computer help --------------------------------------------------------------
sub sms_transaction { my ( $class, $mobilenumber, $input ) = @_; # mobile number + raw string my ( $token, $offset, $limit, $class, $pages, $token ); # return values for screen, not really used by scripts my ( $metarefresh, $home, $error, $output_message, $page, $c ); my %transaction; ### $input = decode( 'UCS-2', lc($input) ); # if sms is stored as unicode my ( $found_count, $transaction_description_ref ) = sms_message_parse($input); return ( $metarefresh, $home, 'sms incomplete message error', $output_message, $page, $c ) if ( $found_count < 5 ); my %transaction_description = %$transaction_description_ref; my ( $error, $fromuserref ) = get_where( $class, $transaction_description{'fromregistry'}, 'om_users', '*', 'userMobile', $mobilenumber, $token, $offset, $limit ); my ( $error, $touserref ) = get_where( $class, $transaction_description{'toregistry'}, 'om_users', '*', 'userLogin', $transaction_description{'touser'}, $token, $offset, $limit ); my ( $error, $currencyref ) = get_where( $class, $transaction_description{'fromregistry'}, 'om_currencies', '*', 'name', $transaction_description{'currency'}, $token, $offset, $limit ); # one of the above lookups fails, reject the whole transaction if ( ( !length($fromuserref) ) || ( !length($fromuserref) ) || ( !length($fromuserref) ) ) { return ( $metarefresh, $home, 'sms database lookup error', $output_message, $page, $c ); } # convert to standard transaction input format, fields etc. #fromregistry : chelsea $transaction{fromregistry} = $transaction_description{'fromregistry'}; #home : http://cclite.caca-cola.com:83/cgi-bin/cclite.cgi, for example $transaction{home} = ""; # no home, not a web transaction #subaction : om_trades $transaction{subaction} = 'om_trades'; #toregistry : dalston $transaction{toregistry} = $transaction_description{'toregistry'}; #tradeAmount : 23 $transaction{tradeAmount} = $transaction_description{'quantity'}; #tradeCurrency : ducket $transaction{tradeCurrency} = $$currencyref{name}; #tradeDate : this is date of reception and processing, in fact my ( $date, $time ) = &Ccu::getdateandtime( time() ); $transaction{tradeDate} = $date; #FIXME: should be multilingual tradeTitle : added by this routine $transaction{tradeTitle} = "SMS transaction: see description"; #tradeDescription $transaction{tradeDescription} = $transaction_description{'description'}; #tradeDestination : ddawg $transaction{tradeDestination} = $$touserref{userLogin}; #tradeItem : test to see variables #tradeSource : manager $transaction{tradeSource} = $$fromuserref{userLogin}; #FIXME: this should be taken from a configuration file $transaction{initialPaymentStatus} = 'waiting'; # # call ordinary transaction my $transaction_ref = \%transaction; my ( $metarefresh, $home, $error, $output_message, $page, $c ) = transaction( 'sms', $transaction{fromregistry}, 'om_trades', $transaction_ref, $pages, $token ); return ( $metarefresh, $home, $error, $output_message, $page, $c ); }
This accepts a /var/spool/mail/xxx and reformats it into a set of transactions. It therefore has to do a email address to user name look up, data reformatting etc.
This will only go registry-a to registry-a, at present when you say 'at' it's assumed that the to and from registries are the same
example mail text -------------------------------------------------------------- [send|snd] 4 duckets to ddawg at dalston for advertising and computer help --------------------------------------------------------------
This will move to GPG encoded mail at -some- stage, real soon now...
This is probably replaced by Ccmailgateway now, reads via POP3 11/2009
sub read_mail_transactions { my ( $class, $db, $table, $mail_file, $token, $offset, $limit ) = @_; my ( $messages, $error, $offset, $limit, $class, $pages, $token ); my %transaction; # parse the mail file into messages my ( %subject, %from, %message, $fromregistry, $toregistry, $counter ); ### From: "Hugh Barnard"<EMAIL_ADDRESS># mail file format is <toregistry>.cclite, registry is parsed out $mail_file =~ /\057([^\057]+)\056cclite$/; $fromregistry = $toregistry = $1; open( MAIL, $mail_file ); $/ = ''; # read paragraphs while (<MAIL>) { if (/^From/) { /^Subject:\s*(?:Re:\s*)*(.*)/mi; $counter++; $subject{$counter} = $1; /From\:.*\<(.*)\>/m; $from{$counter} = $1; } # endif $message{$counter} .= $_; } # endwhile close(MAIL); foreach my $key ( keys %subject ) { my $input = lc( $message{$key} ); # canonical is lower case my @words = split( /\s+/m, $input ); # fuzzy ark parsing the terms mainly go two-by-two! my $counter = 0; # used for term lookahead my ( $description, $currency, $quantity, $touser ); foreach my $word (@words) { if ( $word =~ /^(\d+)$/ ) { $quantity = $word; # quantity is the only numeric thing $currency = $words[ ( $counter + 1 ) ]; # currency is next to quantity $currency =~ s/s$//; # singulate or deplural... } # deals with yahoo footer etc. stupid format though if ( $word eq "to" && !length($touser) ) { # found 'to' $touser = $words[ ( $counter + 1 ) ]; # touser is next } $counter++; } ($description) = $input =~ /for\s+(\w.*)$/mi; # description is everything at end # look up sending user, receiving user and currency my ( $error, $fromuserref ) = get_where( $class, $fromregistry, 'om_users', '*', 'userEmail', $from{$key}, $token, $offset, $limit ); my ( $error, $touserref ) = get_where( $class, $toregistry, 'om_users', '*', 'userLogin', $touser, $token, $offset, $limit ); my ( $error, $currencyref ) = get_where( $class, $fromregistry, 'om_currencies', '*', 'name', $currency, $token, $offset, $limit ); # one of the above lookups fails, reject the whole transaction if ( ( !length($fromuserref) ) || ( !length($fromuserref) ) || ( !length($fromuserref) ) ) { ###send_mail_message($from{$key},"transaction invalid: $input") ; } # convert to standard transaction input format, fields etc. #fromregistry : chelsea $transaction{fromregistry} = $fromregistry; #home : http://cclite.caca-cola.com:83/cgi-bin/cclite.cgi, for example $transaction{home} = ""; # no home, not a web transaction #subaction : om_trades $transaction{subaction} = 'om_trades'; #toregistry : dalston $transaction{toregistry} = $toregistry; #tradeAmount : 23 $transaction{tradeAmount} = $quantity; #tradeCurrency : ducket $transaction{tradeCurrency} = $$currencyref{name}; #tradeDate : this is date of reception and processing, in fact my ( $date, $time ) = &Ccu::getdateandtime( time() ); $transaction{tradeDate} = $date; #tradeTitle : added by this routine $transaction{tradeTitle} = "Mail transaction: see description"; #tradeDescription $transaction{tradeDescription} = $description; #tradeDestination : ddawg $transaction{tradeDestination} = $$touserref{userLogin}; #tradeItem : test to see variables #tradeSource : manager $transaction{tradeSource} = $$fromuserref{userLogin}; # call ordinary transaction my $transaction_ref = \%transaction; my ( $metarefresh, $home, $error, $output_message, $page, $c ) = transaction( 'mail', $transaction{fromregistry}, 'om_trades', $transaction_ref, $pages, $token ); } # end of each on letters unlink $mail_file; # delete mail file when read # need to decide how this returns, processes multiple transactions return ( 0, "", $error, $messages, 'result.html', "" ); }
This accepts a /var/cclite/xxx.csv and reformats it into a set of transactions.
Prints a new file showing accepted transactions and rejected ones
example text 0 date 1 from 2 to 3 fromreg 4 toreg 5 currency 6 type 7 taxflag 8 amount 9 description "10-04-2005","ddawg","manager","dalston","dalston","ducket","credit","N",345,"test1" This will move to GPG encoded at -some- stage
04/10/2009,"test1","test2","dalston","dalston","dally","credit","N",345,"batch test"
'tradeSource' => 'test1', 'tradeDestination' => 'test2', 'tradeDescription' => 'batch test', 'tradeTaxflag' => 'N', 'initialPaymentStatus' => 'waiting', 'tradeTitle' => 'Batch transaction: see description', 'tradeDate' => '2009-10-04', 'fromregistry' => 'dalston', 'subaction' => 'om_trades', 'toregistry' => 'dalston', 'tradeCurrency' => 'dally', 'tradeAmount' => '345', 'home' => ''
Note that $db is empty, the registries are declared in the transactions themselves. It's there to keep the function signatures consistent.
Skip # lines which are expected to be comments. Only allow debits, currently.
sub read_csv_transactions { my ( $class, $db, $table, $csv_file, $file_name, $configuration_ref, $fields_ref, $token, $offset, $limit ) = @_; my ( $error_count, $success_count ); open( CSV, $csv_file ) or die "can\'t open csv file: $csv_file"; # timestamp output files so that they don't get confused my ( $numeric_date, $time ) = getdateandtime( time() ); # results written per registry now...11/2009 my $results_out = "$$configuration_ref{csvout}/$db/$file_name\056$numeric_date$time\056html"; open( OUT, ">$results_out" ) or die "can\'t open csv output file: $results_out"; print OUT <<EOT;   <link href="/styles/default.css" rel="stylesheet" type="text/css" /> <title>$db $numeric_date$time</title>   EOT while (<CSV>) { my ( $messages, $offset, $limit, $class, $pages, %error, $save, $bad_registry, $token, %transaction ); s/"//g; # remove quotes next if (/^#|^\s/); # skip comment lines/header and space lines chop($_); $save = $_; # if the from registry is bad currency lookup etc. won't work... $bad_registry = 0; my @transaction_array = split( /\,/, $_ ); # from registry must be same as to registry for the moment, too much # complexity doing batch to remote 03/2012 if ( $transaction_array[3] ne $transaction_array[4] ) { $error{'fromregistry'} = 'y'; $error{'toregistry'} = 'y'; } my ( $dberror, $fromuserref ) = get_where( $class, $transaction_array[3], 'om_users', '*', 'userLogin', $transaction_array[1], $token, $offset, $limit ); if ( length($dberror) ) { $error{'fromregistry'} = 'y'; $bad_registry = 1; } # test destination user in same registry, remote currently not allowed my $touserref; if ( !$bad_registry ) { ( $dberror, $touserref ) = get_where( $class, $transaction_array[4], 'om_users', '*', 'userLogin', $transaction_array[2], $token, $offset, $limit ); } # to user is invalid or absent if ( !length($touserref) && !$bad_registry ) { $error{'tradeDestination'} = 'y'; } # fail on currency not within this registry, cannot succeed my $currencyref; if ( !$bad_registry ) { ( $dberror, $currencyref ) = get_where( $class, $transaction_array[3], 'om_currencies', '*', 'name', $transaction_array[5], $token, $offset, $limit ); } # one of the above lookups fails, reject the whole transaction if ( !length($fromuserref) && !$bad_registry ) { $error{'tradeSource'} = 'y'; } if ( !length($currencyref) && !$bad_registry ) { $error{'tradeCurrency'} = 'y'; } # only debit transactions allowed at present, tradeType is NOT # part of a genuine transaction, at present! if ( $transaction_array[6] ne 'debit' ) { $error{'tradeType'} = 'y'; $transaction{tradeType} = $messages{'notadebit'}; } # tradeAmount only contains numbers and decimal points, allow 123.1 for moment if ( $transaction_array[8] !~ /^\d+$/ && $transaction_array[8] !~ /^\d+\.\d{1,2}$/ ) { $error{'tradeAmount'} = 'y'; } # convert to standard transaction input format, fields etc. #fromregistry : chelsea $transaction{fromregistry} = $transaction_array[3]; # home : http://cclite.caca-cola.com:83/cgi-bin/cclite.cgi, for example # $transaction{home} = ""; # no home, not a web transaction # subaction : om_trades $transaction{subaction} = 'om_trades'; #toregistry : dalston $transaction{toregistry} = $transaction_array[4]; #tradeAmount : 23 $transaction{tradeAmount} = $transaction_array[8]; #tradeCurrency : ducket $transaction{tradeCurrency} = $transaction_array[5]; #tradeDate : this is date of reception and processing, in fact my ( $date, $time ) = &Ccu::getdateandtime( time() ); # read from configuration file in cron job $transaction{initialPaymentStatus} = $configuration_ref->{'initialpaymentstatus'}; #validate and reformat date ; my $tdate; if ( $transaction_array[0] =~ m/(\d\d)\D(\d\d)\D(\d\d\d\d)/ ) { $tdate = ( length($3) == 0 ) ? $transaction_array[0] : "$3-$2-$1"; $transaction{tradeDate} = $tdate; } else { $error{'tradeDate'} = 'y'; $transaction{tradeDate} = "$transaction_array[0]"; } #tradeTitle : added by this routine $transaction{tradeTitle} = $messages{batchtransaction}; #tradeDescription $transaction{tradeDescription} = $transaction_array[9]; #tradeDestination : ddawg $transaction{tradeDestination} = $transaction_array[2]; #tradeItem : test to see variables #tradeSource : manager $transaction{tradeSource} = $transaction_array[1]; # this is new 01/2006 and needs adding everywhere $transaction{tradeTaxflag} = $transaction_array[7]; # call ordinary transaction my $transaction_ref = \%transaction; my ( $metarefresh, $home, $error, $output_message, $page, $c ); if ( scalar( keys %error ) == 0 ) { # json is the default for this... $transaction_ref->{'mode'} = $fields_ref->{'mode'} || 'json'; #FIXME: transaction has two return signatures if ( $transaction_ref->{'mode'} ne 'json' ) { ( $metarefresh, $home, $error, $output_message, $page, $c ) = transaction( 'batch', $transaction{fromregistry}, 'om_trades', $transaction_ref, $pages, $token ); } else { ($output_message) = transaction( 'batch', $transaction{fromregistry}, 'om_trades', $transaction_ref, $pages, $token ); } print "$output_message \n"; # data is OK but there's something wrong during the transaction if ( length($error) ) { $transaction_ref->{'tradeError'} = '$error'; $error{'tradeError'} = 'y'; } } # add a message to the output transaction and print in output file my $message; if ( scalar( keys %error ) > 0 ) { foreach my $key ( keys %error ) { $transaction_ref->{$key} = "$transaction_ref->{$key}"; } $message = "$messages{transactionrejected}"; $error_count++; } else { $message = $messages{transactionaccepted}; $success_count++; } my $x = Dumper $transaction_ref ; print OUT _prettify_dumper($x) . $message . '

'; } # end of while on csv files my %report = ( 'success', $success_count, 'error', $error_count ); # need to decide how this returns, processes multiple transactions return ( \%report ); }
miniature hack to get dumper output nicer to keep a record for csv transactions but could be useful later for other batchy stuff
sub _prettify_dumper { my ($x) = @_; #$x =~ s/\,//g ; $x =~ s/^([^\{]+)\{//g; $x =~ s/\}\;//g; return $x; }
transaction from oscommerce, authorised with merchantkey this is a work in progress at present.
Several transactions are generated depending on the (Cclite) user in the OsCommerce manufacturer fields. This is the 'link' between the two systems
Currently there's still work to be done to generate a merchant key: hotbits + hashing probably for the moment.
sub oscommerce_transaction { my ( $class, $db, $table, $fieldsref, $token ) = @_; my ( $html, $offset, $limit, $ok, %transaction ); my %fields = %$fieldsref; # for code simplicity, really # test whether the merchant key from the interface = that stored in the registry my ( $merror, $registryref ) = get_where( $class, $fields{registry}, 'om_registry', '*', 'merchant_key', $fields{merchant_key}, $token, $offset, $limit ); # deduce paying 'shopper' from email address sent from osCommerce my ( $uerror, $fromuserref ) = get_where( $class, $fields{registry}, 'om_users', '*', 'userEmail', $fields{email}, $token, $offset, $limit ); # (new 2007) get list of allowed IP addresses for oscommerce and # for straight through RESTful transactions. no list = anything goes! my @allowed_ips = split( /\s+/, $$registryref{allowed_ip_list} ); # loop through allowed ips if ( scalar(@allowed_ips) >= 1 ) { my $found = 0; foreach my $ip (@allowed_ips) { if ( $ip eq $$fieldsref{client_ip} ) { $found = 1; last; } } print "Location: $fields{cancel_url}" if ( !$found ); } # deduce currency from currency symbol sent from osCommerce : only one allowed at present my ( $cerror, $currencyref ) = get_where( $class, $fields{registry}, 'om_currencies', '*', 'code', $fields{currency_code}, $token, $offset, $limit ); my $message = "cclite $fields{version} gateway "; # invalid 'from' user or invalid currency, returns straight away if ( !length($fromuserref) || !length($currencyref) || !length($registryref) ) { $message .= "$messages{merchantkeyerror}:" if ( !length($registryref) ); $message .= "$messages{notregisterederror}->$fields{email}:" if ( !length($fromuserref) ); $message .= "$messages{currencysymbolerror}->$fields{currency_code}:" if ( !length($currencyref) ); print "Location: $fields{cancel_url}?$fields{osCsid}&payment_error=1&error_message=$message\n\n"; } # now construct and do a transaction for each 'manufacturer' who is, in fact a Cclite 'userLogin' # from om_users, each to payment is of form "to:userLogin" # this is two-pass, it needs to make sure that ALL the users (manufacturers) are # present otherwise it won't process ANY of the order. This is cleaner than # partially processing the order. # $ok = 1; foreach my $key ( keys %fields ) { if ( $key =~ /^to:(\w+)/ && $fields{onlinestatus} eq "live" ) { my $touser = $1; # payment destination my ( $terror, $touserref ) = get_where( $class, $fields{registry}, 'om_users', '*', 'userLogin', $touser, $token, $offset, $limit ); $ok = 0 if ( !length($touserref) ); $message .= "$messages{manufacturererror}->$touser" if ( !length($touserref) ); } } # don't go on if even one 'manufacturer' is not found print "Location: $fields{cancel_url}?$fields{osCsid}&payment_error=1&error_message=$message\n\n" if ( !$ok ); foreach my $key ( keys %fields ) { $html .= "$key:$fields{$key}
"; if ( $key =~ /^to:(\w+)/ && $fields{onlinestatus} eq "live" ) { my $touser = $1; # payment destination # convert to standard transaction input format, fields etc. #fromregistry : chelsea $transaction{fromregistry} = $fields{registry}; $transaction{home} = ""; # no home, not a web transaction #subaction : om_trades $transaction{subaction} = 'om_trades'; #toregistry : chelsea, single registry only, currently $transaction{toregistry} = $fields{registry}; #tradeAmount : 23 : this value is in the to:userLogin key is quantity $transaction{tradeAmount} = $fields{$key}; #tradeCurrency : ducket $transaction{tradeCurrency} = $$currencyref{name}; #tradeDate : 20050423 # added by transaction routine at point of processing # configured intial status in cclite.cf $transaction{tradeStatus} = $fields{initialPaymentStatus}; #tradeDescription : test $transaction{tradeTitle} = "store payment from osc: $fields{item_id}"; #tradeDestination : ddawg $transaction{tradeDestination} = $touser; #tradeItem : test to see variables #tradeSource : manager $transaction{tradeSource} = $$fromuserref{userLogin}; # trade tax flag $transaction{tradeTaxflag} = $fields{taxflag}; # make a reference to the transaction hash and # call ordinary transaction my $transaction_ref = \%transaction; if ($ok) { my ( $metarefresh, $home, $error, $output_message, $page, $c ) = transaction( 'osc', $transaction{fromregistry}, 'om_trades', $transaction_ref, "", $token ); } # endif } # endif: search for manufacturers } # end foreach if ( $fields{onlinestatus} eq "live" ) { print "Location: $fields{return_url}?$fields{osCsid}\n\n"; } else { return ( "0", $fields{home}, "", $html, "result.html", "" ); } } 1;


---
layout: post
title: EDUCATION - Unpicking Hyper Island's Pedagogy
categories: []
tags: []
status: draft
type: post
published: false
meta: {}
---
- Personal development
- Professional development
- Experience/Project/Problem-Based Learning
- Accredited
- Encounter groups
- Industry-led and focused
http://shapingtheparish.com/storage/About%20T-groups.pdf


This module contains the tests to the class PyGraphParser in module PyGraphParser.
This test serves to ensure the viability of the methods of the class PyGraphParser in PyGraphParser.py.
This class contain the test methods if the class PyGraphParser.
Methods
Raise an assertion if can’t set annotation end.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set annotation start.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the annotation set start.
Used to parse <annotationSet .../> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the annotation sapce start.
Used to parse <annotationSpace .../> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the end of the annotation set.
Used to parse end /as> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the start of the annotation set.
Used to parse start <as/ ...> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the character.
Processes any characters within the xml file. It’s a method from ContentHandler class.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set the dependencies.
Used to parse dependsOn elements in the XML representation. Finds other XML annotation files on which depend the current XML file. Parses the dependency files and adds the resulting graph to the current graph.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set edge.
Used to parse edge elements in the XML representation. Edge information is stored and the edges are added after all nodes/spans have been parsed.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t find the node to end.
Processes the end xml tags, according to their type. It’s a method from ContentHandler class.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set the feature end.
Used to parse end features elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set feature start.
Used to parse start features elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set inside feature end.
Used to parse </fs> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set inside feature start.
Used to parse <fs> elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the tag value.
Executes when the parser encounters the end graph tag. Sets the root node and adds all the edges to the graph. Neither of these tasks can be safely performed until all nodes have been added.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set the tag value.
Processes the opening xml tags, according to their type. It’s a method from ContentHandler class.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set the link.
Used to parse link elements in the XML representation.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t set the tag value.
Executes when the parser encounters the end graph tag. Sets the root node and adds all the edges to the graph. Neither of these tasks can be safely performed until all nodes have been added.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set the tag value.
Executes when the parser encounters the end graph tag. Sets the root node and adds all the edges to the graph. Neither of these tasks can be safely performed until all nodes have been added.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t find a file.
Return a PyGraph.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t set region.
Used to pare the region elements in the XML representation. A tolkenizer is used to separate the anchors listed in the XML tag, and a new PyAnchor instance is created for each one. A PyRegion instance is then created with the id from the XML tag and added to the graph.
| Raises : | AssertionError : If can’t set the value. : |
|---|
Raise an assertion if can’t find the end root.
Used to parse end root elements in the XML representation.
| Raises : | AssertionError :
|
|---|
Raise an assertion if can’t find the start root.
Used to parse start root elements in the XML representation. The root characters are processed by the characters() method and stored in self._buffer.
self._root_element is a flag indicating the presence of a root.
| Raises : | AssertionError :
|
|---|


Introduction
CS 148 is an introduction to core topics in the modeling and control of autonomous robots. This course focuses on the development of “brains for robots”. That is, given a robot as a machine with sensing, actuation, and computation, how do we develop programs that allow the robot to function autonomously? Such programs involve the robot's perception of its world, decision making towards some objective, and transforming decided actions into motor commands. These are functions commonly used in modern robotics, such as for the PR2 (below).
This year, CS148 projects will model and control robots through projects written in JavaScript/HTML5. These projects will be supported by the 3jsbot code stencil, which uses threejs for in-browser 3D rendering. We will roughly follow software models from the Robot Operating System (ROS) robot middleware framework, such as the URDF kinematic modeling format. Projects will cover 3D geometric transforms, compositions of matrix transforms, forward kinematics, axis-angle rotation by quaternions, proportional-derivative control, inverse kinematics, simple collision detection, and RRT motion planning, along with coverage of potential field navigation, Monte Carlo localization, and Newton-Euler dynamics.
Instructor
Chad Jenkins
Office Hours
Monday 10:30-12
Thursday 1-2 (when not conflicting with travel)
Prof. Jenkins administative support person is Suzanne Alden.
Meeting time/place
Monday 3:00-5:20 (M Hour) in CIT 368
Mailing list
<EMAIL_ADDRESS>UPDATED: from incorrect pointer to Fall 2011 mailing list
Prerequisites
Any one of the following: CS15, CS17, CS19, or permission from the instructor
CS 15, 17, or 19 should provide an adequate programming background for the projects in this course. In addition, motivated students who have taken CS 4 should consult with the instructor before enrolling in CS148. Interested students who have not taken any of these courses at Brown, but have some other strong programming experience should consult with course instructor.
Highly Recommended: Linear alegebra
Recommended: computer graphics, computer vision, AI
I will do my best to cover the necessary material, but no guarantees. Linear algebra will be used extensively for representing 3D geometric transforms. Computer graphics is helpful for under-the-hood understanding of threejs. Computer vision and AI share common concepts with this course.
Textbook
Robot Modeling and Control
Mark W. Spong, Seth Hutchinson and M. Vidyasagar
Wiley, 2005
Projects and Grading
There will be 6 projects in CS148: 5 programming assignment and 1 oral/written assignment. CS 148 projects are graded as “checked” (completed) or “not checked” (incomplete). To receive an A grade in the course, you must have all assignments checked by the end of reading period. For a B grade, 4 assignments must be checked. Less than 4 checks will result in no credit for the course. The timing and due dates for these projects will be announced on an ongoing basis. Git repositories will be used for project implementation, version control, and submission. Project implementations are submitted as branches in your assigned repository. These branches must be submitted prior to the due date for each assignment. Your implementation will be checked out and executed by the course staff. You will be notified by the course staff whether your implementation is sufficient for checking off the assignment. If your assignment is insufficient for receiving a check, your group is allowed one regrade (per assignment) with 2 weeks of notification. If deemed necessary, the course staff may require an interactive demonstration of your implementation and/or a web-based written report.
Repositories
The course staff will provide a git repository (through github) for each student group to check in project source code and reports, unless you request using separate service or repository. Please refer to this tutorial for an in-depth introduction to git and version control. Although it has a coarse language choice, this is also a great and accessible tutorial. We expect students to use these repositories for collaborative development as well as project submission. It is the responsibility of each student group to ensure their repository adheres to the Collaboration Policy and submission standards for each assignment. Submission standards and examples will be described for each assignment.
Do not be late submitting assignments. The course staff reserves the right to not grade late submissions.
CS148 can be taken for 200-level (graduate) credit. For 200-level credit, a grad of A must be earned.
This policy covers all course material and assignments unless otherwise stated. Course material and Turtlebot/ROS information and documentation may be discussed with anyone. Course material does not include assignment handouts. Assignments may be discussed with the other cs148 students. Discussions may make use of a whiteboard or paper. Discussions outside of your group cannot include writing or debugging code on a computer. You may take notes away from these discussions, provided these notes do not include any source code.
The code for your implementation may not be shown to anyone outside of your group, including granting access to repositories or careless lack of protection. You do not need to hide the screen from anyone, but you should not attempt to show anyone your code. When you are done using any robot device such that another group may use it, you must remove all code you have put onto the device. You may not share your code with others outside of your group. At any time, you may show others the implemented program running on a device or simulator, but you may not discuss specific debugging details about your code while doing so.
Should you fail to abide by this policy, you will receive no credit for this course. Brown also reserves the right to pursue any means necessary to ensure compliance. This includes, but is not limited to prosecution through Brown University’s Student Conduct Procedures, which can result in your suspension or expulsion from the University
Due 9am, Monday, February 3, 2014
In this assignment, you should clone the 3jsbot_stencil repository as your working repository for the course. 3jsbot_stencil contains a code stencil for the assignment and projects in the course. If you open "home.html" in this repository, you should see the jittering disconnected pieces of a robot (described in "robots/br2.js"), similar to the follwing snapshot:
Your task is to make these objects responsive to keyboard commands, specifically to move upward and stop/start jittering (although more is encouraged). To do this, you will modify "home.html" within the sections delimited by "// CS148: INITIAL GETTING FAMILIAR CODE". These sections also include code examples meant to be a quick (and very rough) introduction to JavaScript, assuming programming competency in another language.
Please be sure that the course instructor knows what repository you are using, and your branch is created and not modified past the deadline.
In the next assignment, we will put these pieces together to form the robot described in "robots/br2.js".
Please email Suzanne Alden<EMAIL_ADDRESS>with your name, email address, and pointer to your repository.
Also, please ensure the instructor has read/commit access to your repository. Such issues can be addressed through email or office hours.
Late Policy
200-Level Credit
Collaboration Policy
Tentative Schedule
Assignment 1: Getting familiar with 3jsbot
Update


This is an example page for the
jp_doodle
package.
jp_doodle
makes implementing special purpose interactive visualizations easy.
Quick references: Javascript API; Python API.
Miscellaneous Demos: Image detail viewer..
These example pages use stand alone Javascript, but the code used to implement them can be transliterated to Python and implemented using Jupyter widgets (modulo some subtleties).The directed network widget allows interactive exploration of directed weighted network structures. It was developed to facilitate the exploration and comparison of gene regulatory networks which are inferred using different methodologies.
The widget allows the user to:
The widget also includes a large number of configuration options which do not have corresponding visual controls which can be set upon initialization or modified subsequently.
The "relax" and "skeleton" layout methods use a gradient descent heuristic to find a layout for the nodes which reflects the edge weights between connected nodes. These layout methods can be slow if there are a large number of nodes and edges visible. The "wiggle" operation applies that heuristic for a limited number of steps. The "grid" layout just puts the nodes in a rectangular array without considering the edge weights.


Neste makes Melbourne move
by Staff reporterAUSTRALIA – Through its new Melbourne office renewable diesel producer Neste plans to ramp up the sourcing of raw materials in the region.
The world’s leading producer of renewable diesel – from waste and residues – currently has a capacity to produce 3 million tons of renewable products annually from its facilities worldwide. The new office is just the latest step in its global expansion strategy.
“The opening of our new office in Australia marks another important step in Neste’s global growth strategy. Our aim is to become a global leader in renewable and circular solutions. By opening a local office, we are better placed to cooperate closely with our partners to secure the supply of waste and residue raw materials. This in turn enables us to serve the growing global demand for low-carbon solutions in transport and cities, aviation, polymers and chemicals,” said Matti Lehmus, Executive Vice President of Renewables Platform at Neste.


The history library supports a history expansion feature that is identical to the history expansion in bash. This section describes what syntax features are available.
History expansions introduce words from the history list into the input stream, making it easy to repeat commands, insert the arguments to a previous command into the current input line, or fix errors in previous commands quickly.
History expansion is usually performed immediately after a complete line is read. It takes place in two parts. The first is to determine which line from the history list to use during substitution. The second is to select portions of that line for inclusion into the current one. The line selected from the history is the event, and the portions of that line that are acted upon are words. Various modifiers are available to manipulate the selected words. The line is broken into words in the same fashion as bash does when reading input, so that several words that would otherwise be separated are considered one word when surrounded by quotes (see the description of history_tokenize() below). History expansions are introduced by the appearance of the history expansion character, which is ! by default. Only backslash (\) and single quotes can quote the history expansion character.
An event designator is a reference to a command line entry in the history list.
Word designators are used to select desired words from the event. A : separates the event specification from the word designator. It may be omitted if the word designator begins with a ^, $, *, -, or %. Words are numbered from the beginning of the line, with the first word being denoted by 0 (zero). Words are inserted into the current line separated by single spaces.
If a word designator is supplied without an event specification, the previous command is used as the event.
After the optional word designator, there may appear a sequence of one or more of the following modifiers, each preceded by a ‘:’.
The programmer using the History library has available functions for remembering lines on a history list, associating arbitrary data with a line, removing lines from the list, searching through the list for a line containing an arbitrary text string, and referencing any line in the list directly. In addition, a history expansion function is available which provides for a consistent user interface across different programs.
The user using programs written with the History library has the benefit of a consistent user interface with a set of well-known commands for manipulating the text of previous lines and using that text in new commands. The basic history manipulation commands are identical to the history substitution provided by bash.
If the programmer desires, he can use the Readline library, which includes some history manipulation by default, and has the added advantage of command line editing.
Before declaring any functions using any functionality the History library provides in other code, an application writer should include the file <readline/history.h> in any file that uses the History library’s features. It supplies extern declarations for all of the library’s public functions and variables, and declares all of the public data structures.
The history list is an array of history entries. A history entry is declared as follows:
typedef void * histdata_t;
typedef struct _hist_entry { char *line; char *timestamp; histdata_t data; } HIST_ENTRY;
The history list itself might therefore be declared as
HIST_ENTRY ** the_history_list;
The state of the History library is encapsulated into a single structure:
/* * A structure used to pass around the current state of the history. */ typedef struct _hist_state { HIST_ENTRY **entries; /* Pointer to the entries themselves. */ int offset; /* The location pointer within this array. */ int length; /* Number of elements within this array. */ int size; /* Number of slots allocated to this array. */ int flags; } HISTORY_STATE;
If the flags member includes HS_STIFLED, the history has been stifled.
This section describes the calling sequence for the various functions exported by the GNU History library.
void using_history void
Begin a session in which the history functions might be used. This initializes
the interactive variables.
HISTORY_STATE * history_get_history_state void
Return a structure describing the current state of the input history.
void history_set_history_state HISTORY_STATE *state
Set the state of the history list according to state.
These functions manage individual entries on the history list, or set parameters managing the list itself.
void add_history const char *string
Place string at the end of the history list. The associated data field
(if any) is set to NULL.
void add_history_time const char *string
Change the time stamp associated with the most recent history entry to
string.
HIST_ENTRY * remove_history int which
Remove history entry at offset which from the history. The removed element
is returned so you can free the line, data, and containing structure.
histdata_t
free_history_entry HIST_ENTRY *histent
Free the history entry histent and any history library private data associated
with it. Returns the application-specific data so the caller can dispose
of it.
HIST_ENTRY * replace_history_entry int which, const char *line,
histdata_t data
Make the history entry at offset which have line and data. This returns
the old entry so the caller can dispose of any application-specific data.
In the case of an invalid which, a NULL pointer is returned.
void clear_history
void
Clear the history list by deleting all the entries.
void stifle_history
int max
Stifle the history list, remembering only the last max entries.
int unstifle_history
void
Stop stifling the history. This returns the previously-set maximum number
of history entries (as set by stifle_history()). history was stifled. The
value is positive if the history was stifled, negative if it wasn’t.
int
history_is_stifled void
Returns non-zero if the history is stifled, zero if it is not.
These functions return information about the entire history list or individual list entries.
HIST_ENTRY ** history_list void
Return a NULL terminated array of HIST_ENTRY * which is the current input
history. Element 0 of this list is the beginning of time. If there is no
history, return NULL.
int where_history void
Returns the offset of the current history element.
HIST_ENTRY * current_history
void
Return the history entry at the current position, as determined by where_history().
If there is no entry there, return a NULL pointer.
HIST_ENTRY * history_get
int offset
Return the history entry at position offset, starting from history_base.
If there is no entry there, or if offset is greater than the history length,
return a NULL pointer.
time_t history_get_time HIST_ENTRY *
Return the time stamp associated with the history entry passed as the
argument.
int history_total_bytes void
Return the number of bytes that the primary history entries are using.
This function returns the sum of the lengths of all the lines in the history.
These functions allow the current index into the history list to be set or changed.
int history_set_pos int pos
Set the current history offset to pos, an absolute index into the list.
Returns 1 on success, 0 if pos is less than zero or greater than the number
of history entries.
HIST_ENTRY * previous_history void
Back up the current history offset to the previous history entry, and
return a pointer to that entry. If there is no previous entry, return a
NULL pointer.
HIST_ENTRY * next_history void
Move the current history offset forward to the next history entry, and
return the a pointer to that entry. If there is no next entry, return a
NULL pointer.
These functions allow searching of the history list for entries containing a specific string. Searching may be performed both forward and backward from the current history position. The search may be anchored, meaning that the string must match at the beginning of the history entry.
int history_search const char *string,
int direction
Search the history for string, starting at the current history offset.
If direction is less than 0, then the search is through previous entries,
otherwise through subsequent entries. If string is found, then the current
history index is set to that history entry, and the value returned is the
offset in the line of the entry where string was found. Otherwise, nothing
is changed, and a -1 is returned.
int history_search_prefix const char *string,
int direction
Search the history for string, starting at the current history offset.
The search is anchored: matching lines must begin with string. If direction
is less than 0, then the search is through previous entries, otherwise
through subsequent entries. If string is found, then the current history
index is set to that entry, and the return value is 0. Otherwise, nothing
is changed, and a -1 is returned.
int history_search_pos const char *string,
int direction, int pos
Search for string in the history list, starting at pos, an absolute index
into the list. If direction is negative, the search proceeds backward from
pos, otherwise forward. Returns the absolute index of the history element
where string was found, or -1 otherwise.
int read_history const char
*filename
Add the contents of filename to the history list, a line at a time. If
filename is NULL, then read from ~/.history. Returns 0 if successful, or
errno if not.
int read_history_range const char *filename, int from, int
to
Read a range of lines from filename, adding them to the history list. Start
reading at line from and end at to. If from is zero, start at the beginning.
If to is less than from, then read until the end of the file. If filename
is NULL, then read from ~/.history. Returns 0 if successful, or errno if
not.
int write_history const char *filename
Write the current history to filename, overwriting filename if necessary.
If filename is NULL, then write the history list to ~/.history. Returns 0
on success, or errno on a read or write error.
int append_history int
nelements, const char *filename
Append the last nelements of the history list to filename. If filename
is NULL, then append to ~/.history. Returns 0 on success, or errno on a read
or write error.
int history_truncate_file const char *filename, int nlines
Truncate the history file filename, leaving only the last nlines lines.
If filename is NULL, then ~/.history is truncated. Returns 0 on success,
or errno on failure.
These functions implement history expansion.
int history_expand char *string, char **output
Expand string, placing the result into output, a pointer to a string.
Returns:
If an error ocurred in expansion, then output contains a descriptive error message.
- If no expansions took place (or, if the only change in the text was the removal of escape characters preceding the history expansion character);
- if expansions did take place;
- -1
- if there was an error in expansion;
- if the returned line should be displayed, but not executed, as with the :p modifier.
char * get_history_event const char *string, int *cindex,
int qchar
Returns the text of the history event beginning at string + *cindex. *cindex
is modified to point to after the event specifier. At function entry, cindex
points to the index into string where the history event specification begins.
qchar is a character that is allowed to end the event specification in
addition to the ‘‘normal’’ terminating characters.
char ** history_tokenize
const char *string
Return an array of tokens parsed out of string, much as the shell might.
The tokens are split on the characters in the history_word_delimiters variable,
and shell quoting conventions are obeyed.
char * history_arg_extract int
first, int last, const char *string
Extract a string segment consisting of the first through last arguments
present in string. Arguments are split using history_tokenize().
This section describes the externally-visible variables exported by the GNU History Library.
int history_base
The logical offset of the first entry in the history list.
int history_length
The number of entries currently stored in the history list.
int history_max_entries
The maximum number of history entries. This must be changed using stifle_history().
int history_write_timestamps
If non-zero, timestamps are written to the history file, so they can be
preserved between sessions. The default value is 0, meaning that timestamps
are not saved.
char history_expansion_char
The character that introduces a history event. The default is !. Setting
this to 0 inhibits history expansion.
char history_subst_char
The character that invokes word substitution if found at the start of
a line. The default is ^.
char history_comment_char
During tokenization, if this character is seen as the first character
of a word, then it and all subsequent characters up to a newline are ignored,
suppressing history expansion for the remainder of the line. This is disabled
by default.
char * history_word_delimiters
The characters that separate tokens for history_tokenize(). The default
value is " \t\n()<>;&|".
char * history_no_expand_chars
The list of characters which inhibit history expansion if found immediately
following history_expansion_char. The default is space, tab, newline, \r,
and =.
char * history_search_delimiter_chars
The list of additional characters which can delimit a history search string,
in addition to space, tab, : and ? in the case of a substring search. The
default is empty.
int history_quotes_inhibit_expansion
If non-zero, single-quoted words are not scanned for the history expansion
character. The default value is 0.
rl_linebuf_func_t * history_inhibit_expansion_function
This should be set to the address of a function that takes two arguments:
a char * (string) and an int index into that string (i). It should return
a non-zero value if the history expansion starting at string[i] should not
be performed; zero if the expansion should be done. It is intended for use
by applications like bash that use the history expansion character for
additional purposes. By default, this variable is set to NULL.
Chet Ramey, Case Western Reserve University
<EMAIL_ADDRESS>Once you have determined that a bug actually exists, mail a bug report to<EMAIL_ADDRESS>If you have a fix, you are welcome to mail that as well! Suggestions and ‘philosophical’ bug reports may be mailed to<EMAIL_ADDRESS>or posted to the Usenet newsgroup gnu.bash.bug.
Comments and bug reports concerning this manual page should be directed to chet@ins.CWRU.Edu.


Welcome to CHS Site Unblocker
Visits:
Enter your website below
Submit (refresh before submiting another)
DISCLAIMER


The following people in your organization will need to provide their consent for a security assessment and financial check. An email will be sent to each person with a unique login link to provide their consent.
You will need to provide consent for a security screening and financial assessment. An email will be sent to you with a unique login link to provide consent.


| Supported Filters | Usage | |
| [!][filter] | [filter] = photos, attachment, note, citations, restriction e.g. photos returns all people with photos, !note returns all people with no notes. | |
| [living] or [deceased] | e.g. living returns all living people. | |
| [male] or [female] | e.g. female returns all living people. | |
| [age]-[age] | For age ranges e.g. 0-16 returns people ages 0 to 16 years. | |
| [age]+ | For age ranges e.g. 64+ returns people over 64. | |
| [dd]/[mm] or [mm]/[yyyy] | For dates of birth e.g. 01/10 returns people born on 1st October or 10/1999 returns people born in October 1999. |


Undocumented
| Class | MiniPrint |
print dimension when changed and a single symbol for each call. |
| Class | ObserverOptions |
a dict with observer options which can be passed to the (C-based) Observer via the as_string property. |
| Class | ProblemNonAnytime |
The non-anytime problem class. |
| Class | SameFunction |
Count the number of consecutive instances of the same function. |
| Class | ShortInfo |
print minimal info during benchmarking. |
| Function | about_equal |
Return True if the floating point number ${a} and ${b} are about equal. |
| Function | args_to_dict |
return a dict from a list of "name=value" strings. |
| Function | ascetime |
return elapsed time as str. |
| Function | print_flush |
print without newline but with flush |
return a dict
from a list of "name=value" strings.
args
come in the form of a list
of "name=value" strings
without spaces, like ["budget_multiplier=100"].
Return dict(arg.split(split) for arg in args) in the most
basic case, but additionally (i) checks that the keys of this
dict
are known names, (ii) evaluates the values in some cases
and (iii) handles specials
.
know_names
is an iterable (dict
or list
or tuple
) of strings.
If know_names is None, all args are processed, otherwise a
ValueError
is raised for unknown names. This is useful if we
want to re-assign variables (overwrite default values) and avoid
spelling mistakes pass silently.
The value is processed as a Python literal with ast.literal_eval
or remains a str
when this is unsuccessful.
specials
is a dict
and can currently only contain 'batch',
followed by "name1/name2" as value. name1 and name2 are
then assigned from the values in arg
, for example to 2 and 4 with
batch=2/4.
A main usecase is to process sys.argv[1:] into a dict
in a
python script, like:
command_line_dict = args_to_dict(sys.argv[1:], globals()) globals().update(command_line_dict)
>>> import cocoex >>> d = cocoex.utilities.args_to_dict(["budget=2.3", "bed=bed-name", "number=4"], ... ["budget", "bed", "number", "whatever"]) >>> len(d) 3 >>> assert d['bed'] == 'bed-name' >>> assert isinstance(d["budget"], float)


Test cards
You can use the sample credit cards below to trigger different responses from our gateway. You can use them on test accounts, but not on your live account.
Approved
| Brand |
Card number |
CVV |
| Visa |
4030000010001234 |
123 |
| Mastercard |
5100000010001004 |
123 |
| Mastercard (2-series BIN) |
2223000048400011 |
123 |
| American Express |
371100001000131 |
1234 |
| DISCOVER |
6011500080009080 |
123 |
Declined
| Brand |
Card number |
CVV |
| Visa |
4003050500040005 |
123 |
| Mastercard |
5100000020002000 |
123 |
| American Express |
342400001000180 |
1234 |
| DISCOVER |
6011000900901111 |
123 |
3D Secure
| Brand |
Card number |
CVV |
Password |
| Visa (Verified by Visa) |
4123450131003312 |
123 |
12345 |
| Mastercard (SecureCode) |
5105105105105100 |
123 |
12345 |
| American Express (SafeKey) |
71449635398431 |
1234 |
12345 |
Test amounts
| Brand |
Card number |
CVV |
| Visa |
4504481742333 |
123 |
- Approved for transactions less than $100
- Declined for transactions higher than $100
AVS
All billing addresses in the Canada or the United States will trigger an AVS response. You can trigger an approved AVS response on all test cards with the same street address and postal code:
- Street address - 1407 Graymalkin Lane
- Postal code - 111 111


LC Select
Superlight vanilla javascript dropdowns, by
LCweb
Simple (with images, search and prepended placeholder option)
Italy
France
Spain
Japan
Korea
China
Multiple (max 2 selectable options)
Lorem
Ipsum
Dolor


 We saw nutmeg on a list of hallucinogens and said, 'what the hell.' Big mistake.
Between the two of us we finished an entire bottle.  I had no perception of time and my very short-term memory was fried. I vaguely recall going from house to house with my friend, aimlessly. I played video games at my friend's house for awhile, but I didn't even have the attention span for that. I felt incredibly stupid, but I did not care. I didn't care about anything.
At one point in the night I actually thought I was going to die of heart failure, because it was pounding out of my chest. Somehow, I ended up at my girlfriend's house in the middle of her family barbecue. It was at this point (6 hours after ingestion) that I began to get worried. It was not wearing off, but the strange sensation of detachment from reality was growing. I told her what was going on and she helped me into her basement where it was dark. I was hearing voices and other strange sounds that seemed just out of my realm of comprehension. It intensified exponentially and I knew at this point I was having a 'bad trip.'
I was lying down on her couch and I kept hearing bizarre sounds above my head and my body was beginning to twitch. It was like sensory overload; I felt like my body couldn't take it anymore and I would just explode. It was at this point that I thought I was going to die, but I didn't care. I was getting visual hallucinations out of my peripheral vision that left me feeling very vulnerable and helpless. I had my girlfriend take me outside where I preceeded to puke my guts out in front of all my friends. If I was in a distance puking contest I would have won. I had never thrown up before but I have seen other people do it, and what I did was completely different. The puke must have shot out of my body at mach 5 and I proceeded to have dry heaves for another half hour.
Things still weren't getting better, I was feeling more and more detached from reality. Let me try and explain. My vision told me that the floor was flat, but my mind interpreted it as completely contorted. You can imagine what this conflict between my eyes and mind did to my motor skills. Somehow, I got to a bed in her house and fell asleep. When I woke up I was still far from OK. The same detachment, but without the visuals (thank GOD!!!). I lay in a nutmeg stupor, if you will, for the entire day while my girlfriend took care of me (awww, how sweet). I had the WORST drymouth I had ever experienced and my breath reeked of nutmeg for weeks, no joke. I finally felt normal the next day.
Experience Reports are the writings and opinions of the individual authors who submit them.
Some of the activities described are dangerous and/or illegal and none are recommended by Erowid.


The AVICENNA project
Towards a holistic description of carcinogenesis.
The first parallel, multi-scale and multi-physics tissue simulation engine in 3D.
Welcome
AVICENNA++ is a high performance, multi-scale, bio-electro-chemical code in parallel environment and on adaptive Voronoi grids. We utilize the level-set methodology to represent the cell membranes and use the Voronoi Interface Method (VIM) to solve the transmembrane potential with unprecedented accuracy.
AVICENNA is the parent project whose scope spans scientific investigation of the produced simulation datasets in pursuit of a predictive theory for cancer as a developmental disease.
Here we will keep a record of the progress of this project, and will present our key results, supplementary movies, snapshots, etc.
News
Updates on the AVICENNA project:
July 13, 2018: Multiple ion concentrations are successfully included!
July 7, 2018: Diffusion and advection of the ions under local electric field works in parallel!
January 2018: Cell membrane electro-permeabilization works in parallel. First multi-scale direct simulations of cell aggregate electro-permeabilization.
People in the AVICENNA project.
Physical modeling, algorithm design, code development, simulation planning, data analysis and visualization:
| Name | |
|---|---|
| Frederic Gibou [PI] | fgibou [at] ucsb [dot] edu |
| Pouria Mistani | pouria [at] ucsb [dot] edu |


library(SIMPLEs)
library(doParallel)
#> Loading required package: foreach
#> Loading required package: iterators
#> Loading required package: parallel
library(foreach)
# SIMPLEs may need parallel to speed up.
registerDoParallel(cores = 8)
If you have the single cell data, for which each row is the gene, and each column is the cell, the content is the log normalized TPM or RPKM, you can directly use SIMPLEs
as followed:
Here we introduce the function to simulate the single cell data and the corresponding RNASeq bulk data.
simulation_bulk <- function(n = 300, S0 = 10, K = 3, MC = 2, block_size = 50, overlap = 15, indepG = 30, dropout = 0.3) {
B = NULL
W = NULL
Lambda = NULL
# sample Y from Factor model, Y = BW + E, W: K*n, Y: G*n, E: G*n
Z = rmultinom(n, 1, rep(1/MC, MC))
Z = apply(Z, 2, which.max)
Z = sort(Z)
if (K > 0) {
# generate data
G = block_size + (K - 1) * (block_size - overlap) + indepG #120
} else {
G = indepG
}
Sigma = rgamma(G, 2, 1/0.3) #rnorm(G, 0.6, 0.1)
Mu = exp(rnorm(G, mean = 0.5, sd = 0.5)) %*% t(rep(1, MC))
act_ind = sample(1:G, S0 * MC)
label0 = matrix(0, G, MC)
# specify mean for each cluster
for (m in 1:MC) {
ss = ((m - 1) * S0 + 1):(m * S0)
Mu[act_ind[ss], m] = Mu[act_ind[ss], m] * sample(c(0.2, 0.5, 1.2, 1.5, 2), S0, replace = T)
label0[act_ind[ss], m] = 1
}
if (K > 0) {
# Factor Loading
Gamma <- matrix(0, G, K)
Gamma[1:block_size, 1] <- 1
if (K > 1) {
for (i in 1:K) {
Gamma[((block_size - overlap) * (i - 1) + 1):
(block_size + (block_size - overlap) * (i - 1)), i] <- 1
}
}
B = Gamma/4 #sqrt(block_size) # eigenvalue of BB^T = block_size * B^2
# specify variance for each cluster
Lambda = list()
for (m in 1:MC) {
Lambda[[m]] = diag(1, K, K)
}
# matrix(rnorm(K*n), K, n) # K * n
W = sapply(Z, function(z) mixtools::rmvnorm(1, rep(0, K), Lambda[[z]]))
E = matrix(rnorm(G * n), nrow = G) * Sigma
Y = Mu[, Z] + B %*% W + E
} else {
Y = matrix(rnorm(G * n, Mu[, Z], Sigma), nrow = G)
}
# add dropout
Y2 = Y
dZ = matrix(rbinom(G * n, 1, exp(-dropout * rowMeans(Mu)^2)), nrow = G) # 0.3
Y2[dZ == 1] = 0
Y2[Y2 < 0] = 0
ind = which(rowSums(Y2 != 0) > 4)
Y2 = Y2[ind, ]
Y = Y[ind, ]
label0 = label0[ind, ]
B = B[ind, ]
Mu = Mu[ind, ]
Sigma = Sigma[ind]
return(list(Y2 = Y2, Y = Y, B = B, W = W, Mu = Mu,
Lambda = Lambda, Sigma = Sigma, Z = Z, bulk = rowMeans(Mu[, Z]), S_label = label0))
}
We then use this function to simulate the input data for SIMPLEs
, and run it. We simulate 1000 genes expressedn in 300 cells. The cells are composed of 3 clusters. In each cluster, we select 20 genes as the cluster specific genes, which are differentially # expressed in different clusters. Meanwhile, the genes have K=3 modules, each of which has block_size=100 genes with the overlap=55 genes shared by two consecutive groups given an order of the group. The drop rate is 0.3.
n_cell <- 300
simu_data <- simulation_bulk(n=n_cell, S0=20, K=3, MC=3, block_size=100, indepG=1000-190,
overlap=55, dropout=0.3)
celltype_true = simu_data$Z
Then run SIMPLEs with or without bulk data.
simple_res <- SIMPLE(simu_data$Y2, K0=3, M0=3,p_min=0.6,max_lambda = T,cutoff=0.01)
# if we have the bulk data
simpleb_res <- SIMPLE_B(simu_data$Y2, K0=3, bulk=data.frame(simu_data$bulk),
celltype=rep(1,n_cell), M0=3,p_min=0.6,max_lambda = T,cutoff=0.01)
We can evaluate the clustering results and get the tsne plot from the imputed data. SIMPLEs will output the clusters of cells but we can also re-do the clustering with the imputation results from SIMPLEs. Sometimes, re-do the clustering can get better result.
# get the cluster infered from SIMPLEs
simple_infered_cluster <- apply(simple_res$z, 1, which.max)
# if we have use the SIMPLE_B
simpleb_infered_cluster <- apply(simpleb_res$z, 1, which.max)
# re-do the clustering. Only use the result from SIMPlE as an example.
scaled_data <- t(scale(t(simple_res$impt)))
s <- svd(scaled_data)
km <- kmeans(t(scaled_data) %*% s$u[, 1:20], 3, iter.max=80, nstart=300)
Compared with the true clusters, we can compute adjusted rand index as following:
library(mclust)
# between 0 and 1; the larger, the better
cluster_score <- mclust::adjustedRandIndex(km$cluster, celltype_true)
cluster_score1 <- mclust::adjustedRandIndex(simple_infered_cluster, celltype_true)
Besides clustering, we can use tsne and ggplot to bview the imputation result.
library(Rtsne)
library(ggplot2)
# for reproducible, we set the seed to tsne.
set.seed(0)
tsne_res <- Rtsne::Rtsne(t(simple_res$impt), pca_scale=T, pca_center=T, initial_dims=20,
pca = T)
partial_tsne <- data.frame(cbind(tsne_res$Y[, 1:2]), celltype_true)
colnames(partial_tsne) <- c("TSNE1", "TSNE2", "Type")
p <- ggplot(partial_tsne, aes(x = TSNE1, y=TSNE2, color=Type)) + geom_point() + theme_bw()
plot(p)
The single cell RNASeq and the bulk RNASeq data from the human embryonic stem cell differentiation towards definitive endoderm are used as the real data study. There are 7 cell types in this dataset. As the dataset is large, we randomly selected part of the original data, and put it in our R package under data
directory. For details, you can use ?chu
to see the help document of the dataset.
Now we can use SIMPLEs on the real data.
ncell = ncol(chu$chu_normalized_data)
chu_simpleb_res <- SIMPLE_B(chu$chu_normalized_data,
bulk=data.frame(chu$chu_bulk_mean),
celltype=rep(1,ncell), K0=10, M0=7,max_lambda = T)
We can re-do the clustering using the same procedure above. We didn’t get perfect score because we only subsampled 3000 genes and H1/H9 are hard to distinguish.
scaled_data <- t(scale(t(chu_simpleb_res$impt)))
s <- svd(scaled_data)
km <- kmeans(t(scaled_data) %*% s$u[, 1:20], 7, iter.max=80, nstart=300)
cluster_score = mclust::adjustedRandIndex(km$cluster, chu$chu_cell_type)
We can add more dropouts given a dropout rate.
dropP <- 0.3
G <- nrow(chu$chu_normalized_data)
n <- ncol(chu$chu_normalized_data)
Z <- matrix(rbinom(G*n, 1, exp(-dropP * rowMeans(chu$chu_normalized_data))),
nrow=G)
more_dropout_data <- chu$chu_normalized_data
more_dropout_data[Z==1] <- 0
We can test SIMPLEs on the modified data to see its imputation result by the mean square error.
chu_more_dropout_impute <- SIMPLE_B(more_dropout_data, celltype=rep(1,ncell),
K0=10, M0=7,bulk=data.frame(chu$chu_bulk_mean))
# the smaller, the better
mse <- mean((chu_more_dropout_impute$impt[Z==1] - chu$chu_normalized_data[Z==1])^2)
simpleb_infered_cluster <- apply(chu_more_dropout_impute$z, 1, which.max)
mclust::adjustedRandIndex(simpleb_infered_cluster, chu$chu_cell_type)


Expected do
.
for file in *
echo "$file"
done
for file in *
do
echo "$file"
done
ShellCheck has found a loop that appears to be missing a do
statement. In the problematic code, it was simply forgotten.
Verify that the do
exists, and that it's in the correct place.
None


Charlotte becomes bowl eligible for 1st time
by NOAH TRISTERIn its fifth season in the FBS, Charlotte is bowl eligible for the first time.
The 49ers secured that prize with a 24-13 win over Marshall on Saturday. They were one of two Conference USA teams that earned their sixth victories of the season in noteworthy fashion this weekend. Florida International did so as well with a 30-24 win over Miami.
Arizona State became bowl eligible with a 31-28 win over Oregon, and California did so as well by beating Stanford 24-20 in the Big Game, snapping a nine-game losing streak in that series.
There are 72 teams that are bowl eligible so far, and a handful of others are still on the bubble. There are 78 bowl slots to fill. Here are the games this coming week with bowl eligibility implications:
Tuesday
Ohio (5-6) at Akron
Thursday
Mississippi State (5-6) vs. Mississippi
Friday
Kent State (5-6) at Eastern Michigan
Missouri (5-6) at Arkansas - Missouri received an NCAA postseason ban for academic violations but is appealing
Nebraska (5-6) vs. Iowa
TCU (5-6) vs. West Virginia
Troy (5-6) vs. Appalachian State
Saturday
Army (5-6) at Hawaii - Army has two games remaining and needs seven wins to become bowl eligible because it beat two FCS teams
Boston College (5-6) at Pittsburgh
Colorado (5-6) at Utah
Liberty (6-5) vs. New Mexico State - Liberty needs seven wins to become bowl eligible because it beat two FCS teams
Louisiana-Monroe (5-6) at Louisiana-Lafayette
Michigan State (5-6) vs. Maryland
North Carolina (5-6) at North Carolina State
Oregon State (5-6) at Oregon
These are the 72 teams that are bowl eligible so far:
Air Force
Alabama
Appalachian State
Arkansas State
Arizona State
Auburn
Baylor
Boise State
Buffalo
BYU
California
Central Florida
Central Michigan
Charlotte
Cincinnati
Clemson
Eastern Michigan
Florida
Florida Atlantic
Florida International
Florida State
Georgia
Georgia Southern
Georgia State
Hawaii
Illinois
Indiana
Iowa
Iowa State
Kansas State
Kentucky
Louisiana-Lafayette
Louisiana Tech
Louisville
LSU
Marshall
Memphis
Miami
Miami (Ohio)
Michigan
Minnesota
Navy
Nevada
Notre Dame
Ohio State
Oklahoma
Oklahoma State
Oregon
Penn State
Pittsburgh
San Diego State
SMU
Southern California
Southern Mississippi
Temple
Tennessee
Texas
Texas A&M;
Toledo
Tulane
UAB
Utah
Utah State
Virginia
Virginia Tech
Wake Forest
Washington
Washington State
Western Kentucky
Western Michigan
Wisconsin
Wyoming
Follow Noah Trister at https://twitter.com/noahtrister
More AP college football: https://apnews.com/Collegefootball and https://twitter.com/AP_Top25
Sign up for Daily Newsletters
Copyright © 2019 The Washington Times, LLC.
Please read our comment policy before commenting.


All
App
Card
Icon
Logo
Web
Bird Document
Logo
Visual Infography
APP
Sonor's Design
Web design
Typography Company
Business card
Weatherette
APP
BMF
Business card
Techlion
Business card
KittyPic
Logo
Graph Plotting
APP
QR Quick Response
Business card
Mobi Sock
Logo
Village Community Church
Logo
Domino's Pizza
Icon
Backend Admin
Web design
Instagram
Icon
Student Guide
Web design
Scoccer
Icon
3D Map
Icon
Note
Web design
Native Designers
Logo
Bookworm
Logo
Sandwich
Icon
Reality
Business card
Speciallisterne
Logo
适用浏览器：360、FireFox、Chrome、Safari、Opera、傲游、搜狗. 不支持IE8、世界之窗。
来源：
站长素材


<mat-toolbar>
is a container for headers, titles, or actions.
Single row: In the most situations, a toolbar will be placed at the top of your application and will only have a single row that includes the title of your application.
<mat-toolbar-row>
elements inside of a
<mat-toolbar>
.
<mat-toolbar-row>
when multiple rows are specified is not supported.


fn() globalAlignmentComputes the best global pairwise alignment.
| Defined in | <seqan/align.h> |
|---|---|
| Signature |
TScoreVal globalAlignment(align, scoringScheme, [alignConfig,] [lowerDiag, upperDiag,] [algorithmTag]);
TScoreVal globalAlignment(gapsH, gapsV, scoringScheme, [alignConfig,] [lowerDiag, upperDiag,] [algorithmTag]);
TScoreVal globalAlignment(frags, strings, scoringScheme, [alignConfig,] [lowerDiag, upperDiag,] [algorithmTag]);
TScoreVal globalAlignment(alignGraph, scoringScheme, [alignConfig,] [lowerDiag, upperDiag,] [algorithmTag]);
|
Parameters
align
|
The Align object to use for storing the pairwise alignment. |
|---|---|
gapsH
|
The Gaps object for the first row (horizontal in the DP matrix). |
gapsV
|
The Gaps object for the second row (vertical in the DP matrix). |
frags
|
String of Fragment objects to store alignment in. |
strings
|
StringSet of length two with the strings to align. |
alignGraph
|
Alignment Graph for the resulting alignment. Must be initialized with two strings. |
scoringScheme
|
The scoring scheme to use for the alignment. Note that the user is responsible for ensuring that the scoring scheme is compatible with algorithmTag. |
alignConfig
|
AlignConfig instance to use for the alignment configuration. |
lowerDiag
|
Optional lower diagonal (int). |
upperDiag
|
Optional upper diagonal (int). |
algorithmTag
|
Tag to select the alignment algorithm (see AlignmentAlgorithmTags). |
Return Values
TScoreVal |
Score value of the resulting alignment (Metafunction: Value of the type of scoringScheme). |
|---|
Detailed Description
There exist multiple overloads for this function with four configuration dimensions.
First, you can select whether begin and end gaps are free in either sequence using alignConfig.
Second, you can select the type of the target storing the alignment. This can be either an Align object, two Gaps objects, a AlignmentGraph, or a string of Fragment objects. Align objects provide an interface to tabular alignments with the restriction of all rows having the same type. Using two Gaps objects has the advantage that you an align sequences with different types, for example DnaString and Dna5String. Alignment Graphs provide a graph-based representation of segment-based colinear alignments. Using Fragment strings is useful for collecting many pairwise alignments, for example in the construction of Alignment Graphs for multiple-sequence alignments (MSA).
Third, you can optionally give a band for the alignment using lowerDiag and upperDiag. The center diagonal has index 0, the ith diagonal below has index -i, the ith above has index i.
Fourth, you can select the algorithm to use with algorithmTag. This can be one of NeedlemanWunsch and Gotoh. The Needleman-Wunsch algorithm supports scoring schemes with linear gap costs only while Gotoh's algorithm also allows affine gap costs.
The available alignment algorithms all have some restrictions. Gotoh's algorithm can handle arbitrary substitution and affine gap scores. Needleman-Wunsch is limited to linear gap scores. The implementation of Hirschberg's algorithm is further limited that it does not support alignConfig objects or banding. The implementation of the Myers-Hirschberg algorithm further limits this to only support edit distance (as scores, matches are scored with 0, mismatches are scored with -1).
The examples below show some common use cases.
Examples
Global alignment of two sequences using an Align object and the Needleman-Wunsch algorithm.
#include <iostream>
#include <seqan/basic.h>
#include <seqan/align.h>
#include <seqan/stream.h> // for printint strings
using namespace seqan;
int main()
{
Dna5String seqH = "CGATT";
Dna5String seqV = "CGAAATT";
Align<Dna5String> align;
resize(rows(align), 2);
assignSource(row(align, 0), seqH);
assignSource(row(align, 1), seqV);
Score<int, Simple> scoringScheme(2, -1, -2, -1);
AlignConfig<> alignConfig;
int result = globalAlignment(align, scoringScheme, alignConfig);
std::cout << "Score: " << result << "\n";
std::cout << "The resulting alignment is\n"
<< align << "\n";
return 0;
}
The output is as follows:
Score: 8 The resulting alignment is 0 . CG--ATT || ||| CGAAATT
Global banded alignment of two sequences using two Gaps objects and the Gotoh algorithm.
#include <iostream>
#include <seqan/basic.h>
#include <seqan/align.h>
#include <seqan/sequence.h>
#include <seqan/stream.h> // for printint strings
using namespace seqan;
int main()
{
Dna5String seqH = "CGATT";
Dna5String seqV = "CGAAATT";
Align<Dna5String> align;
resize(rows(align), 2);
assignSource(row(align, 0), seqH);
assignSource(row(align, 1), seqV);
Score<int, Simple> scoringScheme(2, -1, -2);
AlignConfig<> alignConfig;
int lDiag = -2;
int uDiag = 2;
int result = globalAlignment(align, scoringScheme, alignConfig, lDiag, uDiag);
std::cout << "Score: " << result << "\n";
std::cout << "The resulting alignment is\n"
<< align << "\n";
return 0;
}
The output is as follows:
Score: 6 The resulting alignment is 0 . CG--ATT || ||| CGAAATT
https://seqan.readthedocs.io/en/develop/Tutorial/Algorithms/Alignment/PairwiseSequenceAlignment.html
References
- Needleman SB, Wunsch CD: A general method applicable to the search for similarities in the amino acid sequence of two proteins. J Mol Biol 1970, 48(3): 443-53.
- Gotoh O: An improved algorithm for matching biological sequences. J Mol Biol 1982, 162(3):705-8


MPs least respected in Ghana – Ken Agyapong
Assin Central Member of Parliament (MP), Kennedy Ohene Agyapong has lamented that MPs are the least respected persons in the country.
According to him, Ghanaians consider ‘people who carry toilet’ as people who ought to be respected because they fear the consequences that may result if they fail to obey them.
Interestingly, the same Ghanaians do not have same level of respect for MPs and Assembly men because ‘they see us people who came to them begging for their mandate to lead them’.
 Ghanaians tend to respect people who carry toilets than MPs and Assembly men all because they know they will face dire consequences when they mocked such people…,” he said.
The maverick politician said it is for this reason that common fund allocated to MPs are never enough to carry out any meaningful development.


---
layout: page
weight: 0
title: IP Management
navigation:
show: true
---
List
Obtain a complete list of all IP's and which are free, taken or available.
| Parameter |
Required |
Requirements |
| list |
Yes |
Must be set to either ( all / free / taken / available ) |
Here is a brief explanation of each option available for the list parameter:
- all
- All IP addresses available to account, regardless of whether or not the IP is taken by a subuser
- free
- All free IP addresses for the account. If a subuser is using an IP, it will not show up on this list
- taken
- All taken IP addresses for the account. Only IP addresses that taken by subusers will show up on this list
- available
- All available IP addresses for the account including all free IP addresses. If a subuser is deactivatedand is assigned an IP, that IP will show up on this list since that IP address is not being used by anyone
{% apiexample list POST https://api.sendgrid.com/apiv2/customer.ip api_user=your_sendgrid_username&api_key=your_sendgrid_password&list=all %}
{% response json %}
[
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
}
]
{% endresponse %}
{% response xml %}
<IP_ADDRESS>
<IP_ADDRESS>
<IP_ADDRESS>
{% endresponse %}
{% endapiexample %}
{% anchor h2 %}
Subuser IP Usage
{% endanchor %}
If your account has more than one IP address, you can manage what IPs your subusers are allowed to send from. If you remove all IPs from a specified user, they will use all IPs from from your list.
| Parameter |
Required |
Requirements |
| task |
Yes |
Must be set to list
|
| user |
Yes |
Subuser must be registered under your account |
{% apiexample usage POST https://api.sendgrid.com/apiv2/customer.sendip<EMAIL_ADDRESS>%}
{% response json %}
{
"success": "success",
"outboundcluster": "o1.sendgrid.net",
"ips": [
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
},
{
"ip": "<IP_ADDRESS>"
}
]
}
//error
{
"error": {
"code": 400,
"message": "User does not exist"
}
}
{% endresponse %}
{% response xml %}
o1.sendgrid.net
<IP_ADDRESS>
<IP_ADDRESS>
<IP_ADDRESS>
<IP_ADDRESS>
<IP_ADDRESS>
User does not exist
{% endresponse %}
{% endapiexample %}
{% anchor h2 %}
Subuser IP Assignment
{% endanchor %}
You need to assign at least ONE IP to your subuser.
| Parameter |
Required |
Requirements |
| task |
Yes |
Must be set to append
|
| user |
Yes |
Subuser must be registered under your account |
| set |
Yes |
Must be either:
none: Remove all ips.
all: Apply all possible ips to subuser.
specify: Specify the ips to the subser. Must be a valid set of IPs (use the list call to determine valid IPs) |
| ip[] |
No |
If the set parameter is set, then you must specify the IPs. Use the ip[] parameter to specify an IP. [ IE - ip[]=<IP_ADDRESS>&ip[]=<IP_ADDRESS> ] |
{% apiexample subuser POST https://api.sendgrid.com/apiv2/customer.sendip<EMAIL_ADDRESS>%}
{% response json %}
{
"message": "success"
}
//error
{
"message": "error",
"errors": [
"...error messages..."
]
}
{% endresponse %}
{% response xml %}
success
error
...
... error messages ...
...
{% endresponse %}
{% endapiexample %}


{% load wagtailcore_tags %} {# The image background_image url is currently broken https://github.com/wagtail/wagtail/issues/2087 #}


WE MAKE IT CLEAR
WE MAKE IT CLEAR
SING IN
Email address
Password
Remember me
Forgot password?
Sign in
Not a member?
Register
or sign up with:


This text is in a fixed-pitch font, and it preserves both spaces and line breaksTeletype text
Computer code text
WWW etc.
Author: of this document:
Here comes a long quotation:
here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation here is a long quotation
Here comes a short quotation:
here is a short quotation here is ashort quotation
a dozen is 20 12 pieces!
a dozen is 20 12 pieces


public class ChokePointPolygonGenerator
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
private static double |
DEFAULT_CHOKEPOINT_VECTOR_LENGTH |
private static int |
DEFAULT_CHOKEPOINT_VECTOR_ROTATION |
| Constructor and Description |
|---|
ChokePointPolygonGenerator() |
| Modifier and Type | Method and Description |
|---|---|
static Polygon |
generatePolygonAtChokePoint(bwta.Chokepoint chokePoint)
Convenience function.
|
static Polygon |
generatePolygonAtChokePoint(bwta.Chokepoint chokePoint,
double vectorLength,
int vectorRotation)
Function for generating a Polygon around a ChokePoint.
|
private static final double DEFAULT_CHOKEPOINT_VECTOR_LENGTH
private static final int DEFAULT_CHOKEPOINT_VECTOR_ROTATION
public static Polygon generatePolygonAtChokePoint(bwta.Chokepoint chokePoint)
chokePoint
- the Chokepoint
that the Polygon
is being
created around.Polygon
that is being created around a
Chokepoint
.generatePolygonAtChokePoint(Chokepoint, double, int)
public static Polygon generatePolygonAtChokePoint(bwta.Chokepoint chokePoint, double vectorLength, int vectorRotation)
chokePoint
- the Chokepoint
that the Polygon
is being
created around.vectorLength
- the length of the Vectors that are being used to generate the
Polygon. A side perpendicular to the ChokePoint itself has the
length 2*vectorLength (When using 90° as rotation).the
- rotation in degrees that the Vectors generating the
Polygon will be rotated.Polygon
that is being created around a
Chokepoint
.


{% url 'profile:home' as profile_home %} {% url 'profile:user-update' as profile_update %} {% url 'password_change' as profile_password%}


Database package¶
Submodules¶
Database.MNISTDatabase module¶
- Database.MNISTDatabase.loadFromLocalFile(image_path, label_path)[source]¶
Load the MNIST train and test datasets from local files.
Code from : https://www.kaggle.com/hojjatk/read-mnist-dataset
- image_pathstring
path of the image dataset
- label_pathstring
path of the label dataset
- x_trainuint8 NumPy array
containing training data with shape (60000, 28, 28)
- y_trainuint8 NumPy array
containing training digit labels with shape (60000,)
- x_testuint8 NumPy array
containing test data with shape (10000, 28, 28)
- y_testuint8 NumPy array
containing test digit labels with shape (10000,)
- Database.MNISTDatabase.loadMNISTDatabase(forceLoadLocalFiles=False)[source]¶
Load the MNIST train and test datasets.
- forceLoadLocalFiles: boolean
Default is False If True, the data are getting loaded from local files Used for test coverage
- x_trainuint8 NumPy array
containing training data with shape (60000, 28, 28)
- y_trainuint8 NumPy array
containing training digit labels with shape (60000,)
- x_testuint8 NumPy array
containing test data with shape (10000, 28, 28)
- y_testuint8 NumPy array
containing test digit labels with shape (10000,)


This action will modify your Stellar account in the following ways:
Your Stellar Address will be: {{userData.username}}*{{siteURL}}


Gingerbell
Orange Cutie
Gingerbell is one of a kind! she loves to play and make funny noises. Here comes gingerbell she's a movie star.
Boss
Spots on Patrol
Boss is the boss. Don't let boss inside the dorm, he'll take control!
Solo
So Exotic
Things that solo likes to chase:
- mice
- birds
- students that are late to commlab


Facebook, Google, Microsoft and Twitter recently announced the Data Transfer Project (DTP) as a way to improve data portability between different services. Naturally, I was intrigued to understand what precisely the DTP is. So I spend a recent ride on the train riding the whitepaper and will give you a little summary here:
DTP provides a Java-based, Docker-deployable open source application that executes bulk tasks with the following workflow:
A running instance of DTP is called a host. There are different possible models for hosts. One option (distributed) is that a provider itself runs a DTP that allows import from and export to a list of other providers of their choosing. The second option (centralized) is a third party that hosts the infrastructure to exchange data between different providers. The DTP whitepaper suggests that Data Portability NGOs could run such an instance. Finally, the third option (self-managed) means end users are running their own DTP instance.
The DTP only provides software and doesn’t specify any requirements for providers as to with who they have to interact. Every host decides which adapters it makes available and needs to apply for API access with each provider. Also, the whole design of the DTP is for one-time data transfer and does not support continuous synchronization.
My opinion: The DTP is convincing and can certainly help with data portability. Of course, it depends on providers opening up their APIs, although consumer demand and data portability requirements (as in the GDPR) could drive them. Its scope is limited, but I think its data models could be applied even outside this scope for federation and interoperability (or they could become “just another standard …”).


Chapter 2 Basics of R
2.1 Brief history
R is a programming language developed by Ross Ihaka and Robert Genleman in 1993 (Ihaka and Gentleman 1996). A good resource about R is the book programming for data science (Peng 2015). R can be explained as a free version of S-PLUS programming language (http://www.solutionmetrics.com.au/products/splus/default.html). It is free and recognized a GNU spftware (https://www.gnu.org/software/software.html) with GNU General Public License (GPLV2-GPLV3) license. This feature allowed that many developers started improving and adding code over the years.
R includes several statistical functions, therefore, user who just want to use the base capabilities of R are not forced to learn R-programming. However, the evolution from user to developer in R has been facilitated with numerous publications such as the book “R packages: organize, test, document, and share your code” (Wickham 2015), or “The art of R programming: A tour of statistical software design” (Matloff 2011).
2.1.1 Installation
R can be installed in different OS including Linux, Windows, Mac and Solaris. The webpage https://cran.r-project.org/ shows how to install R in any platform. A popular Integrated development environment (IDE) is RStudio https://www.rstudio.com/, which contains many useful integrated options. However, R can be run on the terminal and use any text editor to write scripts.
2.2 Using R
If we type at the R promt
x <- 1 # Not printing results
x # Print results
## [1] 1
print(x) # Explicit print x
## [1] 1
Rhe integer 1 was assigned (<-) to x, then writing x or print(x) will show the value of x. Instead of numbers, can be assigned other expressions such as strings, dates or other objects. R includes several statistical functions. For instance, if we type ‘pi’ at the terminal, it will print the pi number.
pi
## [1] 3.141593
2.2.1 R objects
There are five basic classes (or atomic classes).
- character.
- numeric.
- integer.
- complex.
- logical (TRUE/FALSE or just T or F).
Objects of the same class can be grouped in vectors. Vectors are created with writting c() with the elements of the vector inside the parenthesis, separated by colon. In fact, c is a builtin function to create vectors. In this case, the vector v1 contain a sequence of three integers, from 1 to 3. The resulting class is numeric.
v1 <- 1:3
v2 <- c(1, 2, 3)
identical(v1, v2)
## [1] FALSE
v1
## [1] 1 2 3
class(v1)
## [1] "integer"
With the operator [
we can get specific elements of your vectors. In the following code it is also used the function length
, which simply returns the length of an object.
v1[1] # first element of v1
## [1] 1
v1[length(v1)] # last element element of v1
## [1] 3
If we create a vector with numbers and letter, the resulting vector will be “character” converting the numbers in characters.
v2 <- c(1:3,"a")
v2
## [1] "1" "2" "3" "a"
class(v2)
## [1] "character"
Objects can be converted to other classes with the “as.*" functions. For instance, If we convert the vector v2 to numeric, it will recognize the numbers adding an NA into the position of the character.
as.numeric(v2)
## Warning: NAs introduzidos por coerção
## [1] 1 2 3 NA
2.2.2 Factors
Factors represents categorical data. A typical example is a character vector of days of the week. The function factor
creates factors, to see help type ?factor
. The following example will use this function with the arguments x
and levels
.
dow <- factor(x = c("Wednesday", "Monday", "Thursday", "Friday"),
levels = c("Monday", "Tuesday", "Wednesday", "Thursday",
"Friday"))
dow
## [1] Wednesday Monday Thursday Friday
## Levels: Monday Tuesday Wednesday Thursday Friday
2.2.3 Missing Values
Missing values in data-sets are a typical source of headache in r users. Fortunatly, R counts with several tools to avoid these headaches. These tools are fhe functions is.na
to check for NA (not available) and is.nan
(not a number). This functions returns logical values.
n <- c(1, NA)
is.na(n)
## [1] FALSE TRUE
n <- c(1, NaN)
is.na(n)
## [1] FALSE TRUE
is.nan(n)
## [1] FALSE TRUE
2.2.4 Matrices
Matrices are structure with rows and columns. They can be created using the matrix
function and also, using vectors. Remember, if you want to know more about any function you just have to type ? and function, for instance:?matrix
will open the help documentation for the function matrix
. Let’s create a matrix using vectors:
a <- 1:12 #numeric vector
(m <- matrix(data = a, nrow = 3, ncol = 4))
## [,1] [,2] [,3] [,4]
## [1,] 1 4 7 10
## [2,] 2 5 8 11
## [3,] 3 6 9 12
We can check the dimensions of our matrix m
with dim
, which are 3 and 4.
dim(m)
## [1] 3 4
In order to get the elements of matrix m
we can use [
operator:
m[1, 1] # first element
## [1] 1
m[, 1] # firs column
## [1] 1 2 3
m[1, ] # firs row
## [1] 1 4 7 10
m[3,4] # last element
## [1] 12
2.2.5 Arrays
Arrays are like matrices inside other matrices. In fact, a matrix is a 2-dimensional array. Let’s create an array create an array using the same vector a and same dimensiones of m, 3 and 4. array
has three arguments, data
, dim
and dimnames
. In th argument dim
let’s add the number 2, resulting in an array of two matrices identical to m
.
(a <- array(data = a, dim = c(3,4,2)))
## , , 1
##
## [,1] [,2] [,3] [,4]
## [1,] 1 4 7 10
## [2,] 2 5 8 11
## [3,] 3 6 9 12
##
## , , 2
##
## [,1] [,2] [,3] [,4]
## [1,] 1 4 7 10
## [2,] 2 5 8 11
## [3,] 3 6 9 12
We can subset elements from array also with the [
operator.
a[1, 1, 1] # first element
## [1] 1
dim(a) # dimensions
## [1] 3 4 2
a[3, 4, 2] # last element
## [1] 12
2.2.6 Lists
List are objects that can contain elements of different classes. I like to call lists as bags. In a bag you can put almost anything. Also, inside the bag, you can put other bags with different things. This means that you can have a list of lists of any R object. Lists can be created with the list
function. Let’s create an empty list. Then we will use the vecctor a
to create another list.
a <- 1:3 # vector of three elements
l1 <- list() # empty list
l1 <- list(a) # vector of three elements
length(l1) # length 1
## [1] 1
l1 <- as.list(a) # vector a as list
length(l1) # three elements
## [1] 3
As mentioned, the list can have lists inside.
l1 <- list(list(a), # three numeric elements
list(TRUE, TRUE, FALSE)) # three logical elements
length(l1) # length 2
## [1] 2
2.2.7 Data-Frames
“Data-frames are used to store tabular data in R” (Peng 2015). You can think in data-frames as spreadsheet-like objects. They are similar with matrix and you can have a matrix and a data-frame with the same dimensions. Basically, you have rows and columns, columns can have different classes, and the columns usually have a one-word name.
As this type of object is very used by scientists, there are R packages created to work with this type of ojects. Below some of them:
data.frame
: This is not a package, for a class and function from thebase
. With this functionyou can create data-frames.data-table
(Dowle and Srinivasan 2017):data.tables
objects has the classdata.table
which inherits from the classdata-frame
, which means that they share common characteristics. However, the big difference withdata-table
is the efficiency with memory. It includes function such asfread
for reading millions of observations in seconds.tidyr
(Wickham and Henry 2018): Sometimes your data is in long format and you need it in wide format, and viceversa. This package does the job.readxl
(Wickham and Bryan 2017): Good package for importing Excel and LibreOffice files. I recommend this packages for newbies.sf
(Pebesma 2017): This package presents the classsf
and introduce the list-column of spatial geometry.
Let’s create a data-frame.
a <- 1:3
b <- 3:5
(ab <- data.frame(a, b))
## a b
## 1 1 3
## 2 2 4
## 3 3 5
class(ab)
## [1] "data.frame"
2.2.8 Names
In R you can put names in almost everything. Below examples for vectors
, matrix
and data.frames
.
names(ab) # original names
## [1] "a" "b"
names(ab) <- c("c", "d")
names(ab) # new names
## [1] "c" "d"
2.3 Inputting data into R
Your data can be in different formats. In this sections i will show you how you can input text and comma separated values files, which is a very common task. Let’s say that you uses an spreadsheet program such as Microsoft Excel or LibreOffice. Then you might want to export your data into R.
- Your first check if the first row of your data has name or not. If they do have names, this means that they have a header.
- Then click on ‘Save as’ and search text file with extension .txt or CSV.
- Then you your file with a note bloc, gedit or other tool to check if the decimal character is point ‘.’ and the separator character is comma ‘,’ or semicolon ‘;’ or other character. This depends on the regional confugarion of your spreadsheet software.
- If your file has extension ‘.txt’, use
read.table
and if is ‘.csv’, useread.csv
.
Once you check, you can import your ‘.txt’ or ‘.csv’ files in R:
a <- read.csv("path/to/file.csv", sep = ",", header = T)
a <- read.tablesv("path/to/file.txt", sep = ",", header = T)
Appendix B
Ihaka, Ross, and Robert Gentleman. 1996. “R: A Language for Data Analysis and Graphics.” Journal of Computational and Graphical Statistics 5 (3). Taylor & Francis: 299–314.
Peng, Roger D. 2015. R Programming for Data Science. Leanpub.com.
Wickham, Hadley. 2015. R Packages: Organize, Test, Document, and Share Your Code. “ O’Reilly Media, Inc.”
Matloff, Norman. 2011. The Art of R Programming: A Tour of Statistical Software Design. No Starch Press.
Dowle, Matt, and Arun Srinivasan. 2017. Data.table: Extension of ‘Data.frame‘. https://CRAN.R-project.org/package=data.table.
Wickham, Hadley, and Lionel Henry. 2018. Tidyr: Easily Tidy Data with ’Spread()’ and ’Gather()’ Functions. https://CRAN.R-project.org/package=tidyr.
Wickham, Hadley, and Jennifer Bryan. 2017. Readxl: Read Excel Files. https://CRAN.R-project.org/package=readxl.
Pebesma, Edzer. 2017. Sf: Simple Features for R. https://CRAN.R-project.org/package=sf.


Instructor: Baishakhi Ray (Rice 340)
Meetings : Tuesday and Thursday 3:30 PM - 4:45 PM at Rice Hall 340
Office Hours: Tuesday 5 pm - 6 pm or by appointment
Teaching Assistant: Chong Tang (ctang at virginia dot edu)
This course will teach how to write better software using diverse data analysis techniques borrowed from Machine Learning, Natural Language Processing, Network Analysis, and Statistical Modeling. We will analyze large-scale open-source software data from GitHub and StackOverflow, and build different tools such as code recommendation systems, automatic bug finders, etc. In addition, we will read research papers to learn the current start-of-the-art.
| Reading & Presentation | Lectures | Assignments | Presenter |
|---|---|---|---|
| Introduction | Week 1 (1/19/2017) | Overview | Baishakhi Ray |
| Program Variants | Week 2 (1/24/2017) | Program Tuning | Chong Tang |
| Week 2 (1/26/2017) | Cost of maintaining program variant | Baishakhi Ray |


Mossle
${catalog.name}
<#list catalog.cmsArticles as article>
${article.title}
详情
${article.content}
#list>
© Mossle


IMPORT DATABASE Statement
Imports a table, view, or query from a Microsoft SQL Server, PostgreSQL, or MySQL database. The data can be copied
into the notebook for fast offline access, or a live link to the remote database can be created.
Syntax
Parameters
- vendor: text
One of the following strings: 'mssql' (Microsoft SQL Server), 'pgsql' (PostgreSQL),
'mysql' (MySQL).
- connection-string: text
The ADO.NET connection
string specifying the hostname, credentials, database name, and other connection details. Use the graphical
import wizard via the Import menu to produce a connection string, and then copy it into your code.
- src-schema-name: text or identifier (optional)
Applies to Microsoft SQL Server only. If provided, then this is the name of the schema in which to find the
src-table-name. By default, this is dbo. When using MySQL, don't use this parameter; instead,
provide the schema name as the database parameter of the connection string.
- src-table-name: text or identifier (optional)
If provided, then this is the name of a remote table to be imported.
- sql: text (optional)
If provided, then this is an SQL query that returns the rows to be imported. This query is in the remote server's
SQL syntax. For instance, this query must be written in Transact-SQL when importing from Microsoft SQL
Server.
- dst-table-name: text or identifier (optional)
If provided, then the table is imported as the specified name, rather than its original name from the remote
database.
Options
-
LINK: integer (0-1, default: 0)
This option specifies whether the remote data should be copied into the notebook.
- 0 = Copy the data into the notebook. This is a one-time snapshot of the data and offers the fastest
querying performance.
- 1 = Create a live link to the remote database. This is slower, but avoids copying the data into the
notebook and provides access to live data.
-
TRUNCATE_EXISTING_TABLE: integer (0-1, default: 0)
If the target table name exists, this option indicates whether the existing data rows should be deleted.
- 0 = Keep existing rows and append new rows
- 1 = Delete existing rows
-
TEMPORARY_TABLE: integer (0-1, default: 0)
If the target table name does not exist, and therefore a new table will be created, this option indicates whether
the new table will be a temporary table.
- 0 = Use
CREATE TABLE
- 1 = Use
CREATE TEMPORARY TABLE
Examples
-- It's convenient to use a variable to hold the connection string.
-- The || operator is string concatenation in SQLite.
DECLARE @connectionString =
'Data Source=localhost\SQLEXPRESS;' ||
'Initial Catalog=Northwind;' ||
'Integrated Security=True';
-- Import the remote table 'foo_bar' into a new table of the same
-- name in the notebook. A one-time copy of the data is performed.
IMPORT DATABASE 'mssql'
CONNECTION @connectionString
TABLE foo_bar;
-- Import a very large remote table by creating a live link. The
-- data is not copied into the notebook. Instead the remote table is
-- queried on demand.
IMPORT DATABASE 'mssql'
CONNECTION @connectionString
TABLE large_table
OPTIONS (LINK: 1);