Hello, an EC Engineer from Heritage Institute of Technology Kolkata here. I am in love with
IoT and Robotics as I have spent hours working on on them, while Research and Teaching have
also been my priorities. Currently serving as Front-End Developer at TCS, Kolkata.
I have led the IEEE Student Chapter of my college and have conducted various Technical
activities under my leadership.
Was a professional teacher for Unacademy teaching Electronics. Also taught to
underpivileged kids for the
Rotaract Club of my Institute.
Being a good human is my first while learning from yesterday isn't among the last.
Download CVGet in touch
A gallery of few of the things I have done so far.
Qualities that I have gathered over time and feel proud to decorate the shelf.
Had keen interest in chasing the field as just not professon but passion.
Have developed quite a few projects and publications in the area of device modelling & simulation.
From my high school, I developed a love of sharing information with my fellow mates and juniors.
Starting from Frontend with Angular and Backend Technologies with Python are my daily routine.
Imparting intelligence to skillfully trained bots are weekend activites to make the most of.
Internships, Research activities and Current Work Performas.
Start Date : 10 Jun'19
Position : Front End Developer
I am working as a DevOps Engineer focussing on mainly the Front End Development.
Angular is the main software used
for the project frontend.
Developed fully functional responsive prototypes
based on Business Requirements using
HTML/HTML5, CSS3, JavaScript and JQuery.
Gained exposure in full
life-cycle implementation with skills in executing
Sofware Development Life Cycle (SDLC) in compliance to quality control.
Gained exposure in end-to-end development of
software products, from requirement analysis to designing, coding and testing
Integrated software components into a
fully functional software system.
Modified existing software to correct
errors, upgrade interfaces and improve
performance
Visit/Reference : www.tcs.com
Comparative Study of Variations in Gate Oxide Material of a Novel Underlap DG MOS-HEMT for Analog/RF and High Power Applications
In this paper an Underlap Double Gate (U-DG) Symmetric Heterojunction AlGaN/GaN Metal Oxide Semiconductor High Electron Mobility Transistor (MOS-HEMT) with gate oxide materials of different dielectric constant has been studied using gate oxide materials such as Hafnium dioxide (HfO2), Silicon dioxide (SiO2) and a symmetric gate stack (GS) of HfO2-SiO2. In this work, the analog performance of the devices has been studied on the basis of parameters like transconductance (gm), transconductance generation factor (gm/ID) and intrinsic gain (gmR0). This paper depicts the effect of varying oxide materials on the analog and RF figure of merits (FOMs) such as the gate to drain capacitance (CGD), gate to source capacitance (CGS) and total gate capacitance (CGG), intrinsic resistances, cut-off frequency (fT) and maximum frequency of oscillation (fMAX) using non-quasi-static approach. Studies show that the introduction of a gate oxide layer in the MOS-HEMT device increases the gate controllability reducing gate leakage currents improving RF performance. U-DG AlGaN/GaN MOS-HEMT with HfO2 gate dielectric shows superior Power output efficiency (POE) of 55% compared to the HfO2-SiO2 composite structure and SiO2 with 26% and 20% respectively.
Influence of Channel Thickness on Analog and RF Performance Enhancement of an Underlap DG AlGaN/GaN based MOS-HEMT Device
This paper elucidates a comprehensive, illustrative and qualitative study on the Analog and RF performance of an Underlapped Double-Gate (U-DG) AlGaN/GaN heterojunction-based MOS-HEMT device with Hafnium-based high-k dielectric gate material. This paper presents the effect of GaN channel thickness variation on the drain current (I d ), the transconductance (g m ), output resistance (RO), the intrinsic gain (g m R o ), transconductance generation factor (g m /I d ) and the RF FOMstotal intrinsic gate capacitance (C gg ) and cut-off frequency (fτ). These hetero-structured devices show superior performance as power transistors due to its enhanced efficiency, cost-effectiveness, reliability and controllability over silicon based conventional DG-MOS and HEMT transistors.
Start Date : 18 Jul'19
Position : IoT Advisor
Have been advising young students and interns about the basics of Internet of Things and have developed several projects on the same.
Visit/Reference : www.mindwebs.org
Start Date : 1 June'18 End Date : 1 July'18
Position : Electronics Design Intern
I was an Intern at the eCOE of Bhubaneswar where I learnt VLSI Design and Layout using Tanner tools. Also learnt about FPGA Designing using Verilog.
Visit/Reference : Electronic Center of Excellence
Start Date : 14 May'17 End Date : 28 May'17
Position : Vocational Trainee
I was a trainee at the Electronics Department at the Airports Authority of India Kolkata where I learnt about all the Electronic Systems in and around the airport including X-Ray Scanning Systems, CCTV Systems, Flight Monitoring Systems etc
Visit/Reference : Airports Authority of India
Start Date : 1 Apr'18 End Date : 31 Aug'18
Position : Educator
I was an Electronics Online Educator for Unacademy and have made over 100+ course videos with more than 1300 minutes of course content.
Visit/Reference : Unacademy
Start Date : 1 Jan'19 End Date : 29 Mar'19
Position : Front End Developer Intern
I was appointed an as Intern in a Development Project where I learnt about the basics of Web Development. Worked on API Gateway Generator using Angular and Flask.
Visit/Reference : www.tcs.com
Start Date : 1 Jan'19 End Date : 29 Mar'19
Position : Manchine Learning Intern
I worked on Python and used NLP to complete the project 'Contextual Chatbot'.
Visit/Reference : www.tcs.com
Acclaim :
Capgemini Global AI Hackathon: Judges' Favourite
BIT Mesra National Hackabit 2018: 4th Position
Sankalp Solar Harvesting Hackathon: Top 15 in India
Abstract :
SunChargers is a Solar Charged Street
Automation Product which packs features
like Solar Tracking, Automatic Fault Detection and Alert, Light Intensity
Controlling and Solar Powered Car Charging Station along with SOS Features and
Traffic Mapping System.
Visit/Reference : Video Demonstration
Solar Charged Street Automation Product
Using Field Programmable Gate Array
Instructor for School & College Students
Working with Circuits
An interactive forum for students & corporates.
Dooars, India
Low-light Photography
Using Node & Flask
Some words of worth, feedback or suggestions from my teachers, fellow mates, co-workers and beloved juniors.
Gariahat
Send me your query anytime!


Half-price wedding up for grabs at Priory Hall or Thomas Robinson
Two of Dudley's most popular wedding venues are offering a half-price deal on wedding booked in the run up to Christmas
by Oprah Flash, https://www.birminghammail.co.uk/authors/oprah-flash/Have you got your heart set on a winter wedding?
While tying the knot is an exciting occasion for you and your loved ones, it can also hit your bank balance pretty hard.
Fear not, if you've got plans for a wedding in the New Year there's a half-price bonus up for grabs
It’s not your average stocking-filler but brides and grooms could save money this Christmas by making a half-price booking at one of Dudley Council’s wedding venues .
Anyone who books a Saturday wedding at Dudley’s stunning Priory Hall or Stourbridge’s beautiful Thomas Robinson building to take place in January can bag themselves a half-price ceremony.
It means they have to be booked before Christmas, making the perfect festive gift.
Staff at the popular wedding venues have decided to trial this quirky deal to help people beat the winter blues and save money in an unusual way.
The offer relates to the Priory Suite at Priory Hall and the Wollescote Suite at Thomas Robinson.
"Penny Fulford, superintendent registrar at Dudley Council, said: "January is a tricky time for household finances. We wanted to do something to help people rise above this and focus on what’s important to them, so we decided to try out this special winter sale.
Dudley news and social media
DudleyLive is the brand to trust on social media. Follow for up-to-the-minute news as well as the odd jokes and meme.

You can also follow us on Twitter and Instagram.
Newsletter
You can get the latest Black Country news sent direct to your email inbox every day.
"I hope that it gives people a bit of New Year cheer - all that remains is for couples to pop the question and treat their loved one to a quirky pre-Christmas stocking filler!"
For more details on the wedding sale, call 01384 815373, visit Dudley's register office online or email<EMAIL_ADDRESS>For all things bostin' in the Black Country on our We Love The Black Country Facebook group - where you'll get the latest news, travel, weather and events in your area.
Keep up-to-date with all things Dudley on our Dudley Live Facebook page - where you'll get the latest news, travel, weather and events in your area.


How do you want to pay?
View current plan
You must pay the remaining amount by 28 July 2019.
{% else %}| Regular payments of | £100 | |
| Frequency of payments | Monthly |
{% extends "layout.html" %}
{% block page_title %}
Money Claims Prototype
{% endblock %}
{% block proposition_header %}
{% set my_account="2" %}
{% include "includes/propositional_navigation.html" %}
{% endblock %}
{% block content %}
You must pay the remaining amount by 28 July 2019.
How do you want to pay?
View current plan
Regular payments of
£100
Frequency of payments
Monthly


| find_plink {pbdRPC} | R Documentation |
Find the plink internal compiled with pbdRPC package.
find_plink()
The function returns a full path to the plink
or plink.exe
command if found.
A full path a full path to the plink
or plink.exe
command if found. Otherwise, "plink" is returned.
## Not run: library(pbdRPC, quietly = TRUE) find_plink() ## End(Not run)


As a current student and New Jerseys institute of technology, I am currently searching for opportunities within my field of both Computer Science and Web and Information Systems. Since graduating high school back in 2012, I have been fascinated about the tech world we live in. it not just about the apps we have on the phone and Facebook, but the back end and front end of systems, the process and steps taken to build something, to implement systems and work with new hardware to improve our processes. I try to get myself acquainted and experienced within the different branches that stem of the Tech field. Working in IT positions, Web development and application development. My skills are still growing for every semester and every job bring new knowledge to me.
Wallkill Valley Regional High School
Graduated: June 2012
10 Grumm Rd, Hamburg, NJ 07419
Sussex County Community College
Graduated: May 2015 -AS in Computer Science
1 College Hill Rd, Newton, NJ 07860
New Jersey Institute of Technology
*Currently Attending*-Expected Grad Date: May 2018
323 Dr Martin Luther King Jr Blvd, Newark, NJ 07102
PlanIT Networks, Blairstown NJ(July 2015-July 2016)
Delaware Cemetery Association, Dingmans Ferry ,PA(Summer, 2014)
Weis Markets Newton ,NJ (August 2012- August 2015
The Pet Spa and Resort, Franklin NJ(August 2016-Current)
Programming languages worked in:
Bilingual: English/Spanish
Usage of Git, and GitHub and Trello
Able to adapt in different working environments.
Communication with others to clearly depict what is needed and must be done for a project to be completed.
The button below will redirect to my Github page.
Need to contact me? Fill out the form below to send me an email! Phone number is optional.


| Methods' Details |
getCanvas
- Description
- Get view canvas.
This method gets the underlying XCanvas to display on this
view.
- Returns
- XSpriteCanvas to display on. Must be valid, and the
same object, as long as this view is added to any slide show.
|
|
clear
- Description
- This method clears the whole view area.
The slideshow uses this method to fully erase the view
content. Since the slideshow has no notion of view size, this
is the only reliable way to wholly clear the view.
|
|
getTransformation
- Description
- Query the current transformation matrix for this view.
This method returns the transformation matrix of the
view. When notified via the transformation change listener,
the show will be displayed using the new transformation.
- Returns
- the view transformation matrix. Note that the slide
show itself will paint all slides as one-by-one boxes, one
therefore has to at least provide a scaling at this matrix to
blow this up to the desired device pixel size (640 times 480,
or whatever size the output view has). Furthermore, the aspect
ratio of the scaling should match that of the slides
(otherwise, the slides will be scaled anisotrophically).
|
|
addTransformationChangedListener
| void |
| addTransformationChangedListener( |
[in] ::com::sun::star::util::XModifyListener |
xListener ); |
- Description
- Add a listener to get notified when the transformation matrix changes.
This method registers a listener with the view, which will get
called everytime the transformation matrix changes.
- Parameter xListener
- Listener interface to call when the transformation matrix changes.
|
|
removeTransformationChangedListener
| void |
| removeTransformationChangedListener( |
[in] ::com::sun::star::util::XModifyListener |
xListener ); |
- Description
- Revoke a previously registered transformation matrix change listener.
- Parameter xListener
- Listener interface to revoke from being called.
|
|
addPaintListener
- Description
- Add a listener to get notified when this view needs a repaint.
This method registers a listener with the view, which will get
called everytime the view needs an update of their screen
representation.
- Parameter xListener
- Listener interface to call when the view needs a repaint.
|
|
removePaintListener
- Description
- Revoke a previously registered paint listener.
- Parameter xListener
- Listener interface to revoke from being called.
|
|
addMouseListener
- Description
- Add a mouse listener to the view.
This method registers a listener with the view, which will get
called everytime the mouse is clicked on the view.
- Parameter xListener
- Listener interface to call when the mouse is clicked on the view.
|
|
removeMouseListener
- Description
- Revoke a previously registered mouse listener.
- Parameter xListener
- Listener interface to revoke from being called.
|
|
addMouseMotionListener
- Description
- Add a mouse motion listener to the view.
This method registers a listener with the view, which will get
called everytime the mouse is moved on the view.
- Parameter xListener
- Listener interface to call when the mouse is moved on the view.
|
|
removeMouseMotionListener
- Description
- Revoke a previously registered mouse move listener.
- Parameter xListener
- Listener interface to revoke from being called.
|
|
setMouseCursor
| void |
| setMouseCursor( |
[in] short |
nPointerShape ); |
- Description
- Change the mouse cursor currently in effect.
This method changes the mouse cursor currently in effect, for
this view.
- Parameter nPointerShape
- New mouse cursor shape to display for this view. Must be from
the ::com::sun::star::awt::SystemPointer constant group.
|
|
getCanvasArea
- Description
- Get rectangle defining area inside of canvas device which
this slideshow view uses.
|
|
Copyright © 2013, The Apache Software Foundation, Licensed under the Apache License, Version 2.0. Apache, the Apache feather logo, Apache OpenOffice and OpenOffice.org are trademarks of The Apache Software Foundation. Other names may be trademarks of their respective owners.


Content Elements
The content elements provide features to support robust content organization, distribution, animation and optimization.
Independent Elements
These elements work independently within the realm of content. No special enabling or parent tag necessary. Just include the element along with configuration attributes to use them.
Content Rendering
These elements render content from various sources in two different formats, HTML n-content and Markdown n-content-markdown.
Data-Driven Content
Content Animation
These elements are for direct interaction with the user. The n-content-reveal


--- title: "Research Paper: Final Submission" linktitle: "08 Final" date: "2020-06-22" due_date: "2020-12-08" due_time: "11:59 PM" menu: assignment: parent: Research Paper weight: 30 type: docs editor_options: chunk_output_type: console output: blogdown::html_page: toc: true ---
Research papers are fairly formulaic, and that’s a good thing - it helps readers know where to look for information, depending on what they want to get out of it.
Your paper is due at 11:59pm December 08. I cannot accept extensions, as there are external grading deadlines I need to meet.
You should submit the following:
I will grade your papers following the rubric. If you would like me to share comments, you must opt-in by filling out the feedback survey. If you do not fill it out, you will not receive feedback!
A reasonable approach is to pull up an academic paper you’re citing that is in the economics literature and see how it’s structured. However, here is more general guide. While a good paper will meet these criteria, please note that, this is not a grading rubric!
First-person active voice! (I estimate a regression, NOT “A regression is estimated”)
Single-authored paper first person singular, “I.” (You’re not the queen!)
Joint-authored paper first person plural, “we.”
Don’t believe me? Check out any economics paper published in the past 20 years. There’s some variation in I vs. we, but all use active voice.
Paper written in present tense
Paper divided into numbered, labeled sections.
A research paper is not an essay!
Personal opinions don’t have a place
Sources should be primarily academic (peer-reviewed journals, working papers, etc.), maybe some non-academic sources for motivation only
Clear, labeled sections
You’ll need a title and an abstract
Descriptive title
Abstract that summarizes the paper and findings in 200 words or less
In an economics paper, and introduction stands alone! That is, a tired person could read the introduction and understand what you did, what you found, and why it matters. Our papers are not mystery novels - there’s no need for a plot twist on page 8!
I’m a big fan of the introduction formula, which is written for folks writing a longer academic paper, but the principles are still solid.
Introduction reads like an academic article. Motivates, describes what you do and what you find. (Almost like a mini-paper!)
States your research question clearly
Explains what economic theory says about the potential answers to your questions, and/or defines clear hypotheses that you test
Describes why your topic is important
Describes what you do
Describes what you find
Describe how it contributes to knowledge
What you include here depends on topic. Sometimes the reader needs to know how your question links to economic theory. Sometimes it’s more important to know specific context first, and then to turn to the literature. Sometimes it’s most important to summarize what the literature already knows. Your call.
At the back of your mind, when motivating your paper, ask “what is the link to economics”?
If studying discrimination, what does economic theory tell us about why discrimination exists/persists
If studying stock market returns, what do economic models tell us about our ability to predict returns?
Includes papers that have answered your research question (or similar research questions)
Research results described in present tense (“Smith finds,” not “Smith found”)
Papers are put in context. That is, rather than just listing paper A and finding, paper B and finding, etc, you link each one (or group) to their contribution (as relates to your research question)
Describe the data you use, where did it come from? If you didn’t create it, cite it
What is the unit of observation? Is it people, households, states, etc? Make sure the unit is appropriate to your question
If you’re working with individual-level data, what is the age range you want in your sample? What years of data do you need?
If dealing with labor force variables, do you want all people of working age, all those who are in the labor force, or all who are employed?
Describe your methodology. Are you estimating a model using OLS? If so, say so.
Clarify whether we are looking at causal estimates or something else. What are the estimated parameters of interest. What do they mean?
Correct standard errors: robust? Clustered? Something else?
Write out your population model!
If you’re using Word, use equation editor. Make it look nice.
Don’t forget the error term!
Use proper equation notation (\(\beta\), \(u\), etc)
Use appropriate subscripts (\(i\), \(t\), \(y\), etc)
All relevant variables explained/defined
Use “real names” to describe variables when possible (ie use \(female\) for women, not \(w1\))
Make sure your variables are written correctly - an equation like \(wage = \alpha_0 + \alpha_1 race\) doesn’t make sense - race isn’t continuous!
If you are using a lot of categorical variables and find it awkward to write them out, you can simplify:
\[y_{st} = \beta_0 + \beta_1 X_{st} + \beta_2 Z_t + ... + f_s + u_{st}\]
and the in the text, “…where \(f_s\) is a vector of state fixed effects”
and in the text, “…where \(D_k\) is a dummy variable for occupation \(s\), from \(s \in [1,S]\)” (or something in that general spirit)
When using categorical/dummy variables, what is your omitted category? Make sure you know and that it’s clear.
What are the units of your measures? Is that percent or percentage points?
Discuss using a reasonable number of decimal places (usually only 1 or 2)
Include as a separate section or integrate into results
What might us from making causal interpretations about our coefficient of interest?
Omitted variable bias?
Reverse causality?
Measurement error?
Are the results externally valid?
What other considerations are important?
Brief summary of paper
Limitations (summary of limitations/discussion section)
Implications for policy
Implications for future research
Tables should be properly formatted. That is, they should be made in Excel (or LaTeX) and NEVER copied and pasted out of Stata
Variables should be described using real words. Ie, “number of children,” not “numchld.”
Tables and figures should be numbered (Table 1, Table 2, etc… Figure 1, Figure 2, etc.) and should also be given a title. Refer to tables by their numbers in the text.
Regression tables include standard errors. Use stars to indicate statistical significance. (The Stata package outreg2 is a big help!)
In most contexts, about 3 places past the decimal point is right, but it depends on the magnitudes. If you really want to be precise, set and stick to a reasonable number of significant digits. There’s no place for a number like 0.05403823 or 0.0000000 in your tables.
Use footnotes rather than endnotes
At the end of your paper, include list of references cited
You can format using APA, MLA, or Chicago style
In-text, cite with author and year (Author, Year; Author, Year) or (Author Year, Author Year)
Download rubric here
| Total: 100 marks | 100 = Excellent | 80 = Adequate | 60 = Marginal | 40 = Poor |
|---|---|---|---|---|
| Motivation/Literature (18 marks) | ||||
| Introduction | Introduction provides complete overview of paper, motivates research question using sources | Introduction provides some overiew of paper, motivation clear with limited sources | Introduction vague; motivation minimal | Incomplete introduction, no motivation |
| Research question | Research question well identified, specific | Research question stated, not specific | Research question vague, not answerable | Cannot identify research question in paper |
| Literature | Important literature discussed and linked to topic | Important literature included, not linked to research question/paper | Scattered lit. discussion, poorly linked to topic (missing or irrelevant papers) | Sparse literature, not linked to topic |
| Methodology/Analysis (30 marks) | ||||
| Data | Clear discussion of data sources and any data cleaning; data cleaned appropriately | Data sources referenced but incomplete discussion; some data issues overlooked | Limited discussion of data | No discussion of data sources or cleaning |
| Empirical methods | Methodology discussed and empirical methods applied correctly | Methodology generally correct, with some issues overlooked | Major errors in empirical methods | Fundamental misunderstanding of empirical methods/no microdata used |
| Discussion of results | Results discussed and interpreted clearly | Results discussed, but inadequate interpretation | Results presented without interpretation | Poor discussion of results, no interpretation |
| Choice of evidence | Presented evidence addresses research question, is well utilized | Presented evidence related, only partially addresses research question | Evidence related, but not directly relevant to research question. | Evidence does not address research question |
| Figures and tables | Figures and tables appropriate to analysis, easy to interpret | Appropriate figures/tables included, difficult to interpret | Irrelevant figures/tables included or key figures/tables missing | Insufficient figures/tables, poorly presented |
| Limitations | Limitations discussed and minimized through analysis | Limitations discussed, few steps to minimize | Incomplete discussion of limitations | No discussion of limitations |
| Conclusions/interpretation (18 marks) | ||||
| Conclusions | Clear presentation of conclusions, qualifications, consequences, and contributions | Conclusions established, limited discussion implications and contributions | Fails to make clear conclusions, limited discussion of interpretation/contributions | Cannot discern conclusions |
| Critical thinking | Demonstrates independent and critical thinking | Demonstrates some independent and critical thinking | Limited evidence of independent and critical thinking | No evidence of independent and critical thinking |
| Argumentation | Assertions are qualified and well supported | Most assertions are qualified and well supported | Assertions are overly strong or unsupported | Assertions made in contrast to evidence or without evidence |
| Written presentation (24 marks) | ||||
| Organization | Well organized, easy to understand | Good organization, some parts out of place | Unclear organization | Disorganized, impedes understanding |
| Writing style | Clear and easy to read | Awkward or wordy writing, clear planning | Readable but difficult to follow | Difficult to understand |
| Grammar | Few grammatical and typographical errors | Some grammatical and typographical errors, but do not impede understanding | Moderate grammatical errors/typos | Frequent errors impede understanding |
| Formatting | Meets all formatting requirements | Minor deviation from formatting requirements | Exceeds page limit/major deviation from formatting requirements | Formatting requirements completely disregarded |
| Replication code (10 marks) | ||||
| Do-files and log | Well-documented, easy to read | Detailed documentation, somewhat confusing | Unclear documentation | Little to no documentation |


Switch off and relax with mindfulness and meditation
Get inspired and motivated for the day ahead
Here you can Learn & develop so you can reach your goals


Random Forest-like tree ensemble that works with groups of predictor variables. When building a tree, a number of variables is taken randomly from each group separately, thus ensuring that it considers variables from each group for the splits. Useful when rows contain information about different things (e.g. user information and product information) and it's not sensible to make a prediction with information from only one group of variables, or when there are far more variables from one group than the other and it's desired to have groups appear evenly on trees. Trees are grown using the C5.0 algorithm rather than the usual CART algorithm. Supports parallelization (multithreaded), missing values in predictors, and categorical variables (without doing One-Hot encoding in the processing). Can also be used to create a regular (non-stratified) Random Forest-like model, but made up of C5.0 trees and with some additional control options. As it's built with C5.0 trees, it works only for classification (not for regression).
| Version: | 0.2.2 |
| Imports: | C50, dplyr, parallel, stats |
| Published: | 2017-06-30 |
| Author: | David Cortes |
| Maintainer: | David Cortes <david.cortes.rivera at gmail.com> |
| License: | GPL-3 |
| NeedsCompilation: | no |
| In views: | MissingData |
| CRAN checks: | StratifiedRF results |
| Reference manual: | StratifiedRF.pdf |
| Package source: | StratifiedRF_0.2.2.tar.gz |
| Windows binaries: | r-devel: StratifiedRF_0.2.2.zip, r-release: StratifiedRF_0.2.2.zip, r-oldrel: StratifiedRF_0.2.2.zip |
| OS X binaries: | r-release: StratifiedRF_0.2.2.tgz, r-oldrel: StratifiedRF_0.2.2.tgz |
| Old sources: | StratifiedRF archive |
Please use the canonical form https://CRAN.R-project.org/package=StratifiedRF to link to this page.


pnmtopng(1) pnmtopng(1) NAME pnmtopng - convert a portable anymap into a Portable Network Graphics file SYNOPSIS pnmtopng [-verbose] [-downscale] [-interlace] [-alpha file] [-transparent [=]color] [-background color] [-gamma value] [-hist] [-chroma wx wy rx ry gx gy bx by] [-phys x y unit] [-text file] [-ztxt file] [-time [yy]yy-mm-dd hh:mm:ss] [-filter type] [-compression level] [-force] [pnmfile] DESCRIPTION Reads a portable pixmap as input. Produces a Portable Network Graphics file as output. Color values in PNG files are either eight or sixteen bits wide, so pnm‐ topng will automatically scale colors to have a maxval of 255 or 65535. Grayscale files will be produced with bit depths 1, 2, 4, 8 or 16. An extra pnmdepth step is not necessary. OPTIONS -verbose Display the format of the output file. -downscale Enables scaling of maxvalues of more then 65535 to 16 bit. Since this means loss of image data, the step is not performed by default. -interlace Creates an interlaced PNG file (Adam7). -alpha file The alpha channel of pixel (or image) specifies the transparency of a pixel. To create this fourth pixel value a separate .pbm- or .pgm-file is needed. In this file black (0) stands for fully transparant and white (1) will become opaque. The sizes of both pbm/pgm/ppm-files must be the same. If the information contained in the alpha mask can also be represented as a transparency index, it will be used, since this should result in a smaller image file. -transparent color ppmtogif marks the specified color as transparent in the PNG image. You specify the color as in ppmmake(1).E.g. red or rgb:ff/00/0d. If the color you specify is not present in the image, pnmtopnm selects instead the color in the image that is closest to the one you specify. Closeness is measured as a cartesian distance between colors in RGB space. If multiple colors are equidistant, pnmtopnm chooses one of them arbitrarily. However, if you prefix your color specification with "=", e.g. -transparent =red Only the exact color you specify will be transparent. If that color does not appear in the image, there will be no transparency. pnmtopng issues an information message when this is the case. -background color To create a background color chunck in the png-file, which can be used for subsequent alpha-channel or transparent-color conver‐ sions. See -transparent for format of color. -gamma value Creates an gAMA chunk. By providing the gamma-value of the pnm- file the software that lateron will display the png-file will be able to do the necessary gamma-corrections. A good rule-of-thumb is that when the file is created by a software program (like a CAD-program or a ray-tracer) the value is probably 1.0. When the pnm-file looks good on a non-gamma corrected PC display (which has itself a gamma-value of 2.2 - 2.8), a value of 0.45 should be given. -hist Use this parameter to create a chunk that specifies the frequency (or histogram) of the colors in the image. -chroma white point X and Y, red X and Y, green X and Y, and blue X and Y To specify the white point and rgb values following the CIE-1931 spec. -phys x y unit When your image should not be displayed with square but with rec‐ tangular pixels this option should be used to create a pHYS chunk. When the unit-value is 0 the x and y only gives the ratio of pixel width and height. When it is 1 the x and y specify the number of pixels per meter. -text file Allows to include comments in the text-chunk of the png-file. The format of the text-file is as follows: when the first column does not contain a blank or a tab, the first word is considered to be the keyword. For keywords to contain spaces, enclose them in dou‐ ble-quotes. When the first character on a line is a blank or tab, the rest of the line is a new line of the current comment. Note that the ini‐ tial spaces are not considered to be part of the comment line. Here is an example: ------------------------------------------- Title PNG-file Author your name Description how to include a text-chunk into a PNG file "Creation date" 3-feb-1987 Software pnmtopng ------------------------------------------- -ztxt file The same as -text, but now the text will be compressed. -time yy-mm-dd hh:mm:ss or -time yyyy-mm-dd hh:mm:ss This option allows you to specify the (modification)time. The year parameter can be given as a two- or a four-digit value. -filter type When the types of filters must be restricted you can specify here which filter you want to use. Allowed values are: 0 (none), 1 (sub), 2 (up), 3 (avg) and 4 (paeth). -compression level To explicitly set the compression level of zlib use this parame‐ ter. Select a level between 0 for no compression (max speed) and 9 for maximum compression. -force When set, -force limits the optimizations of pnmtopng. A png-file similar to the pnm-input is as much as possible enforced. For example no paletted files will be created and alpha-channel images will not be converted to images with a transparency chunck. All flags can be abbreviated to their shortest unique prefix. SEE ALSO pngtopnm(1), gif2png(1), pnmgamma(1), pnm(5) NOTE Instead of xxxtopnm|pnmtopng, a specific converter should be used, if available. E.g. gif2png (GIF conversion), etc. BUGS There could be an option to read the comment text from pnm comments instead of a separate file. The program could be much faster, with a bit of code optimizing. AUTHORS Copyright (C) 1995-1997 by Alexander Lehmann and Willem van Schaik. 6 January 1997 pnmtopng(1)


{{app.power}} W
Daily: {{app.price | currency}}
Monthly: {{app.price * 30 | currency}}
Yearly: {{app.price * 365 | currency}}
Enter a percent change of power usage.
A decrease of {{app.delta}}% in energy usage of {{app.name}} will result in {{app.price * (app.delta / 100) | currency}} saved per day, {{app.price * (app.delta / 100) * 30 | currency}} saved per month, and {{app.price * (app.delta / 100) * 365 | currency}} saved per year.


The goal of this project is to develop a Monte Carlo simulation of the spread of an infectious disease. We will use the classical SIRS model of to develop the necessary transition probabilities for the simulation. Interpreting the simulation requires a thorough understanding of the SIRS model, so a deterministic approach is used in conjunction with Monte Carlo methods.
The main purpose of creating such a simulation is to investigate how a disease spreads throughout a given population over time. Then we can make predictions about whether or not a certain disease has the capacity to establish itself within the population, i.e. a fraction of the population remains infected after the system reaches equilibrium.
The SIRS model considers an isolated population of \( N \) people which are divided into three separate groups:
For the simple case, we will assume that the dynamics of the epidemic occur during a time scale much smaller than the average person's lifetime. Hence the effect of the birth and death rate of the population is ignored.
From these assumptions, a set of coupled differential equations can be constructed to form the classical SIRS model: $$ \begin{equation} \begin{split} S'&=cR-\frac{aSI}{N}\\ I'&=\frac{aSI}{N}-bI\\ R'&=bI-cR\\ \end{split} \label{_auto2} \end{equation} $$
Note that for small populations, one may choose to write \( aSI \) instead of \( \frac{aSI}{N} \) since the number of susceptibles which become infected depend more on the absolute number of infected people rather than the infected fraction of the population.
Though this set does not have analytic solutions like the closely-related SIR model, the equilibrium solutions are simple to obtain. The constraint in (1) reduces this three dimensional system into a two dimensional one so that the equation for \( R' \) can just be omitted: $$ \begin{equation} \begin{split} S'&=c(N-S-I)-\frac{aSI}{N}\\ I'&=\frac{aSI}{N}-bI\\ \end{split} \label{_auto3} \end{equation} $$
The steady state is found by setting both equations in (3) equal to zero. Let \( s \), \( i \), and \( r \) denote the fractions of people in \( S \), \( I \), and \( R \), respectively. Then the fractions of people in each group at equilibrium are: $$ \begin{equation} \begin{split} s^* &= \frac{b}{a},\\ i^* &= \frac{1-\frac{b}{a}}{1+\frac{b}{c}},\\ r^* &= \frac{b}{c}\frac{1-\frac{b}{a}}{1+\frac{b}{c}}. \end{split} \label{_auto4} \end{equation} $$
Here, the asterisk (\( ^* \)) signifies that these fractions are at equilibrium. Notice that each fraction must be a number between 0 and 1, and that the three fractions must add up to 1. Thus the equations in (4) suggest that the rate of recovery \( b \) must be less than the rate of transmission \( a \) for the number of infected people at equilibrium to be greater than zero. In other words, the disease establishes itself in the population only if \( b < a \).
For this project you can collaborate with fellow students and you can hand in a common report. This project (together with projects 3 and 4) counts 1/3 of the final mark.
We will create four different populations to investigate the effect of increasing the rate of recovery \( b \) and crossing the "threshold". Each population consists of 400 people, 100 of which were initially infected and 300 of which were initially susceptible. We fix the rate of transmission \( a \) and the rate of immunity loss \( c \) between populations, but let the rate of recovery \( b \) be varied because it is the one parameter which can be reasonably controlled by the actions of human society (access to health care, development of new medicines, etc). Note that the rates have units of inverse time. The table here lists a possible set of parameters for the four different populations.
| Rate | A | B | C | D |
| a | 4 | 4 | 4 | 4 |
| b | 1 | 2 | 3 | 4 |
| c | 0.5 | 0.5 | 0.5 | 0.5 |
The rates of transmission are given by the parameter \( a \), recovery by \( b \), and immunity loss \( c \) for populations \( A \), \( B \), \( C \), and \( D \).
We treat the population as a continuous variable. Develop a Runge-Kutta fourth order code to solve the above equations.
Discuss your results and present your interpreations.
The set of differential equations in (2) inherently assume that \( S \), \( I \), and \( R \) are continuous variables, when they are discrete in reality. We can use the idea of randomness to remedy this issue by defining a set of transition probabilities for the possible moves a person can take from one state to another: \( S\rightarrow I \), \( I \rightarrow R \), and \( R \rightarrow S \). To obtain the specific values for each probability, we first notice from (2) that in a small time step \( \Delta t \), the number of people moving from \( S \) to \( I \) is approximately \( \frac{aSI}{N}\Delta t \). Likewise, about \( bI\Delta t \) move from \( I \) to \( R \) and \( cR\Delta t \) move from \( R \) to \( S \).
Now we let \( \Delta t \) be small enough so that at most one person moves from a given group to another. Since $$ \begin{equation} \begin{split} &\max \Big\{ \frac{aSI}{N}\Delta t \Big\} = \frac{a}{N}\left(\frac{N}{2}\right)^2\Delta t=\frac{aN}{4}\Delta t,\\ &\max \Big\{ bI\Delta t \Big\} = bN\Delta t,\\ &\max \Big\{ cR\Delta t \Big\} = cN\Delta t,\\ \end{split} \label{_auto5} \end{equation} $$ the time step is then given by $$ \begin{equation} \Delta t = \min \Big\{ \frac{4}{aN}, \frac{1}{bN}, \frac{1}{cN} \Big\}. \label{_auto6} \end{equation} $$ This construction allows us to reinterpret the values \( \frac{aSI}{N}\Delta t \), \( bI\Delta t \), and \( cR\Delta t \) as transition probabilties: $$ \begin{equation} \begin{split} P(S\rightarrow I) &= \frac{aSI}{N}\Delta t,\\ P(I \rightarrow R) &= bI\Delta t,\\ P(R \rightarrow S) &= cR\Delta t.\\ \end{split} \label{_auto7} \end{equation} $$ For each possible move, a random number between 0 and 1 is generated. If the number is less than the probability for the move, the move is taken.
Develop now a Monte Carlo algorithm which implements the last equations using the same parameters \( N \), \( a \), \( b \), and \( c \) for each population. Compare your results to those obtained with the deterministic differential equation solver and discuss your findings.
You will need to find the fraction of people when the system has been equilibrated. You will need to find the equlibrium expectation values and corresonding standard deviations.
The same principles used in this simple model can be extended to include more details about the population and disease.
For instance, vital dynamics can be easily added to the system so that the model can describe the spread of diseases which occur over longer stretches of time. If \( e \) is the birth rate, \( d \) is the death rate, and \( d_I \) is the death rate of infected people due to the disease, then the modified differential equations are given by: $$ \begin{equation} \begin{split} S'&=cR-\frac{aSI}{N}-dS+eN\\ I'&=\frac{aSI}{N}-bI-dI-d_I I\\ R'&=bI-cR-dR\\ \end{split} \label{_auto8} \end{equation} $$ Here, we have assumed that all the babies born into the population are initially susceptible.
Add now these additions to your ODE solver and Monte Carlo solver and discuss the results.
For diseases such as influenza, the rate of transmission depends largely on the time of year. During the colder months, individuals are more likely to spend time in closer proximity to one another, resulting in a rate of transmission which oscillates. So we can let \( a \) be given by $$ \begin{equation} a(t)=Acos(\omega t) + a_0, \label{_auto9} \end{equation} $$
where \( a_0 \) is the average transmission rate, \( A \) is the maximum deviation from \( a_0 \), and \( \omega \) is the frequency of oscillation. Study the the effect of seasonal variations as well, with both the ODE and Monte Carlo solver. Try different values of the above new parameters and discuss your results.
Diseases with available vaccinations allow people to move directly from \( S \) to \( R \), breaking the cyclic structure of the SIRS model. We assume that a susceptible individual's choice to become vaccinated does not depend on how many other susceptibles are vaccinated. We may, however, assume that the rate of vaccination \( f \) can depend on the time, since this rate may oscillate during the course of a year and/or increase as awareness and medical research increases. Then the system of differential equations become $$ \begin{equation} \begin{split} S'&=cR-\frac{aSI}{N}-f\\ I'&=\frac{aSI}{N}-bI\\ R'&=bI-cR+f\\ \end{split} \label{_auto10} \end{equation} $$
Add now the effect of vaccination via the parameter \( f \) and discuss again your results. Play around with different values of the parameter \( f \).
Here follows a brief recipe and recommendation on how to write a report for each project.
The preferred format for the report is a PDF file. You can also use DOC or postscript formats or as an ipython notebook file. As programming language we prefer that you choose between C/C++, Fortran2008 or Python. The following prescription should be followed when preparing the report:


The RequestFactory
shares the same API as
the test client. However, instead of behaving like a browser, the
RequestFactory provides a way to generate a request instance that can
be used as the first argument to any view. This means you can test a
view function the same way as you would test any other function – as
a black box, with exactly known inputs, testing for specific outputs.
The API for the RequestFactory
is a slightly
restricted subset of the test client API:
get()
,
post()
, put()
,
delete()
, head()
,
options()
, and trace()
.follow
. Since this is just a factory for producing
requests, it’s up to you to handle the response.The following is a simple unit test using the request factory:
from django.contrib.auth.models import AnonymousUser, User
from django.test import RequestFactory, TestCase
from .views import MyView, my_view
class SimpleTest(TestCase):
def setUp(self):
# Every test needs access to the request factory.
self.factory = RequestFactory()
self.user = User.objects.create_user(
username='jacob', email='jacob@…', password='top_secret')
def test_details(self):
# Create an instance of a GET request.
request = self.factory.get('/customer/details')
# Recall that middleware are not supported. You can simulate a
# logged-in user by setting request.user manually.
request.user = self.user
# Or you can simulate an anonymous user by setting request.user to
# an AnonymousUser instance.
request.user = AnonymousUser()
# Test my_view() as if it were deployed at /customer/details
response = my_view(request)
# Use this syntax for class-based views.
response = MyView.as_view()(request)
self.assertEqual(response.status_code, 200)
The ALLOWED_HOSTS
setting is validated when running tests. This
allows the test client to differentiate between internal and external URLs.
Projects that support multitenancy or otherwise alter business logic based on
the request’s host and use custom host names in tests must include those hosts
in ALLOWED_HOSTS
.
The first and simplest option to do so is to add the hosts to your settings file. For example, the test suite for docs.djangoproject.com includes the following:
from django.test import TestCase
class SearchFormTestCase(TestCase):
def test_empty_get(self):
response = self.client.get('/en/dev/search/', HTTP_HOST='docs.djangoproject.dev:8000')
self.assertEqual(response.status_code, 200)
and the settings file includes a list of the domains supported by the project:
ALLOWED_HOSTS = [
'www.djangoproject.dev',
'docs.djangoproject.dev',
...
]
Another option is to add the required hosts to ALLOWED_HOSTS
using
override_settings()
or
modify_settings()
. This option may be
preferable in standalone apps that can’t package their own settings file or
for projects where the list of domains is not static (e.g., subdomains for
multitenancy). For example, you could write a test for the domain
http://otherserver/
as follows:
from django.test import TestCase, override_settings
class MultiDomainTestCase(TestCase):
@override_settings(ALLOWED_HOSTS=['otherserver'])
def test_other_domain(self):
response = self.client.get('http://otherserver/foo/bar/')
Disabling ALLOWED_HOSTS
checking (ALLOWED_HOSTS = ['*']
) when
running tests prevents the test client from raising a helpful error message if
you follow a redirect to an external URL.
If you’re testing a multiple database configuration with primary/replica (referred to as master/slave by some databases) replication, this strategy of creating test databases poses a problem. When the test databases are created, there won’t be any replication, and as a result, data created on the primary won’t be seen on the replica.
To compensate for this, Django allows you to define that a database is a test mirror. Consider the following (simplified) example database configuration:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'HOST': 'dbprimary',
# ... plus some other settings
},
'replica': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'myproject',
'HOST': 'dbreplica',
'TEST': {
'MIRROR': 'default',
},
# ... plus some other settings
}
}
In this setup, we have two database servers: dbprimary
, described
by the database alias default
, and dbreplica
described by the
alias replica
. As you might expect, dbreplica
has been configured
by the database administrator as a read replica of dbprimary
, so in
normal activity, any write to default
will appear on replica
.
If Django created two independent test databases, this would break any
tests that expected replication to occur. However, the replica
database has been configured as a test mirror (using the
MIRROR
test setting), indicating that under
testing, replica
should be treated as a mirror of default
.
When the test environment is configured, a test version of replica
will not be created. Instead the connection to replica
will be redirected to point at default
. As a result, writes to
default
will appear on replica
– but because they are actually
the same database, not because there is data replication between the
two databases.
By default, Django will assume all databases depend on the default
database and therefore always create the default
database first.
However, no guarantees are made on the creation order of any other
databases in your test setup.
If your database configuration requires a specific creation order, you
can specify the dependencies that exist using the DEPENDENCIES
test setting. Consider the following (simplified)
example database configuration:
DATABASES = {
'default': {
# ... db settings
'TEST': {
'DEPENDENCIES': ['diamonds'],
},
},
'diamonds': {
# ... db settings
'TEST': {
'DEPENDENCIES': [],
},
},
'clubs': {
# ... db settings
'TEST': {
'DEPENDENCIES': ['diamonds'],
},
},
'spades': {
# ... db settings
'TEST': {
'DEPENDENCIES': ['diamonds', 'hearts'],
},
},
'hearts': {
# ... db settings
'TEST': {
'DEPENDENCIES': ['diamonds', 'clubs'],
},
}
}
Under this configuration, the diamonds
database will be created first,
as it is the only database alias without dependencies. The default
and
clubs
alias will be created next (although the order of creation of this
pair is not guaranteed), then hearts
, and finally spades
.
If there are any circular dependencies in the DEPENDENCIES
definition, an
ImproperlyConfigured
exception will be raised.
TransactionTestCase
¶TransactionTestCase.
available_apps
¶Warning
This attribute is a private API. It may be changed or removed without a deprecation period in the future, for instance to accommodate changes in application loading.
It’s used to optimize Django’s own test suite, which contains hundreds of models but no relations between models in different applications.
By default, available_apps
is set to None
. After each test, Django
calls flush
to reset the database state. This empties all tables
and emits the post_migrate
signal, which
recreates one content type and four permissions for each model. This
operation gets expensive proportionally to the number of models.
Setting available_apps
to a list of applications instructs Django to
behave as if only the models from these applications were available. The
behavior of TransactionTestCase
changes as follows:
post_migrate
is fired before each
test to create the content types and permissions for each model in
available apps, in case they’re missing.post_migrate
isn’t fired; it will be
fired by the next TransactionTestCase
, after the correct set of
applications is selected.Since the database isn’t fully flushed, if a test creates instances of
models not included in available_apps
, they will leak and they may
cause unrelated tests to fail. Be careful with tests that use sessions;
the default session engine stores them in the database.
Since post_migrate
isn’t emitted after
flushing the database, its state after a TransactionTestCase
isn’t the
same as after a TestCase
: it’s missing the rows created by listeners
to post_migrate
. Considering the
order in which tests are executed, this isn’t an
issue, provided either all TransactionTestCase
in a given test suite
declare available_apps
, or none of them.
available_apps
is mandatory in Django’s own test suite.
TransactionTestCase.
reset_sequences
¶Setting reset_sequences = True
on a TransactionTestCase
will make
sure sequences are always reset before the test run:
class TestsThatDependsOnPrimaryKeySequences(TransactionTestCase):
reset_sequences = True
def test_animal_pk(self):
lion = Animal.objects.create(name="lion", sound="roar")
# lion.pk is guaranteed to always be 1
self.assertEqual(lion.pk, 1)
Unless you are explicitly testing primary keys sequence numbers, it is recommended that you do not hard code primary key values in tests.
Using reset_sequences = True
will slow down the test, since the primary
key reset is a relatively expensive database operation.
If you are writing a reusable application you may want to use the Django test runner to run your own test suite and thus benefit from the Django testing infrastructure.
A common practice is a tests directory next to the application code, with the following structure:
runtests.py
polls/
__init__.py
models.py
...
tests/
__init__.py
models.py
test_settings.py
tests.py
Let’s take a look inside a couple of those files:
#!/usr/bin/env python
import os
import sys
import django
from django.conf import settings
from django.test.utils import get_runner
if __name__ == "__main__":
os.environ['DJANGO_SETTINGS_MODULE'] = 'tests.test_settings'
django.setup()
TestRunner = get_runner(settings)
test_runner = TestRunner()
failures = test_runner.run_tests(["tests"])
sys.exit(bool(failures))
This is the script that you invoke to run the test suite. It sets up the Django environment, creates the test database and runs the tests.
For the sake of clarity, this example contains only the bare minimum necessary to use the Django test runner. You may want to add command-line options for controlling verbosity, passing in specific test labels to run, etc.
SECRET_KEY = 'fake-key'
INSTALLED_APPS = [
"tests",
]
This file contains the Django settings required to run your app’s tests.
Again, this is a minimal example; your tests may require additional settings to run.
Since the tests package is included in INSTALLED_APPS
when
running your tests, you can define test-only models in its models.py
file.
Clearly, unittest
is not the only Python testing framework. While Django
doesn’t provide explicit support for alternative frameworks, it does provide a
way to invoke tests constructed for an alternative framework as if they were
normal Django tests.
When you run ./manage.py test
, Django looks at the TEST_RUNNER
setting to determine what to do. By default, TEST_RUNNER
points to
'django.test.runner.DiscoverRunner'
. This class defines the default Django
testing behavior. This behavior involves:
test*.py
.migrate
to install models and initial data into the test
databases.If you define your own test runner class and point TEST_RUNNER
at
that class, Django will execute your test runner whenever you run
./manage.py test
. In this way, it is possible to use any test framework
that can be executed from Python code, or to modify the Django test execution
process to satisfy whatever testing requirements you may have.
A test runner is a class defining a run_tests()
method. Django ships
with a DiscoverRunner
class that defines the default Django testing
behavior. This class defines the run_tests()
entry point, plus a
selection of other methods that are used to by run_tests()
to set up,
execute and tear down the test suite.
DiscoverRunner
(pattern='test*.py', top_level=None, verbosity=1, interactive=True, failfast=False, keepdb=False, reverse=False, debug_mode=False, debug_sql=False, **kwargs)[source]¶DiscoverRunner
will search for tests in any file matching pattern
.
top_level
can be used to specify the directory containing your
top-level Python modules. Usually Django can figure this out automatically,
so it’s not necessary to specify this option. If specified, it should
generally be the directory containing your manage.py
file.
verbosity
determines the amount of notification and debug information
that will be printed to the console; 0
is no output, 1
is normal
output, and 2
is verbose output.
If interactive
is True
, the test suite has permission to ask the
user for instructions when the test suite is executed. An example of this
behavior would be asking for permission to delete an existing test
database. If interactive
is False
, the test suite must be able to
run without any manual intervention.
If failfast
is True
, the test suite will stop running after the
first test failure is detected.
If keepdb
is True
, the test suite will use the existing database,
or create one if necessary. If False
, a new database will be created,
prompting the user to remove the existing one, if present.
If reverse
is True
, test cases will be executed in the opposite
order. This could be useful to debug tests that aren’t properly isolated
and have side effects. Grouping by test class is
preserved when using this option.
debug_mode
specifies what the DEBUG
setting should be
set to prior to running tests.
If debug_sql
is True
, failing test cases will output SQL queries
logged to the django.db.backends logger as well
as the traceback. If verbosity
is 2
, then queries in all tests are
output.
Django may, from time to time, extend the capabilities of the test runner
by adding new arguments. The **kwargs
declaration allows for this
expansion. If you subclass DiscoverRunner
or write your own test
runner, ensure it accepts **kwargs
.
Your test runner may also define additional command-line options.
Create or override an add_arguments(cls, parser)
class method and add
custom arguments by calling parser.add_argument()
inside the method, so
that the test
command will be able to use those arguments.
DiscoverRunner.
test_suite
¶The class used to build the test suite. By default it is set to
unittest.TestSuite
. This can be overridden if you wish to implement
different logic for collecting tests.
DiscoverRunner.
test_runner
¶This is the class of the low-level test runner which is used to execute
the individual tests and format the results. By default it is set to
unittest.TextTestRunner
. Despite the unfortunate similarity in
naming conventions, this is not the same type of class as
DiscoverRunner
, which covers a broader set of responsibilities. You
can override this attribute to modify the way tests are run and reported.
DiscoverRunner.
test_loader
¶This is the class that loads tests, whether from TestCases or modules or
otherwise and bundles them into test suites for the runner to execute.
By default it is set to unittest.defaultTestLoader
. You can override
this attribute if your tests are going to be loaded in unusual ways.
DiscoverRunner.
run_tests
(test_labels, extra_tests=None, **kwargs)[source]¶Run the test suite.
test_labels
allows you to specify which tests to run and supports
several formats (see DiscoverRunner.build_suite()
for a list of
supported formats).
extra_tests
is a list of extra TestCase
instances to add to the
suite that is executed by the test runner. These extra tests are run
in addition to those discovered in the modules listed in test_labels
.
This method should return the number of tests that failed.
DiscoverRunner.
add_arguments
(parser)[source]¶Override this class method to add custom arguments accepted by the
test
management command. See
argparse.ArgumentParser.add_argument()
for details about adding
arguments to a parser.
DiscoverRunner.
setup_test_environment
(**kwargs)[source]¶Sets up the test environment by calling
setup_test_environment()
and setting
DEBUG
to self.debug_mode
(defaults to False
).
DiscoverRunner.
build_suite
(test_labels, extra_tests=None, **kwargs)[source]¶Constructs a test suite that matches the test labels provided.
test_labels
is a list of strings describing the tests to be run. A test
label can take one of four forms:
path.to.test_module.TestCase.test_method
– Run a single test method
in a test case.path.to.test_module.TestCase
– Run all the test methods in a test
case.path.to.module
– Search for and run all tests in the named Python
package or module.path/to/directory
– Search for and run all tests below the named
directory.If test_labels
has a value of None
, the test runner will search for
tests in all files below the current directory whose names match its
pattern
(see above).
extra_tests
is a list of extra TestCase
instances to add to the
suite that is executed by the test runner. These extra tests are run
in addition to those discovered in the modules listed in test_labels
.
Returns a TestSuite
instance ready to be run.
DiscoverRunner.
setup_databases
(**kwargs)[source]¶Creates the test databases by calling
setup_databases()
.
DiscoverRunner.
run_checks
()[source]¶Runs the system checks.
DiscoverRunner.
run_suite
(suite, **kwargs)[source]¶Runs the test suite.
Returns the result produced by the running the test suite.
DiscoverRunner.
get_test_runner_kwargs
()[source]¶Returns the keyword arguments to instantiate the
DiscoverRunner.test_runner
with.
DiscoverRunner.
teardown_databases
(old_config, **kwargs)[source]¶Destroys the test databases, restoring pre-test conditions by calling
teardown_databases()
.
django.test.utils
¶To assist in the creation of your own test runner, Django provides a number of
utility methods in the django.test.utils
module.
setup_test_environment
(debug=None)[source]¶Performs global pre-test setup, such as installing instrumentation for the template rendering system and setting up the dummy email outbox.
If debug
isn’t None
, the DEBUG
setting is updated to its
value.
teardown_test_environment
()[source]¶Performs global post-test teardown, such as removing instrumentation from the template system and restoring normal email services.
setup_databases
(verbosity, interactive, keepdb=False, debug_sql=False, parallel=0, aliases=None, **kwargs)[source]¶Creates the test databases.
Returns a data structure that provides enough detail to undo the changes
that have been made. This data will be provided to the
teardown_databases()
function at the conclusion of testing.
The aliases
argument determines which DATABASES
aliases test
databases should be setup for. If it’s not provided, it defaults to all of
DATABASES
aliases.
The aliases
argument was added.
teardown_databases
(old_config, parallel=0, keepdb=False)[source]¶Destroys the test databases, restoring pre-test conditions.
old_config
is a data structure defining the changes in the database
configuration that need to be reversed. It’s the return value of the
setup_databases()
method.
django.db.connection.creation
¶The creation module of the database backend also provides some utilities that can be useful during testing.
create_test_db
(verbosity=1, autoclobber=False, serialize=True, keepdb=False)¶Creates a new test database and runs migrate
against it.
verbosity
has the same behavior as in run_tests()
.
autoclobber
describes the behavior that will occur if a
database with the same name as the test database is discovered:
autoclobber
is False
, the user will be asked to
approve destroying the existing database. sys.exit
is
called if the user does not approve.True
, the database will be destroyed
without consulting the user.serialize
determines if Django serializes the database into an
in-memory JSON string before running tests (used to restore the database
state between tests if you don’t have transactions). You can set this to
False
to speed up creation time if you don’t have any test classes
with serialized_rollback=True.
If you are using the default test runner, you can control this with the
the SERIALIZE
entry in the TEST
dictionary.
keepdb
determines if the test run should use an existing
database, or create a new one. If True
, the existing
database will be used, or created if not present. If False
,
a new database will be created, prompting the user to remove
the existing one, if present.
Returns the name of the test database that it created.
create_test_db()
has the side effect of modifying the value of
NAME
in DATABASES
to match the name of the test
database.
destroy_test_db
(old_database_name, verbosity=1, keepdb=False)¶Destroys the database whose name is the value of NAME
in
DATABASES
, and sets NAME
to the value of
old_database_name
.
The verbosity
argument has the same behavior as for
DiscoverRunner
.
If the keepdb
argument is True
, then the connection to the
database will be closed, but the database will not be destroyed.
coverage.py
¶Code coverage describes how much source code has been tested. It shows which parts of your code are being exercised by tests and which are not. It’s an important part of testing applications, so it’s strongly recommended to check the coverage of your tests.
Django can be easily integrated with coverage.py, a tool for measuring code
coverage of Python programs. First, install coverage.py. Next, run the
following from your project folder containing manage.py
:
coverage run --source='.' manage.py test myapp
This runs your tests and collects coverage data of the executed files in your project. You can see a report of this data by typing following command:
coverage report
Note that some Django code was executed while running tests, but it is not
listed here because of the source
flag passed to the previous command.
For more options like annotated HTML listings detailing missed lines, see the coverage.py docs.
Oct 01, 2019


Quick post. Super useful. Only works if you have an NYU login.
This is a “bookmarklet”. Drag it into your bookmarks bar on your browser. You can rename it. It’ll still work.
Click it when you it a paywall (e.g., on HeinOnline or an Elsevier journal or whatever), it will remove the paywall if NYU libraries has access.
 If NYU libraries doesn’t have access, it will bring you to an error page.


layout: true name: blank styling: styling.css styling-by: Martin Weitzel .stylehint[ Styled with [{{styling}}]({{styling}}) by {{styling-by}} ] --- layout: true name: plain copyright: (CC) BY-SA branding: [Dipl.-Ing. Martin Weitzel](https://tbfe.de) 2019-05-22 (11:15 - 12:45) customer: [ELEKTRONIK PRAXIS & PLC2](http://www.fpga-kongress.de/de) .eta[ETA: {{eta}}] {{header}} .pagefooter[ {{copyright}}: {{branding}} .fpga-logo[{{customer}}] ] --- layout: true name: linkinfo copyright: (CC) BY-SA branding: [Dipl.-Ing. Martin Weitzel](https://tbfe.de) 2019-05-22 (11:15 - 12:45) customer: [ELEKTRONIK PRAXIS & PLC2](http://www.fpga-kongress.de/de) .eta[{{eta}}] {{header}} .infographic[ [![Info-Grafik](InfoGraphics/{{graphic}}.png)](InfoGraphics/{{graphic}}.png "Click to open – add [CTRL+] SHIFT for new [tabbed] window") ] .pagefooter[ {{copyright}}: {{branding}} .fpga-logo[{{customer}} ] ] --- layout: true name: linkinfoA3 copyright: (CC) BY-SA branding: [Dipl.-Ing. Martin Weitzel](https://tbfe.de) 2019-05-22 (11:15 - 12:45) customer: [ELEKTRONIK PRAXIS & PLC2](http://www.fpga-kongress.de/de) .eta[{{eta}}] {{header}} .infographicA3[ [![Info-Grafik](InfoGraphics/{{graphic}}.png)](InfoGraphics/{{graphic}}.png "Click to open – add [CTRL+] SHIFT for new [tabbed] window") ] .pagefooter[ {{copyright}}: {{branding}} .fpga-logo[{{customer}} ] ] --- layout: false template: blank name: frontmatter .title[ Down To Earth C++ For Embedded ] .subtitle[ How to benefit from C++ without "Doing everything completely different, beginning tomorrow". ] .author.pull-left[ Durchführung Dipl.-Ing. Martin Weitzel Technische Beratung für EDV https://tbfe.de ] .client.pull-right[ FPGA-Kongress 2019, München 2019-05-21 to 2019-05-23 ELEKTRONIK PRAXIS & PLC2 Schulungscenter ] .F[: You may use the code examples from this presentation in compliance with the [Creative Commons BY-SA License](http://creativecommons.org/licenses/by-sa/2.0/). As it has been created using the free HTML4-Tool [Remark](http://remarkjs.com), its content is written using the [Markdown-Syntax](http://daringfireball.net/projects/markdown/syntax), so you may even enhance the purely electronic (non-printed) form with your own annotations, only by means of any ordinary text editor. Just hit the P-key while viewing this in an Internet browser and follow instructions. ] ??? (use +/- above to adjust the font size for convenient reading) Remark allows to add presenter notes to each page. As that feature is **not** used by the author of that presentation, it is available for private annotations from [this page](#content) on. Assuming you have downloaded and stored this presentation as HTML-file, proceed as follows: * Open the file in a text editor of your choice. * Locate the page which you want to annotate. * You may do so by just scrolling down (but often it is easier to) * use the text search feature of your editor. * Locate the separator to the next page (i.e. `---` in a line of its own). * Before that add another line with three question marks (`???`) only. Between these to separator lines you can put your annotations and view these by using as you just view this page. **Hint:** Indent code examples with four spaces at the beginning of each line and they will be displayed with their original line breaks. As an example, below the page structure including annotations is shown: template: plain name: used_for_internal_links header: ## Shown at the Top of the Page Simply scroll down through this document loaded in an editor and you will probably catch the basics of Markdown-Syntax easily, e.g. how to put in *slight* or **strong** emphasis or [add a link](http://tbfe.de/downloads). ??? From here follow the [Presenter Notes], i.e. your private annotations ... ... [Presenter Notes]: adding-longer-links-that-keeps-text--uncluttered ... up to here. --- To return to the normal view, now press the P-key once more. --- template: plain class: agenda name: content header: # Agenda eta: 11:20 ------------------------------------------------------------------------------- * [Three Short Case Studies – Overview ](#case_studies_overview) * [Strong Arithmetic Types – Possible in C++? ](#strong_arithmetic_types) * [Templates – From the Many To the Few ](#two_faces_of_templates) * [Compile-Time Computing – A Facet of Modern C++ ](#compile_time_computing) ------------------------------------------------------------------------------- If you have questions during the talk, feel free to interrupt any time. .I[ You can download download the code covered in advance from here: https://github.com/tbfe-de/FPGA-Kongress_2019 ] --- template: plain name: case_studies_overview header: ## Three Short Case Studies eta: 11:21 There are people telling you: .N.center[ If you start with C++, you need to do everything different. Otherwise you'll never exploit the advantages of OOP.._[] ] .F[: Note that C++ is much more than "just another OOP-Language". Especially its template feature – which at the advanced edge leads to Metaprogramming – is [Metaprogramming]: https://en.wikipedia.org/wiki/Generic_programming relatively unique among other language, which at first, cursory glance may look similar. ] -- .center.large[ !! NOT HERE !! ] -- If you can compile your code with C++ (can you?) -- * you can very well profit from "small things" … -- * … slowly grow into a language with so many advantages over C … -- * … that you soon will fight tooth and nails to keep using it. --- template: plain header: ### WHAT we will do here eta: 11:22 This presentation * walks you through three little example -- * meant to show how C++ would improve your C code -- * without going "full OOP and -- * without having to learn a lot._[] .F[: Well, I lied: how much you have to learn depends on how much you want to optimize the resulting code – optimize *beyond* what C allows you to do. ] --- template: plain header: ### HOW we will do it eta: 11:23 The following Code Walks are * are partially based on prepared material * which is then in live-demos modified for improvements._[] .F[: From some feedback of the trainings I teach I know this can help to slow down the presentation: typing in code may seem like a waste of time but actually it allows the participants understand the big picture before going into the specifics (compared to throwing 20 lines of code or so onto the screen, you yourself know very well, and immediately start talking about the code in line 11, 12 and 17 to highlight a particular technique that code is meant to communicate). ] -- .N.center[ So you have a chance to step in and control progress AND direction. ] -- .center.large[ !! USE THAT CHANCE !! ] --- template: plain name: strong_arithmetic_types header: ## Strong Arithmetic Types eta: 11:25 .pull-left[ Doesn't this fragment look nice? ``` typedef float Current; // mA typedef float Voltage; // V typedef float Power; // W … Current get_I(); Current get_U(); void show_VA(Power); … const Voltage minVcc = 4.85, maxVcc = 5.2; … Current c = get_I(); Voltage v = get_U(); … show_VA(v * c/1e3); ``` ] .pull-right[ What may be the intent? * Allow to change the data type at a central place – e.g. from `float` to `double`? * Protect against easy errors? ``` if (get_I() < minVcc) … ``` * Maybe even with units checking? ``` show_VA(get_U() % get_I()); ``` ] --- template: plain header: ### First Live Demo Starts eta: 11:28 .center.large[ SO LET'S SEE ] .N.center[ `step0.cpp` – motivating type safety … ] -- * `typedef`-types are just aliases – *not strong types* -- * same for type definitions in the new C++ `using` syntax -- .center.large[ OK, so it was a bad idee. ] --- template: plain header: #### Trying a Different Approach eta: 11:31 .N.center[ `step1.cpp` – a very first PoC (proof of concept) ] * `struct`-s._[] are real types … .F[: And of course `class`-es are, because in C++ the only difference between `struct` and `class` is that the former by default starts with `public` and the latter starts with `private`. ] -- .N.center[ `step2.cpp` – minimally fleshing it out ] * Looks like type-checking works as expected :-) -- * But how avoid developing the habit to "throw in" just enough `.get()`-s to silence compiler error messages? -- .center.large[ C++ allows it! ] --- template: plain header: #### Looks Promising So Far eta: 11:33 .N.center[ `step3.cpp` – blowing up the strong type PoC. ] * Actually it is possible to write your code like this … ``` int main() { Voltage u1 = 5.0_V; Current i1 = 20_mA; Power p1 = u1 * i1; std::cout << p1.get_mW() << " mW" << std::endl; } ``` -- * … at least when a due amount of evidence is invested.._[] .F[: In this example a lot of code is commented out. The reason is to suggest you shouldn't actually write code that goes untested … and therefore **only the minimum to make the code compile** is implemented. The comments are meant to show what should probably added if these strong types are made available in a library. ] --- template: plain header: #### Reducing Focus For a Moment eta: 11:36 .N.center[ `step4.cpp` – A "more fully blown" example for `Voltage` class ] * Obviously there is a lot of code required … -- * … but it's rather systematic. -- .center.large[ So how make it more DRY?._[] ] .F[: DRY is an acronym often used to refer to the *Don't Repeat Yourself" principle which means you should strive for avoiding large parts of duplicate code. ] -- Two solutions come to mind: * Re-structure and shift common parts into a template or base class. * Generate systematic code from a simplified description. --- template: plain header: #### Getting Serious About It eta: 11:41 .N.center[ `step5.cpp` – a templated base class.._[] ] .F[: An alternative approach using the C-preprocessor as code generator is beyond the scope of this short talk. It could also be here to reduce the systematic code sequences. ] Before looking at the details understand that most developers * need no delve into the details of the implementation details * but just can profit from the strong types like that: .pull-left[ ``` … 158: int main() { 159: Voltage v = 20_mA; 160: } ``` ] .pull-right[ ``` step5.cpp:159:14: error: conversion from ´Current´ to non-scalar type ´Voltage´ requested ``` ] --- template: plain header: #### Where To Go from here? eta: 11:44 .I[ Full code see **`Example1`** in https://github.com/tbfe-de/FPGA-Kongress_2019 ] .center.large[ Just whetted your appetite? ] * Don't underestimate the effort required to extend it to all the physical units your program requires! -- * Maybe [Boost.Units] makes sense for you.._[] [Boost.Units]: https://www.boost.org/doc/libs/release/doc/html/boost_units.html .F[: Copied from its description: *The Boost.Units library is a C++ implementation of dimensional analysis in a general and extensible manner, treating it as a generic compile-time metaprogramming problem. With appropriate compiler optimization, no runtime execution cost is introduced, facilitating the use of this library to provide dimension checking in performance-critical code. Support for units and quantities (defined as a unit and associated value) for arbitrary unit system models and arbitrary value types is provided, as is a fine-grained general facility for unit conversions. Complete SI and CGS unit systems are provided, along with systems for angles measured in degrees, radians, gradians, and revolutions and systems for temperatures measured in Kelvin, degrees Celsius and degrees Fahrenheit. The library architecture has been designed with flexibility and extensibility in mind; demonstrations of the ease of adding new units and unit conversions are provided in the examples.* ] --- template: plain name: two_faces_of_templates header: ## The Two Faces of Templates eta: 11:45 Assume we have just completed a nice piece of code, implementing a little event queue …._[] ``` class EventQueue { static const std::size_t QueueSize = 10+1; Event data[QueueSize]; size_t iput = 0, iget = 0; static std::size_t wrap(std::size_t idx) { return idx % QueueSize; } public: bool empty() const; bool full() const; std::size_t size() const; void put(Event); void get(Event&); Event peek(std::size_t = 0) const; }; ``` .F[: Payload `Event` not further detailed (maybe assume an enumeration type). ] --- template: plain header: ### Second Live Demo Starts eta: 11:47 .center.large[ Where to go from here? ] -- Outline of demo – maybe varied or extended on request: * Explain the code, especially "full" and "empty" conditions. * Explain its current limitations. -- .N.center[ `step1.cpp` – generalize into a `RingBuffer` template. ] -- Parametrize * payload via a template `typename` argument and * maximum queue size via a template `std::size_t` argument. --- template: plain header: #### Intermezzo: Now That Was the Easy Part eta: 11:50 Let's see what we've got so and how it changes the usage: ``` template
class RingBuffer { Payload data[Size+1]; std::size_t iput = 0, iget = 0; static std::size_t wrap(std::size_t idx) { return idx % (Size+1); } public: bool empty() const; bool full() const; std::size_t size() const; void put(const PayLoad&); void get(PayLoad&); PayLoad peek(std::size_t = 0) const; }; ``` -- .pull-left[ Usage once was: ``` EventQueue q; ``` ] .pull-right[ And now it is: ``` RingBuffer
q: ``` ] --- template: plain header: #### Summarizing So Far eta: 11:54 [Generic Programming]: https://en.wikipedia.org/wiki/Generic_programming .center.large[ Wasn't that easy-peasy? ] -- For most everybody usage is nearly as easy as before!._[] .N.center[ That's the tiny little bit what **many** developers need to know when C++ templates are utilized for what is also called [Generic Programming]. ] .F[: And you can get it even closer with this type alias: ``` using EventQueue = RingBuffer
; ``` ] -- And turning a type and a compile-time constant into template arguments wasn't that difficult either, or was it? .N.center[ That's the additional knowledge to be acquired. But only **few** developers need to have it. ] -- So why is it C++ templates have the reputation to be hard to master? --- template: plain header: #### Second Live Demo Continues eta: 11:58 [Metaprogramming]: https://en.wikipedia.org/wiki/Generic_programming C++ templates **may** become a bit or even much more complicated * once you want or need to optimize based on type properties, * what is also called [Metaprogramming]. -- .N.center[ But that again is knowledge **only some few** need to have! ] (Well … except maybe for the ability to interpret error messages.._[]) .F[: Yes! It was a bit of a white lie to get you started. Actually deciphering error messages from bad use of templates may need special skills at times. But then there comes C++20 with its promise a new feature called [Constraints] will improve the current situation substantially. ] -- .N.center[ `step2.cpp` – a closer look to argument handling ] If time allows and there is sufficient interest it may be discussed * why the argument to `put` was turned into `const Payload&` and * how this could be optimized using with [Metaprogramming]. [Metaprogramming]: https://en.wikipedia.org/wiki/Generic_programming --- template: plain header: #### Optional Further Extensions eta: 12:03 Discuss generalizing handling of the "full" and "empty" case:._[] .F[: For an even more advance extension consider how "thread-safe" variants of the `RingBuffer` could be provided via derived classes or "policy"-style template argument. ] -- * ignore situation * overwriting elements on `put` * returning default on `get` -- * ignore situation, returning * `false` on `put` when `full` (otherwise `true`) * `false` on `get` when `empty` (otherwise `true`) -- * throw exception * on calling `put` when `full` * on calling `get` when `empty` -- .I[ Full code see **`Example2`** in https://github.com/tbfe-de/FPGA-Kongress_2019 ] --- template: plain name: compile_time_computing header: ## Computing at Compile Time eta: 12:10 C++11 has added `constexpr` to indicate * a data initialization is to be done at compile time, meaning * an expression used as initial value needs no run-time code; * a function is to be made available also._[] at compile-time, meaning * there are certain restrictions on what it is allowed to do. .F[: A run-time version of a `constexpr` function is made available too when there are arguments that themselves are not `constexpr` data; of course such a function can then *not* be used to initialize `constexpr` data. ] -- .N.center[ Beyond that semantics are straight forward and exactly like expected. ] -- You may * call `constexpr` functions in expression initializing `constexpr` data; * use `constexpr` data as argument for `constexpr` function calls. --- template: plain name: compile_time_computing header: ### A Close To Trivial Example eta: 12:11 Here is an example (requiring C++14._[] at least): ``` constexpr int countBits(std::uint16_t v) { int bits = 0; for (; v; v >>= 1) bits += (v & 0x1); return bits; } ``` To verify the function call takes place at compile-time you may … .pull-left[ … either use that function to initialize `constexpr` data … ``` constexpr int n = bitCount(42); ``` ] .pull-right[ … or in any other context which requires a compile-time constant: ``` char s[bitCount(42)]; ``` ] .F[: A C++11 version would have to look like this as such a function is limited to a `return` statement only: ``` constexpr int countBits(std::uint16_t v) { return v ? ((v & 0x1) + countBits(v >> 1) : 0; } ``` ] --- template: plain name: compile_time_computing header: ### Picking Up From There eta: 12:13 .N.center.large[ Now that's … just boring! ] -- So lets go for something more involved: * At some point a program needs to call the sine function. -- * It is determined such function calls are a performance bottle-neck. -- * The arguments come only from a limited range (radians or degrees). -- * There is no ultimate precision necessary, instead -- * a pre-calculated table with a fixed set of values should be used, -- * and intermediate values determined by linear interpolation. -- .N.center.large[ Sounds ambitious enough? ] --- template: plain header: ### Third Live Demo Starts eta: 12:14 Outline of demo – maybe varied or extended on request: * Starting with a proof of concept * Evaluating performance and … * … deviation from accurate value.._[] .F[: In case you are only reading this you may be interested in the result. It looks like this: ``` step0.cpp **************** TESTCASE 1 **************** 0 to 90 degree lookup-table with 19 entries -------------------------------------------- quicksine: 42137 usec for 1000000 calls = 0.042137 usec per call std::sin : 134871 usec for 1000000 calls = 0.134871 usec per call deviation: 2000 random data points 425 = exact results (21.25%) 0 = within 0.01 percent (0%) 0 = within 0.02 percent (0%) 20 = within 0.05 percent (1%) 1515 = within 0.1 percent (75.75%) 40 = within 0.25 percent (2%) 0 = within 0.5 percent (0%) 0 = within 1 percent (0%) 0 = within 2 percent (0%) 0 = worse results (0%) ``` ] --- template: plain header: #### Everything Cool So Far? eta: 12:16 * Then fasten your seat belts and … * … let's push the pedal to the metal!._[] -- .N.center[ `step1.cpp` – pull things belonging together in `class QuickSine`. ] Modifications are systematic, some decisions to be made include: * Where to put common helper functions? * Continue to support white-box testing? .N.center[ `step2.cpp` – finally achieved to make the constructor `constexpr` ] Here `std::array` introduced in `step0.cpp` (because of its index-checking feature) had to be replaced with a native array. * This is because prior to C++17 neither `std::array::operator[]` nor `std::operator::at` are `constexpr`. --- template: plain header: #### The Problems Of an Autodidact eta: 12:19 .N.center[ Surely, since the beginning of our *Internet Times* much has changed. ] -- E.g. how much do * we still need to know in adavance compared * to what can we just look up when needed? -- The problem comes when something doesn't work and compiler error messages aren't particularly hepful (which is not that rare in C++). -- Sometimes it is very hard to decide: * Is it I', still on the right track and just missing a small point? * Or should I back-out substantuially and try a different approach? .center.large[ This has often hit me too!._[] ] .F[: And it is just one reason why you should allow some time to try out ideas with what I call "proof of concept" approaches, like the one shown in this short series. ] --- template: plain header: #### Lessons Learned (Personally) eta: 12:25 Here is a list of the major stumble stones that hit me during this little "Proof of Concept" series. -- * C++11 does not require any of the `cmath`-functions to be `constexpr` -- * Actually it **IS** the case for `g++` but **not** for `clang++`.._[] .F[: If your compile time computations require library functions that aren't `constexpr` you need to find an open source implementation (in this case of the trig-function) which only builds on basic math, like e.g. approximating the sine from the [Taylor Series]. While I'm at it: Wikipedia has a nice article about computing square roots exploiting some specific properties of the IEEE floating point format: https://en.wikipedia.org/wiki/Fast_inverse_square_root ] [Taylor Series]: https://en.wikipedia.org/wiki/Taylor_series -- * Neither `array::operator[]` nor `array::at` are `constexpr` in C++14. -- * This made it necessary to switch back to a native array. -- * For some reason you need to add an initializer for the look-up table. -- * Despite the actuall initialization follows later in a loop. --- template: plain header: #### And the Winner is …? eta: 12:29 .N.center[ `step3.cpp` – going for the victory lap. ] More cleanup to make the class a candidate for production use.._[] * Still it is a single file solution … * … but comments already indicate what is intended to go where. .F[: So far it has been nothing but refactoring as the behavior is still the same: ``` step3.cpp **************** TESTCASE 1 **************** 0 to 90 degree lookup-table with 19 entries -------------------------------------------- quicksine: 53284.1 usec for 1000000 calls = 0.0532841 usec per call std::sin : 134429 usec for 1000000 calls = 0.134429 usec per call deviation: 2000 random data points 425 = exact results (21.25%) 0 = within 0.01 percent (0%) 0 = within 0.02 percent (0%) 20 = within 0.05 percent (1%) 1515 = within 0.1 percent (75.75%) 40 = within 0.25 percent (2%) 0 = within 0.5 percent (0%) 0 = within 1 percent (0%) 0 = within 2 percent (0%) 0 = worse results (0%) ``` ] --- template: plain header: #### Summarizing Again eta: 12:32 Again think of: -- .N.center.large[ From the Many To the Few! ] -- The "many" are those who now use `quicksine` just like this:._[] ``` QuickSine
quicksine; … auto x = quicksine(123); ``` .F[: Or maybe with a type alias: ``` using MyQuickSine = QuickSine
; ``` ] -- The "few" are those having written the code just walked through. -- .I[ Full code see **`Example3`** in https://github.com/tbfe-de/FPGA-Kongress_2019 ] --- template: plain name: closing_note header: ## Closing Note eta: 12:35 Feel free to contact me via<EMAIL_ADDRESS>if you have any questions on -- * *C++*._[] – no matter whether you are interested in using it * as *"Better C"* only (= Zero-Overhead C++), * as *"Classic C++"* (= C++98 Style), or * as *"Modern C++"* (= C++11/14/17/20) .F[: Did you know: You can also mix C++ with Tcl Scripting, e.g. to improve time-critical parts of some software initially implemented in Tcl, which makes a nice and easy way of *"Rapid Prototyping"* … ] -- * the *Tcl Programming Language* and/or its *Standard Library* -- * including Tk, the *Tcl Extension for GUI-Programming* -- .N.center[ ***Thank You for Attending to (or Reading) this Presentation.*** ]


{{Infobox prepared food | name = Prežganka | image = | caption = | alternate_name = | country = Slovenia | region = Upper Carniola | creator = | course = | type = Soup | served = | main_ingredient = Flour, caraway seeds, eggs | variations = | calories = | other = }}
Prežganka ("browned" soup with eggs) is Slovenian national soup made of flour, caraway seeds and beaten eggs.<ref>Traditional slovenian cookery. Adamlje Slavko, 1997. Mladinska knjiga. ISBN<PHONE_NUMBER></ref> The brown color comes from browning the flour in oil or butter. Instead of the flour, breadcrumbs can be used.
Prežganka is a traditional dish from Upper Carniola region.
{{Reflist}}
{{DEFAULTSORT:Prezganka}}
{{soup-stub}}


Connecting R to an enterprise data warehouse? Do it properly and do not hard-code your passwords! Here is how you can do it in R with rMarkdown and RStudio version 1.0+
Working as a data scientist in a large organisation, chances are you will have to get data out of an Enterprise Data Warehouse (EDW) and into your Data Manipulation Environment (DME, usually R, Python, Julia, or SAS). Of course, you could create a manual extract, save it as .csv and read it from disk. However, this approach has a number of downsides: - the manual workflow may be hard to reproduce later on - files use up additional disk space - csv files do not store data types
Generally, I prefer to connect my DME directly to the database, as do many other Data Scientists. What I have repeatedly come across in this context is people hard-coding their passwords and access tokens into their analysis code. In my opinion, this is a dangerous practice! It is most likely in violation of the security regulations of your organisation, and for good reason. It is far too easy for your code to accidentally end up on an unrestricted access github repository, an unprotected S3 bucket, or similar. With GDPR just around the corner, a mistake like that could soon cost your organisation up to 3% of their global annual revenue in fines!
So what’s the “proper” way to do this? Well, RStudio (v1.0+) offers some great new features in this context. If you are using Windows (like many big corporations do) and you are connecting to your EDW using the Windows ODBC Data Source Administrator, you can read your connection details directly from there using the “odbc” package.
Note: each code block below should be a chunk in an rMarkdown ```R # Unfortunately, odbc is not on CRAN yet. # So if you do not have it yet we will need devtools install.packages(devtools)
devtools::install_github(‘rstats-db/odbc’)
# Using the name you set manually con <- dbConnect(odbc::odbc(), ‘EDW_name’) ```
Using this connection object, we can now write and run SQL code snippets in rMarkdowns, rNotebooks, and shiny apps. Just pass the connection as property to the snippet and specify an “output.var” that will capture the output. This “output.var” will be available in your R workspace afterwards.
sql
-- This should be a chunk with the following header:
-- {SQL, connection = con, output.var = result}
-- As a result, this turns into sql code.
-- comments need to be marked accordingly
SELECT TOP 10 * FROM EDW_database.EDW_table
r
# result will be available in the next chunk!
result
This code has syntax highlighting, runs start to finish without any manual steps, does not rely on “hacky” string queries, does not have hard-coded passwords, and your data updates as and when new data becomes available in your EDW!
As always, hope this is useful for someone. Please leave a comment below!


AnythingZoomer
DownloadBasics
This is a jQuery plugin, so you'll need to load the jQuery library first, then the plugin file, then invoke the new function on the area you wish to have zooming. There is a specific HTML structure and some required CSS to have all this work correctly, so read on. The full list of parameters is also below.

The HTML
The only required HTML is the wrapper and the small area. The large area is required if you don't clone the small area.

<-- the large content can be cloned from the small content -->

There are five parts to the actual zoomable area. The idea is to allow for a good amount of flexibility in customizing each part, including having the "small" area have different content than the "large" zooming area.
- The Wrap (#zoom) - goes around everything.
- Small Area (.small) - the default viewable area, that you mouse over to zoom.
- Large (.large) - the content that is viewable through the zoomer.
- Zoom (.az-zoom) - the zooming box that follows the mouse around.
You are not locked into these ID's though, you can override then when calling the plugin.

The CSS
The widths, heights, borders and things like that can be altered to your needs. The positioning, z-index, overflow, and top/left values should stay as it is here to function properly.
Text Demo CSS Example
#zoom { width: 500px; }
.small img { width: 225px; height: 150px; }
.large img { width: 500px; height: 333px; background: white; }
anythingzoomer.css
/* Overall */
.az-wrap, .az-small, .az-large {
position: relative;
}
.az-wrap-inner {
display: block;
}
/* This wraps the large image and hides it */
.az-zoom {
background: #fff;
border: #333 1px solid;
position: absolute;
top: 0;
left: 0;
width: 100px; /* Default zoom window size */
height: 100px;
overflow: hidden;
z-index: 100;
display: none;
}
/* Class applied to az-mover when large image is windowed */
.az-windowed {
overflow: hidden;
position: absolute;
}
/* Class applied to az-mover when large image is fully shown */
.az-expanded {
height: auto;
width: auto;
position: static;
overflow: visible;
};
All Params
$("#zoom").anythingZoomer({
smallArea : 'small', // class of small content area; the element with this class name must be inside of the wrapper
largeArea : 'large', // class of large content area; this class must exist inside of the wrapper. When the clone option is true, it will add this automatically
clone : false, // Make a clone of the small content area, use css to modify the style
switchEvent : 'dblclick', // event that allows toggling between small and large elements - default is double click
edge : 30 // How far outside the wrapped edges the mouse can go; previously called "expansionSize"
});
Methods
You can open the zoom window using an external link using these methods. This would be useful to highlight portions of the content in say instructions on how to use an app or name the presidents in the image demo.
// TARGET X,Y COORDINATE
// $('.zoom').anythingZoomer( x, y, [ w, h ] );
// x, y = left and top coords to target (will be centered in the zoom window)
// w, h = width and height of the zoom window, if not defined, it will default to the css definition
// Example: $('.zoom').anythingZoomer( 82, 50, [200,200] );
// 82, 50 will target George Washington; [200,200] will make the zoom window 200px x 200px in size
$('.zoom').anythingZoomer( 82, 50, [200,200] );
// TARGET AN OBJECT
// $('.zoom').anythingZoomer( 'selector', [ xOffset, yOffset ], [zoomW, zoomH] );
// 'selector' - jQuery selector targeting the element
// [xOffset, yOffset] - by default the zoom window will center itself on the element, if you want to move the window, change the offset values (negative values are okay)
// [zoomW, zoomH] - width and height of the zoom window
// Example: $('.zoom').anythingZoomer( '.day[rel=2009-08-26]', [0, 0], [200, 200] );
// '.day[rel=2009-08-26]' targets the table cell with day class name and rel attribute of "2009-08-26"
// [ 0, 0 ] has no x or y offset; this can be replaced with '' (empty string); or if only one number is included, like [-1] this sets the xOffset only
// [200,200] will make the zoom window 200px x 200px in size
$('.zoom').anythingZoomer( '.day[rel=2009-08-26]', [0, 0], [200, 200] );
Image Demo Example
George Washington,
Thomas Jefferson,
Theodore Roosevelt or
Abraham Lincoln
$('.president')
// prevent the link from doing anything
.bind('click', function(){
return false;
})
// click or mouseover the link to show the zoom window
.bind('mouseover click', function(){
// get coordinates from rel attribute
var loc = $(this).attr('rel');
if (loc && loc.indexOf(',') > 0) {
loc = loc.split(',');
// send the coordinates to anythingZoomer
$('.zoom').anythingZoomer( loc[0], loc[1] );
}
return false;
});