HOME
HTML markup consists of several key components, including those called tags (and their attributes), character-based data types, character references and entity references. HTML tags most commonly come in pairs like

and

, although some represent empty elements and so are unpaired, for example
. The first tag in such a pair is the start tag, and the second is the end tag (they are also called opening tags and closing tags).
Following table uses colspan and rowspan attributes inside
to merge two or more cells
| First Year | Second Year | Third Year | Fourth Year | |
|---|---|---|---|---|
| 8.00 a.m-10.00 a.m | Data Structures & Algorithms | Software Engineering | Mobile Application Development | Parellel Computing |
| 10.00 a.m-12.00 a.m | Database | Functional Programming | Machine Learning | Computational Biology |
| 12.00 a.m-1.00 p.m | ||||
| 1.00 p.m-3.00 p.m | Mathematics | Group Project
|
Game Development | Cognitive Robotics |
| 3.00 a.m-5.00 p.m | Programming using C | Software Engineering | Phylosophy of Science |


Sketch-html
K
How much time do you plan
to spend taking Acne
courses and lessons?
About an hour a day
More than one hour per day
1 to 3 hours per day
I don't plan to train regularly
Next Question
Done


All,
I'm trying to follow the instructions of how to run emoncms from a RPi and hard drive. http://emoncms.org/site/docs/raspberrypihddbuild
I'm stuck on this section;
"Change /etc/fstab on HDD
Mount the Harddrive on your computer and open the main partition. Open to edit the file:
/etc/fstab
Change the root device from: /dev/mmcblk0p2 / to be /dev/sda2"
I've written the Raspbian image to the HDD (using Win32 disk imager), but all I can see on there now is 56Mb boot folder. There is no main partition. Should I have made a partition on the HDD? Where should the fstab file be located?
I've searched on google but can't find anyone else doing this...can someone assist?
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
The main partition is ext4 format which cannot be seen by a windows machine. What you see is quite normal.
You need to hook your hdd up to the pi, boot up on an sd card and mount the hdd filesystem to be able to edit /etc/fstab.
The preferred alternative method now is to use debian packages, have a look at this (rather longish) thread it explains how to start from scratch with the latest raspbian image and install emonCMS using the easier method
http://openenergymonitor.org/emon/node/4908
the bit you should read starts about post 20-22 on Fri, 04/04/2014 - 22:38.
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I have just transplanted the relevant part to its own thread for easy access. hope it helps :-)
Creating a local EmonCMS installation on a Raspberry Pi
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Thanks Paul!
All working now, except that having completed the heating scheduler instructions, I can't see packet gen in the Extras drop down menu- any thoughts?
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Hi Chris, there are a couple of possibilities I can think of, the easy one is have you run Admin -> Update & check in emonCMS ?
Try that first and if thats not it can you confirm the method you used that is whether followed the instructions you linked to entirely or did you "mix & match" or change anything.
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I've now caused myself another problem- I tried to change the RPi to have a static IP so I could do port forwarding. Somehow I must have entered the addresses incorrectly (using these instructions), as now I can't find the RPi on the network! Any way around this? Will I have to a) get a hdmi cable and monitor + keyboard or b) start again with fresh Raspbian image?
When I get back to the program, in response to your questions;
"have you run Admin -> Update & check in emonCMS ?" No. Do this on the RPi via SSH?
I followed http://openenergymonitor.org/emon/node/5092, then went to the heating scheduler instructions and added the modules, then edited the scheduler.
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
networking/port forwarding are not familiar territory but if you followed http://openenergymonitor.org/emon/node/5092 you do have the advantage of the redundant sd card image.
If you remove your sd card stick it in your card reader on your pc, open the file cmdline.txt replace " /dev/sda2 " with " /dev/mmcblk0p2 " save and return card to pi. when you reboot pi you will be running the original raspbian image. you can mount the hdd with
sudo mount /dev/sda2 /media/hdd
assuming you used these settings the first time round and haven't deleted/changed anything. from here you can ssh in as originally done and access the files you were editing to check & edit using commands like
note that you are not running on the hdd image so any commands you run will effect the sd card image not the hdd so restrict yourself to "having a look" "editing obvious mistakes" or "reverting the changes to allow you to regain direct access". When you feel you've fixed it run
sudo shutdown -r now
to edit the /boot/cmdline.txt back to booting from hdd and restart the pi.
Good luck :-)
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Paul,
Wouldn't he need to do sudo mkdir /media/hdd before running the mount command?
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Hi Bill
The /media/hdd directory was created during the initial "installing raspbian to hdd" so it should still be there (hence the "assuming you used these settings the first time round and haven't deleted/changed anything" disclaimer) hopefully :)
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I wondered if something like that might have been the case. Hence the question, vice a statement...
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Got my head around crontab now (I had the scheduler line commented out in crontab, and also hadn't put spaces between each " * ".
However I still can't see packetgen or scheduler in emoncms.
Do I need to reset something?
I discovered what I did wrong with changing the RPi's IP address- typo in the interfaces file! Again, obvious once you realise it.
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Did you try this yet? You should log into emonCMS the usual way, via a browser, on the right of the nav bar at the top of the screen, you should have "Admin" then on that screen, click the "update & check" button.
If you haven.t already, try that first. There could also be an issue with the modules locations as the git and apt methods install to different locations and I've not tried mixing the two.
So can you confirm if you've done the "update & check" and hopefully that's it! but if not, someone better versed in the server antics may be able to confirm if the 2 module locations will work in harmony or if they should be combined,
Paul
ps for the record (future searches) did you use the redundant sd card partition or another method to access and fix the typo ?
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Paul,
I tried "Admin -> Update & check in emonCMS" in emoncms and it said that everything was up to date. I suspect the issue might be to do with module locations as when I tried to use
$ git pull /var/www/emoncms
it said that the folder wasn't a git repository.
To sort the RPi type in the etc/network/interfaces file, in the end I resorted to digging out an old playstation2 scart-phono converter, and connect up my TV! Worked a treat, except that I had to then learn how to fix the display which was cut-off down one side (and hence why it took me a while to see the typo!), and I only had one keyboard which I had to keep switching from RPi to PC!
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I should add that when I list the files in /var/www/emoncms/Modules it does show all of them their- raspberrypi, scheduler, packgetgen, events etc.
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
Ok, I'm not so good at understanding the git v apt default path situation, but based on what (little) I do know and my curious nature, in the absence of any solid advice I would revisit the scheduler instructions and replace every instance of " /var/www/emoncms/Modules " with " /usr/share/emoncms/www/Modules " to see where that got me.
In fact I just did (I did say I was curious) I ran
cd /usr/share/emoncms/www/Modules
sudo git clone https://github.com/emoncms/packetgen.git
sudo git clone https://github.com/emoncms/scheduler.git
as I already have the raspberrypi module. and they are accessible via the emoncms webpage (on a apt-get installed system). I ran "update and check" and browsed around the additional pages, but haven't configured or tested anything. I'd sat it's worth a try :-)
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
A quick update I ran through the steps on the scheduler page and the scheduler seems to function ok, I can see my temp sensor/zone and can change the set times and temps. I cannot see any resulting activity in the packetge. all the packetgen fields seem to work but I cannot see my "zone" this maybe due to the fact I did not rename my zones prior to initial use or maybe something else is amiss or maybe I'm just not doing something right, I've run out of time right now (need to be somewhere) so may pick this up later if I get time and try to fathom it out
Paul
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I just did the same and can now see scheduler and packetgen. However like you I can't see any of the zones in packetgen. Did you get any further?
The scheduler temperature numbers are cut off in my browser- the entry box isn't quite large enough. So I changed the values of the box sizes in the php file.
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
I notice the scheduler instructions also include;
git clone https://github.com/emoncms/raspberrypi.git
I appear to already have this in /usr/share/emoncms/www/Modules, but does it need to be updated? Or should already be the latest?
Chris
Re: Emoncms + RaspberryPI + Hard drive: How to prepare HDD
That copy would of been installed by the emoncms-module-rfm12pi package.
I have already tried apt-get remove emoncms-module-rfm12pi and then installed using the git clone method and have also installed the modified version from the packetgen's copyto_raspberrpi_module folder as per the original packetgen installation method as although thats not mentioned in the heating scheduler module thread, I assume it's required as the packetgen code is missing from the raspberrypi_run.php copy that is installed with the raspberrypi module.
I'm guessing somewhere there is a misdirected path due to the modules being in a different location, but that is just a guess.
So far I haven't spent too much time on this, as to be honest I'm not that sure of what I'm doing and it's not something I currently need
Paul


{% extends "base_error.html" %} {% block content %}
If you think this URL should exist, send a pull request or file an issue on github.com/namin/io.livecode.ch.


{{ booking.name|title }} booked from {{ booking.start_time|date:'g:i a' }} until {{ booking.end_time|date:'g:i a' }} for {{ booking.number_of_people }} {{ booking.number_of_people|pluralize:"person,people" }}:
{% for boat in booking.boats.all %} {% endfor %}


HTML Tidy is a program, which helps to find errors in HTML documents and to perform some actions on HTML pages, such as "convert tags to lowercase", "convert document to XHTML form", "make document clean", "reformat for better readability" etc.
Plugin adds menuitems to "Plugins" menu of Synwrite:
- "Menu": shows list of configured Tidy actions. Each action formats source file, if it's ok;
if not it shows error report in Validation tab of Output panel.
- "Validate document": shows list of errors in code in Validation tab of Output panel.
You can double-click lines in this list to go to source code.
- "Browse configs": shows folder with config files, one txt file per Tidy action, you can edit configs or add new ones.
Help files:
Author of plugin: Alexey (Synwrite)
License: MIT


Kannur, also known as Cannanore, is a beautiful city on the northern side of Kerala State in India.  Kannur is the administrative headquarters of the district of Kannur. It is known as Land of Looms and Lores.
The impeccably unspoilt Payyabalam beach is adorned with sparkling pearls of golden sand and foamy white waves of the Arabian Sea. The highlight of Kannur and one of the many beautiful beaches of Kerala, it has an incredibly peaceful and inviting aura.
Tucked away in the lush greenery of the Western Ghats and soaring at a dizzying altitude of 3500 feet above sea level, Palakayyam Thattu is one of the most beautiful hill stations in the entire state of Kerala. Adorned with luxuriously dense greenery, sky-touching trees and majestic hillocks, the view that Palakayyam Thattu enjoys is one that you will rarely find
St Angelo's Fort is definitely one of the most popular and frequently visited attractions of Kannur and for more reasons than one. The polished yet prehistoric structure of this fortress oozes with unadulterated elegance and overwhelming power. Standing ashore in the Arabian sea, it enjoys a panoramic and unobstructed view of the diorama created by the merger of the magnetic waves and the azure waters. It also overlooks the mesmerising Mopilla Bay, a natural harbour.
The Muzzhapilangad Drive-in Beach at Kannur is one referred to with many superlatives- as the longest drive-in beach in the whole of India, as one of the cleanest beaches of Kannur and most importantly, as one of the best drive-in beaches that the entire Asian continent has to offer.


A devastated Muzanhi confirmed the affair to B-Metro
Added Muzanhi:
Muzinda could not be reached for comment but she confirmed her illicit affair with Chari.
She even threatened to reveal “intimate” details of their illicit relationship if Chari refused to apologise to her husband.
She further warned that if Chari remained adamant, she was prepared to “dump” her husband and elope to him.
When reached for comment Chari strongly denied that there was anything untoward that had been going on between him and Muzinda.
CHECK OUT OUR CELEB NEWS
PICS: The Beauty behind Tendai ‘The Beast’ Mtawarira
Savage gone wrong…. Jackie Ngarande Flees Facebook after trying to embarrass singer Pah Chihera
PICS: Baba naMai Charamba take romantic vacation in Sun City
Passion Java RUBBISHES Influential List, MOCKS Mtawarira, Mambo Dhuterere and Ginimbi
To View and Apply for the latest Jobs and Vacancies in Zimbabwe, Please Visit our Sister website iHarare Jobs


I have an older Current Cost Envi that spits out data over a serial link that I was thinking of trying to use to write data to the Nest platform, but it seems the Open Energy Monitor is a much better device and of course is a completely open source project so that's always a good thing and I'm wondering how feasible it would be to get it working with the Nest platform/environment? Even the clock on the Envi is poor, it drifts several minutes per month!
It seems the Open Energy Monitor group might be best served by doing this once perhaps with a single developer account vs multiple DIY developers reinventing this particular wheel.
I have just enough computer science to possibly fight through this slowly while making lots of naive mistakes, but the documentation at Nest seems like it would be fairly straightforward for a 'real' developer to work through, although I could be wrong.
Thoughts?
(p.s. Sorry if this is already discussed somewhere, but a forum search didn't reveal anything that seemed related.)
Re: 'works with nest' functionality feasible?
Anybody? If not I guess I'll try and work through it using the current cost monitor for a data source, for now. Can always build up an open energy system eventually if I can get the Nest api details ironed out.
Re: 'works with nest' functionality feasible?
I would be happy to assist with interfacing with emonhub, I do not have a "nest" available for development purposes nor a deep understanding of its functionality but looking at the API docs this morning I would say you are right it should be quite straight forward (alas it would not be the first time I've thought that and been wrong)
There is a similar thread for "Feeding Hive data to emoncms" which I've offered to help with too, and the same concept would work, just the API structure would be different I guess
Have you stumbled across any working examples at all?
Paul
Re: 'works with nest' functionality feasible?
Excellent, thanks for the offer to help with this. Im going to start workimg with it and may reach out if I get stuck and will attempt to post updates on here as things move along.
I'm building a small personal website now since Google seems to require that you have a website to register as a developer but I may start there and ask the Dev support team at google if they have a recommended best approach for implementing this.
I have not seem a clear working example anywhere. Some people were using an unofficial api and sending data to xively but most of that was before the google acquisition and release of the real api and developer program. Initial emails with google were positive and they said once registered as a developer for the nest it would be possible to get support from their internal team etc so I figure it makes sense to start there.
Re: 'works with nest' functionality feasible?
I did take a quick look at registering as a developer, but one of the items in a list of tick boxes to agrre before becoming a registered developer was something like "promise not to develop anything that will effect the call for heat" or something similar which I though was a bit limiting and decided I anted to read more before ageeing, which I haven't managed to do yet. Sounds very Apple'esque rather than a Google'ish type of limitation so maybe it will get lifted, who knows. I will take another look though.
I have started a emonhub modules "sandbox" thread about an easy fit experimental environment you may fancy looking in on.
Paul
Re: 'works with nest' functionality feasible?
Ok thanks. Essentially it seems they don't want developers doing things that would change how the nest functions with respect to its core features. So if you wanted to write a client that would call for heat when your client program is triggered by some event, that's probably not going to happen through the official api. It seems they're fine with writing data objects to the platform if you play it by the book, which is what I'd like to do. There are apparently already special built in tools and displays in nest for adding energy usage data, eg electricity and gas, and its in google's best interest to have this data anyways so they can better see directly the effects of tweaking nest thermostat behavior etc etc
Re: 'works with nest' functionality feasible?
I just saw there is development ongoing for an emoncms android app and a nicely written tutorial to boot. Perhaps the snippets of code required for pulling thermostat data and pushing energy data from and to the nest environment could be incorporated there.
So many ways one could skin this particular cat and minimizing duplication of effort is always smart. They (people with real computer science backgrounds) tell me that great coders reuse.
Emoncms already exists and seems like a good place for the energy monitor data to go first if it can be queried by an android app.
Ok, eyes are shot from reading the Nest and android developer documentation, time to sleep and hope some of it soaks in.


Angular Formatter Parser
Name
(target view and model - capitalize input)
Coupon Code
(target view and model different - upper and lower case)
9 Digit Code
(custom transform function - add spaces for readability)
{{basicFormGroup.get('couponcode').value}}
{{basicFormGroup.value | json}}


Available rooms:
Users online:
Just use overflow: auto. Since your content by default just breaks to the next line when it cannot fit on the current line, a horizontal scrollbar won't be created (unless it's on an element that has word-wrapping disabled). For the vertical bar,it will allow the content to expand up to the height you have specified. If it exceeds that height, it will show a vertical scrollbar to view the rest of the content, but will not show a scrollbar if it does not exceed the height.


Abby Geist was soaking some red kidney beans in the kitchen. Over her shoulder, she remarked to Tom, "Christianity, you know, is white supremacist."
"It is?"
"Of course: it has been instrumental in a system of white oppression and worldwide terrorism for 500 years."


---
layout: post
title: MATLAB Programming/Struct Arrays - Wikibooks, open books for an open world
tags:
- matlab
- struct array
- array of structs
---
MATLAB Programming/Struct Arrays - Wikibooks, open books for an open world
In Matlab, working with arrays of structs can be quite unintuitive - this page had some very helpful tips.


This document introduces Deferred
s, Twisted's preferred mechanism for controlling
the flow of asynchronous code. Don't worry if you don't know what that means
yet—that's why you are here!
It is intended for newcomers to Twisted, and was written particularly to help
people read and understand code that already uses
Deferred
s.
This document assumes you have a good working knowledge of Python. It assumes no knowledge of Twisted.
By the end of the document, you should understand
what Deferred
s are and
how they can be used to coordinate asynchronous code. In particular, you
should be able to:
- Read and understand code that uses
Deferred
s - Translate from synchronous code to asynchronous code and back again
- Implement any sort of error-handling for asynchronous code that you wish
The joy of order
When you write Python code, one prevailing, deep, unassailled assumption is that a line of code within a block is only ever executed after the preceding line is finished.
1 2
pod_bay_doors.open() pod.launch()
The pod bay doors open, and only then does the pod launch. That's wonderful. One-line-after-another is a built-in mechanism in the language for encoding the order of execution. It's clear, terse, and unambiguous.
Exceptions make things more complicated. If
pod_bay_doors.open()
raises an exception, then
we cannot know with certainty that it completed, and so it would be wrong to
proceed blithely to the next line. Thus, Python gives us
try
, except
,
finally
and else
,
which together model almost every conceivable way of handling a raised
exception, and tend to work really well.
Function application is the other way we encode order of execution:
1
pprint(sorted(x.get_names()))
First x.get_names()
gets called,
then sorted
is called with its return value, and
then pprint
with
whatever sorted
returns. It can also be written
as:
1 2 3
names = x.get_names() sorted_names = sorted(names) pprint(sorted_names)
Sometimes it leads us to encode the order when we don't need to, as in this example:
1 2 3 4
total = 0 for account in accounts: total += account.get_balance() print "Total balance $%s" % (total,)
But that's normally not such a big deal.
All in all, things are pretty good, and all of the explanation above is laboring familiar and obvious points. One line comes after another and one thing happens after another, and both facts are inextricably tied.
But what if we had to do it differently?
A hypothetical problem
What if we could no longer rely on the previous line of code being finished
(whatever that means) before we started to interpret & execute the next
line of code? What if pod_bay_doors.open()
returned immediately, triggering something somewhere else that would
eventually open the pod bay doors, recklessly sending the Python interpreter
plunging into pod.launch()
?
That is, what would we do if the order of execution did not match the order
of lines of Python? If returning
no longer meant finishing
?
In other words, how can we deal with asynchronous operations?
How would we prevent our pod from hurtling into the still-closed doors? How could we respond to a potential failure to open the doors at all? What if opening the doors gave us some crucial information that we needed in order to launch the pod? How would we get access to that information?
And, crucially, since we are writing code, how can we write our code so that we can build other code on top of it?
The components of a solution
We would still need a way of saying do this only
when that has finished
.
We would need a way of distinguishing between successful completion and
interrupted processing, normally modeled with try
,
expect
, else
, and
finally
.
We need a mechanism for getting return failures and exception information from the thing that just executed to the thing that needs to happen next.
We need somehow to be able to operate on results that we don't have yet. Instead of acting, we need to make and encode plans for how we would act if we could.
Unless we hack the interpreter somehow, we would need to build this with the Python language constructs we are given: methods, functions, objects, and the like.
Perhaps we want something that looks a little like this:
1 2
placeholder = pod_bay_doors.open() placeholder.when_done(pod.launch)
One solution: Deferred
Twisted tackles this problem with
Deferred
s,
a type of object designed to do one thing, and one thing only: encode an
order of execution separately from the order of lines in Python source code.
It doesn't deal with threads, parallelism, signals, or subprocesses. It doesn't know anything about an event loop, greenlets, or scheduling. All it knows about is what order to do things in. How does it know that? Because we explicitly tell it the order that we want.
Thus, instead of writing:
1 2
pod_bay_doors.open() pod.launch()
We write:
1 2
d = pod_bay_doors.open() d.addCallback(lambda ignored: pod.launch())
That introduced a dozen new concepts in a couple of lines of code, so let's break it down. If you think you've got it, you might want to skip to the next section.
Here, pod_bay_doors.open()
is returning a
Deferred
, which we
assign to d
. We can think
of d
as a placeholder, representing the value
that open()
will eventually return when it
finally gets around to finishing.
To say do this next
, we add a callback to
d
. A callback is a function that will be called
with whatever open()
eventually returns. In this
case, we don't care, so we make a function with a single, ignored parameter
that just calls pod.launch()
.
So, we've replaced the order of lines is order of execution
with a
deliberate, in-Python encoding of the order of execution,
where d
represents the particular flow and
d.addCallback
replaces new line
.
Of course, programs generally consist of more than two lines, and we still don't know how to deal with failure.
Getting it right: The failure cases
In what follows, we are going to take each way of expressing order of
operations in normal Python (using lines of code and and
try
/except
) and
translate them into an equivalent code built with Deferred
objects.
This is going to be a bit painstaking, but if you want to really understand
how to use Deferred
s
and maintain code that uses them, it is worth understanding each example
below.
One thing, then another, then another
Recall our example from earlier:
1
pprint(sorted(x.get_names()))
Also written as:
1 2 3
names = x.get_names() sorted_names = sorted(names) pprint(sorted_names)
What if neither get_names
nor sorted
can be relied on to finish before they
return? That is, if both are asynchronous operations?
Well, in Twisted-speak they would return Deferred
s and so we would write:
1 2 3
d = x.get_names() d.addCallback(sorted) d.addCallback(pprint)
Eventually, sorted
will get called with
whatever get_names
finally delivers.
When sorted
finishes, pprint
will be called with whatever it
delivers.
We could also write this as:
1
x.get_names().addCallback(sorted).addCallback(pprint)
Since d.addCallback
returns d
.
Simple failure handling
We often want to write code equivalent to this:
1 2 3 4
try: x.get_names() except Exception, e: report_error(e)
How would we write this with Deferred
s?
1 2
d = x.get_names() d.addErrback(report_error)
errback is the Twisted name for a callback that is called when an error is received.
This glosses over an important detail. Instead of getting the exception
object e
, report_error
would get a Failure
object, which has all of the useful information
that e
does, but is optimized for use
with Deferred
s.
We'll dig into that a bit later, after we've dealt with all of the other combinations of exceptions.
Handle an error, but do something else on success
What if we want to do something after our try
block if it actually worked? Abandoning our
contrived examples and reaching for generic variable names, we get:
1 2 3 4 5 6
try: y = f() except Exception, e: g(e) else: h(y)
Well, we'd write it like this with Deferred
:
1 2
d = f() d.addCallbacks(h, g)
Where addCallbacks
means add a callback and an
errback at the same time
.
h
is the callback,
g
is the errback.
Now that we have addCallbacks
along
with addErrback
and addCallback
, we can match any possible
combination
of try
, except
, else
and finally
by varying the order in which we call
them. Explaining exactly how it works is tricky (although
the Deferred reference does rather a good job), but
once we're through all of the examples it ought to be clearer.
Handle an error, then proceed anyway
What if we want to do something after
our try
/except
block,
regardless of whether or not there was an exception? That is, what if we
wanted to do the equivalent of this generic code:
1 2 3 4 5
try: y = f() except Exception, e: y = g(e) h(y)
And with Deferred
:
1 2 3
d = f() d.addErrback(g) d.addCallback(h)
Because addErrback
returns d
, we can chain the calls like so:
1
f().addErrback(g).addCallback(h)
The order of addErrback
and addCallback
matters. In the next section, we
can see what would happen when we swap them around.
Handle an error for the entire operation
What if we want to wrap up a multi-step operation in one exception handler?
1 2 3 4 5
try: y = f() z = h(y) except Exception, e: g(e)
With Deferred
, it
would look like this:
1 2 3
d = f() d.addCallback(h) d.addErrback(g)
Or, more succinctly:
1
d = f().addCallback(h).addErrback(g)
Do something regardless
What about finally
? How do we do something
regardless of whether or not there was an exception? How do we translate
this:
1 2 3 4
try: y = f() finally: g()
Well, roughly we do this:
1 2
d = f() d.addBoth(g)
This adds g
as both the callback and the errback.
It is equivalent to:
1
d.addCallbacks(g, g)
Why roughly
? Because if f
raises, g
will be passed a Failure
object representing the
exception. Otherwise, g
will be passed the
asynchronous equivalent of the return value
of f()
(i.e. y
).
Conclusion
You have been introduced to asynchronous code and have seen how to
use Deferred
s to:
- Do something after an asynchronous operation completes successfully
- Use the result of a successful asynchronous operation
- Catch errors in asynchronous operations
- Do one thing if an operation succeeds, and a different thing if it fails
- Do something after an error has been handled successfully
- Wrap multiple asynchronous operations with one error handler
- Do something after an asynchronous operation, regardless of whether it succeeded or failed
These are very basic uses of
Deferred
. For
detailed information about how they work, how to combine multiple Deferreds,
and how to write code that mixes synchronous and asynchronous APIs, see
the Deferred reference. Alternatively, read
about how to write functions that generate
Deferreds.


--- layout: archive title: Zulip Chat Archive permalink: /stream/116395-maths/topic/bundling.20normal.20subgroups.html ---
Should normal subgroups be bundled? I am a bit confused about this.
Subsets of a group G are bundled -- they're set G
. The general concensus amongst the community is that subgroups of G should also be bundled -- they can be subgroup G
. There's a local project at Imperial with bundled subgroups and they're working fine.
But we're venturing into quotients so we need the notion of a normal subgroup. If we also bundle these as normal_subgroup' G
then we have the issue that a normal subgroup of G is now not a subgroup. We can put a coercion to subgroups, but then there's sometimes a coercion from subgroups to subsets, and we are ending up with double coercions and things just don't look good.
Thinking about how to solve this made me realise that I don't really understand what's going on. Are we bundling subgroups because they just seem to work better? Is the idea that we bundled submodules and they worked really well? Is there an argument for making normal subgroups a typeclass on subgroups? This feels similar to making subgroups a typeclass on subsets -- which is what the community decided to move away from. What are the disadvantages of letting normal subgroups be a typeclass on bundled subgroups?
@Chris Hughes do you have an opinion about this? Sorry to bother you.
I think that probably bundling normal subgroups will be best. There'll be type class inference problems otherwise with quotient groups. A lot of these decisions depend on what happens in Lean4. Hopefully we'll have unification hints that work nicely.
Then should there be coercions from normal subgroups to subgroups, and from subgroups to subsets, and from normal subgroups to subsets?
Yes, but then there should probably be mem on all of this stuff as well.
I guess ideal R
is bundled ideals and Spec R
is bundled prime ideals.
Oh wow Amelia just pointed out
@[class] def is_prime (I : ideal α) : Prop := I ≠ ⊤ ∧ ∀ {x y : α}, x * y ∈ I → x ∈ I ∨ y ∈ I
What's going on there? I don't even understand how a definition which isn't a structure can be tagged as a class.
Is that another way of doing normal subgroups?
It's possible but a bad idea, but I can't remember why. Something to do with it being semireducible.
I think normal should be a predicate on subgroups, and quotient groups should be defined relative to arbitrary sets or arbitrary subgroups (not sure which) by taking the normal closure
You can make a quotient by a non-normal subgroup, it's just a set with an action of the big group
it's not a group though
No. What do you mean by predicate? No type class inference at all?
right
I'm not positive, it depends on how this predicate is used
when do you need normality anyway?
When you're teaching undergraduates group theory
a predicate is preferable for teaching undergrads
typeclass inference is confusing
Fair point
OK, now #2140 is close to hitting mathlib (hopefully -- any reviews welcome) we need to make a decision on normal subgroups. There are two possibilities: (1) bundling (i.e. a new type normal_subgroup G
) (2) a predicate is_normal
on subgroup G
which isn't a class (3) a predicate is_normal
on subgroup G` which is a class.
Mario asked "when do you need normality anyway?" and my initial answer was "teaching" but now it's "research" -- we use quotient groups in the perfectoid project, and currently we're quotienting out by an unbundled normal subgroup. I'd like to get started on this but I don't know what to do. Mario suggested quotienting out by general subsets (defined to be quotienting out by the normal closure) and because I don't actually need normal subgroups per se, but rather quotient groups, this would also be good for me.
I am completely happy if the answer is "make a random choice and see how it works out" but what I want to avoid is me refactoring group_theory/quotient_group.lean
and then in the PR process someone saying "you should have done it another way".
In fact maybe this is not even the right question! I don't even care about normal subgroups. I care about quotient groups. Currently the set-up is
quotient_group.quotient : Π {α : Type u_1} [_inst_1 : group α] (s : set α) [_inst_2 : is_subgroup s], Type u_1
(this is just the type of cosets) and then an instance of type
Π {G : Type u_1} [_inst_1 : group G] (N : set G) [_inst_2 : normal_subgroup N], group (quotient N)
My question is simple: should I PR some more lemmas about quotient groups, or should I take the opportunity to refactor quotient groups in some way? If so, how? I would like to come to a firm decision before starting the PR.
You should randomly choose (1)
But it sounds like this is what you have already?
Oh wait, no I misread.
In perfectoid spaces, are you taking quotients of abelian groups?
Yes
but I decided not to mention this because I thought it would muddy the water.
{% endraw %}Last updated: Apr 24 2020 at 19:02 UTC


ACTION & SHOOTING
RACING
ARCADE
BATTLE ROYALE
FANTASY
HORROR
PUZZLES & CLASSICS
THE RIGHT BYTE!
Super Mario
A platform game
series developed by
Nintendo.
Trailer
₹259
Add to Cart!
Pacman
A 1980 maze action game
developed by
Namco.
Trailer
₹159
Add to Cart!
Donkey Kong
A game featuring an ape's
adventures developed by
Shigeru Miyamoto.
Trailer
₹199
Add to Cart!

Trailer
₹99
Add to Cart!
Road Rash
A motorcyle racing video
game developed by
Electronic Arts.
Trailer
₹169
Add to Cart!
Space Invaders
A 1987 shoot'em up
game developed by
Tomohiro Nishikado.
Trailer
₹299
Add to Cart!


The Javascript solution requires touch event support so either use your iOS or Android mobile device. Another solution is to use the touch emulator in chrome (remember to reload the page after having enabled it).
This could be used a fall back for browsers that doesn't support the webkit touch event (like Windows Phone or just regular desktops). It only requires you to add the switch
class.


Microsoft and NVIDIA join up to boost 'cutting-edge' AI startups
Microsoft for Startups and NVIDIA Inception want to give innovative AI startups a little help.
by Dan Thorp-LancasterSource: Daniel Rubino/Windows Central
What you need to know
- Microsoft for Startups and NVIDIA Inception are 'joining forces.'
- The two companies will offer preferred access to their startup programs for "cutting-edge" AI startups.
- The programs give startups free or discounted technology, access to experts, and go-to-market support.
Microsoft and NVIDIA announced today that they're teaming up to give a boost to "cutting-edge" AI startups. The two companies are combining forces with their Microsoft for Startups and NVIDIA Inception programs, giving AI startups "preferred access" to extra resources to bring their ideas to life. This includes free or discounted technology, access to expers, and go-to-market support.
Here's a look at all of what's included for the preferred partners:
- Free access to Microsoft technologies, including up to $120k of free Azure cloud.
- Dedicated go-to-market resources to help startups sell alongside our global sales teams and partner channel.
- Free credits for NVIDIA Deep Learning Institute online courses, such as the Fundamentals of Deep Learning for Computer Vision, Accelerating Data Science, and Image Classification.
- Access to go-to-market NVIDIA Inception Connect events and marketing support.
- Unlimited access toDevTalk—a forum built for technical inquiries and community engagement.
- Guidance on which GPU applications and hardware are best suited for your needs.
- Discounts on NVIDIA DGX systems, NVIDIA GPU accelerators, NVIDIA Quadro pro graphics, and NVIDIA TITAN GPUs for deep learning.
"This partnership will allow us to accelerate AI startups with NVIDIA's deep technical expertise and market-leading GPU technology on Microsoft Azure, combined with both companies' ability to connect startups with customers," Microsoft said in a press release.
Microsoft for Startups launched in 2018 and offers a mix of technical help, development tools, and other support for bringing startups' products to life. NVIDIA Inception got its start in 2016, and it similarly offers go-to-market support and technology solutions for innovative startups. You can learn more at Microsoft and NVIDIA about each program.
We may earn a commission for purchases using our links. Learn more.


Upload New and Updated Subscriptions records here.
Please limit file size to 3MB
Expecting *.tsv file in the format:
- Customer id (an integer)
- Customer first name
- Customer last name
- Customer street address (assume US addresses only)
- Customer state (assume US addresses only)
- Customer zip code (assume US addresses only)
- Change in purchase status - this will be either 'new' or 'canceled'
- Product id for purchase (an integer)
- Product name (a string, not longer than 100 characters)
- Product purchase amount (in US dollars)
- Date and time in ISO8601 format, i.e. 2007-04-05T14:30Z
{% endblock content %}


Note
Click here to download the full example code
External Tensor Functions¶
Author: Tianqi Chen
While TVM supports transparent code generation, sometimes it is also helpful to incorporate manual written code into the pipeline. For example, we might want to use cuDNN for some of the convolution kernels and define the rest of the stages.
TVM supports these black box function calls natively. Specfically, tvm support all the tensor functions that are DLPack compatible. Which means we can call any function with POD types(pointer, int, float) or pointer to DLTensor as argument.
from __future__ import absolute_import, print_function
import tvm
import numpy as np
from tvm.contrib import cblas
Use Extern Tensor Function¶
In the example below, we use tvm.extern
to add an extern
array function call. In the extern call, we declare the shape
of output tensors. In the second argument we provide the list of inputs.
User will need to provide a function describing how to compute the result. The compute function takes list of symbolic placeholder for the inputs, list of symbolic placeholder for the outputs and returns the executing statement.
In this case we simply call a registered tvm function, which invokes a CBLAS call. TVM does not control internal of the extern array function and treats it as blackbox. We can further mix schedulable TVM calls that add a bias term to the result.
n = 1024
l = 128
m = 235
bias = tvm.var('bias', dtype=tvm.float32)
A = tvm.placeholder((n, l), name='A')
B = tvm.placeholder((l, m), name='B')
C = tvm.extern((n, m), [A, B],
lambda ins, outs: tvm.call_packed(
"tvm.contrib.cblas.matmul",
ins[0], ins[1], outs[0], False, False), name="C")
D = tvm.compute(C.shape, lambda i, j: C[i,j] + bias, name="D")
s = tvm.create_schedule(D.op)
Verify the Result¶
We can verify that the result matches what we expected.
ctx = tvm.cpu(0)
f = tvm.build(s, [A, B, D, bias], "llvm")
a = tvm.nd.array(np.random.uniform(size=(n, l)).astype(A.dtype), ctx)
b = tvm.nd.array(np.random.uniform(size=(l, m)).astype(B.dtype), ctx)
d = tvm.nd.array(np.zeros((n, m), dtype=D.dtype), ctx)
bb = 10.0
f(a, b, d, bb)
np.testing.assert_allclose(
d.asnumpy(), np.dot(a.asnumpy(), b.asnumpy()) + 10, rtol=1e-5)
Extern Contrib Wrappers¶
TVM also provide extern contrib wrappers to useful extern calls, the following line is equivalent to the previous example.
from tvm.contrib import cblas
C = cblas.matmul(A, B)
D = tvm.compute(C.shape, lambda i, j: C[i,j] + bias, name="D")
s = tvm.create_schedule(D.op)
Hook Python Function as Extern¶
Since we can call into any PackedFunc in TVM. We can use the extern function to callback into python.
The following example registers a python function into tvm runtime system and use it to complete one stage of the computation. This makes TVM much more flexible. For example, we can insert front-end callbacks to inspect the intermediate results or mix customized code with TVM.
@tvm.register_func("tvm.contrib.my_tvm_addone")
def my_tvm_addone(x, y):
print("my_tvm_addone signatures: %s, %s" % (type(x), type(y)))
tvm.nd.array(x.asnumpy() + 1).copyto(y)
A = tvm.placeholder((n,), name='A')
B = tvm.extern(A.shape, [A], lambda ins, outs: tvm.call_packed(
"tvm.contrib.my_tvm_addone", ins[0], outs[0]), name="C")
s = tvm.create_schedule(B.op)
f = tvm.build(s, [A, B], "llvm")
a = tvm.nd.array(np.random.uniform(size=(n,)).astype(A.dtype), ctx)
b = tvm.nd.array(np.random.uniform(size=(n,)).astype(B.dtype), ctx)
f(a, b)
np.testing.assert_allclose(b.asnumpy(), a.asnumpy() + 1, rtol=1e-5)
Summary¶
TVM calls extern tensor function via
tvm.extern
Use contrib wrappers for short sugars of extern tensor calls.
We can hook front-end function as extern tensor callbacks.
Total running time of the script: ( 0 minutes 0.000 seconds)


Welcome to Hoodie Camp!
We created this place to welcome new and existing Hoodie contributors and to help maintainers keep an overview.
Code team
Moin! I’m Charlie the Dev Beaver.
I love clean code and a great developer experience.
- No issues right now, check back later!
Design team
¿Qué tal? I’m the Design Alpaca. I care about accessability and ease of use of our websites and apps.
- No issues right now, check back later!
Docs team
Docs docs docs! I’m the Docs Chicken and I make sure that all our code is well documented.
- No issues right now, check back later!
Editorial team
Salut! We have lots of good stories here at Hoodie, I love to share them!
- No issues right now, check back later!


List Sample - Web Storage
Sync
Switch User
Clear Local
User:
Name:
Description:
Created Date:
Name:
Description:
Priority:
Status:
Start Date:
End Date:
Are you going to delete it?
+
Add List
Debug Output
Local Storage
Refresh