Dr Administrator

Author's posts

Eulogy for Andrew Hopkinson

My dad, Andrew Hopkinson, died in Bournemouth Hospital at about 11:45am on Thursday 17th December 2020. He was born 11th August 1939.

Dad grew up in Yorkshire with his brothers David, Barry and John. He attended Bradford Grammar School, we still have his school reports and his passion for maths was obvious even then.

David remembers:

Andy and I were avid readers from quite a young age with similar tastes.  To avoid friction we had a rule that whoever brought a book home had absolute right to it, and could demand it to be handed over even when the other was engrossed in it.  This agreement  worked very well though we did have occasional problems to persuade our father to abide by it.

Barry remembers:

Most of my memories of my brother Andy go back to our teenage years when we were particularly close.


We were in the scouts together at Baildon (6th Shipley Baildon Methodists Group) where we would meet weekly. We were a very active troop, one of our contemporaries being Ian Clough, who went on to be the first British climber (together with Chris Bonnington) to make the ascent of the North Wall of the Eiger. We did not aspire to such great things but we did go on together to gain the “Queen’s Scout Award” which was no mean achievement. I think we were the only ones to do so from Baildon in our era. We enjoyed annual scout camps together in Nidderdale and Borrowdale in the Lake District.


In the summer of 1958 we spent about 5 weeks together cycling around Europe. Our expedition took us down to Dover to make the channel crossing to Boulogne then across northern France to Strasbourg, through the Black Forest of western Germany and onward to Munich and Innsbruck before heading back through Austria, Switzerland and France. We were pulled in by the police near Innsbruck for not dismounting on the descent of a steep hill. I had done a bit of German at school and pleaded ignorance, repeatedly saying “Ich verstehe nicht, ich bin ein Englander”. The police simply shrugged their shoulders and muttered “Englanders, hah hah hah”. Just as I thought I was getting somewhere Andy says “Oh, Ich verstehe” and got us landed with an on the spot fine. We didn’t have any of the electronic gismos available today that provide a myriad of statistics and I don’t even have a record of the actual mileage covered, but I would guess at getting on for 3,000 miles (a few years ago I cycled to Rome to raise funds for the local hospice and covered 1,535 miles (I didn’t return home by bike on that occasion). We did all this with full camping gear and cooked all our own meals of course.


One Easter in the very early sixties Andy went to the Isle of Arran with me and two friends from the Bradford Pothole Club. While there we made the traverse of the whole of the Arran ridge plus Goat Fell in a day. From the summit of Goat Fell two of us dashed down to Brodick to get some beer while Andy and our other friend cooked the evening meal. It was a Sunday and although we managed to convince the barman we were bona fide travellers we were not permitted any “carry outs” so we downed a quick couple of pints before returning to our camp in Glen Rosa to break the sad news to the others.


Andy also joined us on at least one of our Bradford Pothole Club camps in the Lake District but I never managed to get him underground in any of the many caves in our beloved Yorkshire Dales.


Then Andy went to work and live in Dorset!

“Cheerio Andy, we had some happy times together before our paths parted all those years ago”

He went up to Jesus College, Cambridge where he gained a 1st in Mathematics. He was cox of the Jesus College boat in the River Cam Bumps races. Here he felt he was with like-minded people, and he kept in touch with the College throughout his life, and would always tell stories of his time there.

He moved to Dorset to work at the UK Atomic Energy Authority site at Winfrith. A job he kept for his whole working life. He wrote computer code to simulate nuclear reactors; this is where he met my mum, Sylvia.

From a former colleague:

I was sorry to hear about Andrew – I’ve probably mentioned in the past that his work on drum dynamics – AEEW M 1123 – ‘A New Model for the Dynamics of Steam Drums’, is quoted in connection with water/steam separation in ‘Simulation and Control of Electrical Power Stations’, J. B. Knowles , John Wiley – a collection of papers produced from UKAEA and CEGB.

I can’t recall ever meeting him but I do remember borrowing his copy of Pippard on thermodynamics for many years.

In the early days Andy was an enthusiastic rock climber as well as a keen walker, Eric C. remembers:

As you probably know, I shared a flat with Andy at Sutton Poyntz near Weymouth for about 4-5 years, and it was an agreeable time. Andy was a gentleman with a fine temperament, and I think we enjoyed each other’s company. I’m enclosing a photo of Andy when we were camped in Easter 1963 in the Lake District at Wasdale. We were all trying to traverse round Wasdale before going back for dinner! I’m also enclosing a composite picture of Andy, Anth, Sheila and Tony George together with other members and friends of Wessex [Mountaineering Club] members in the Christmas 1962 camp at Wasdale – proof that in those days – 58 years ago we were still capable of climbing moderate sized mountains!

My younger brother, Paul, and I were born in the early seventies. We lived in Wool on Colliers Lane until we successively left for university. Dad was a stickler for safety, and would often tell the story of how, when we were returning home from the hospital after my birth, he had strapped my cot into the backseat of the car – the nurse had said it was customary for the mother to hold the baby in her arms! And so throughout our childhood Paul and I wore seatbelts in the back of the car, long before it was a legal requirement. This saved our lives exactly once.

Dad was a quiet, methodical DIYer. His most memorable project was a large stone fireplace/sideboard which he made from carefully labelled Portland stone, taking great care to hide wires for the stereo and TV that sat upon it – he despised visible wires.

It was not until I was quite old that I discovered that not all people keep a little book in the glove box of their car where they record every time they buy petrol, how much it cost and the car mileage at that point. Dad was always a methodical record keeper.

At Christmas I like to remember him for the time he heated a spoon to warm up brandy to set the Christmas pudding on fire, and tested the temperature of the spoon on his trousers, only to discover that polyester melts!

Dad did a lot of cycling and camping as a child; he kept cycling through most of his life but only as a way of getting around. Our holidays revolved around camping and walking, often in the New Forest, Scotland or Devon but also in great tours around Europe – a bigger organisational challenge in the days before the internet. Our final holiday with dad as a family was a road trip around the West Coast of the United States, starting in Calgary and going all the way down to the Grand Canyon and then back up through San Francisco and along the Pacific Coast crossing back through the Rockies. He told us glacial meltwater was a milky blue and too cold to swim in.

Dad kept an allotment on and off through much of his life, a passion he had inherited from his father. He was still worrying about harvesting and storing the apples from the trees in the garden shortly before he moved into the care home.

Trains were a constant through his life, I can remember his subscription to Modern Railways magazine arriving every month, and when he came to visit us in Chester from Christchurch the engineering works he saw on the way were often the first topic of conversation. He was happy to sit down and just read the national railway timetable. He had hoped to live to travel on the first leg of HS2, and see his first great-grandchild – I’m not sure what the priority was there!

Dad met Susan, my stepmother, on a night walk with the Ramblers Association, she was impressed by his ability to cook a full breakfast on a Primus stove after walking through the night. With Susan, my stepbrothers Kevin and Dominic joined the family.

Following his retirement, Susan and dad went on many walking trips, both around the United Kingdom and further afield in Italy, France, Tenerife and New Zealand. For their four month trip to Australia and New Zealand, my brother Paul was shocked to discover that all they took with them was a small rucksack each – the sort of size most of us would use as a day bag. After staying in bothies in New Zealand they looked to do similar in the Highlands.

Dad and Susan also attended many concerts together, joined the University of the Third Age which they enjoyed almost to the ends of their lives. Dad never lost his enthusiasm for learning new things. They were frequent users of the local library.

Dad was delighted when Sharon and I got married, after many years of “living in sin”. He was an enthusiastic grandparent when our son Thomas, now 8, was born. As he was for his other grandchildren, Chloe and Zach, Jamie and Alex.

From Margaret K., one of his friends at the Ramblers:

Andy was one of the first people I chatted with when I joined the Ramblers in early 2003 and from then on talking with him was always interesting.  I learnt a great deal more from him than he did from me.  He and Susan were enthusiastic users of public libraries and he found intriguing books to read on a wide variety of subjects.  I found that reading some of his recommendations led me to all sorts of interesting information.   His love of navigation and the countryside, especially the New Forest, made him a much appreciated leader of Ramblers’ walks and he was one of the leaders I observed in learning to lead walks myself.  

He was an efficient secretary of the East Dorset Group of the Ramblers for a couple of long stints up to 2003 and soon after that became a careful chairman of the group for a few years, at that time helping to develop the group’s involvement in the Purbeck Plod, a 25 mile challenge walk.  He volunteered at White Mill, which is on the River Stour near Blandford and at the visitor centre at Hengistbury Head.  

Susan was still walking when I joined the Ramblers but her health problems made her pull out as time went on.  My husband Bernie and I exchanged some dinner dates with the two of them, the last one in autumn 2019 when Susan was already very ill but she and Andy pulled out all the stops to get her out to the pub where we met.  

In the last few years dad and Susan had both been seriously ill but they looked after each other. Following Susan’s death at the end of 2019, dad spent his final year in the Sunrise of Southbourne care home. He had a propensity to hoard things (plastic bags) and liked to save a few pennies – over 10,000 tooth picks were cleared from the house when he moved into the care home.

Initially rather ill, his health improved through the first few months, and he started taking extended trips out. Then the coronavirus came and he was confined to the home, but took full opportunity of the social opportunities it presented.

From Lana W. at Sunrise Care Home:

Thank you for putting your trust in us and for letting us look after Andy over the past year. He was a true gentleman who will always hold a special place in all of our hearts. I am going to miss his stories and seeing him complete his laps around the garden. He is already greatly missed by all especially the residents in mind gym.

My brother, Paul, was able to visit him on the Saturday before he died, he was a little down having been unwell for a couple of months but brightened up showing Paul around the pictures at the home. Kevin was able to visit him briefly in hospital on the morning he died.

Choosing music for dad’s funeral was hard, he was not really a musical person. From my childhood I remember The Hippopotamus Song by Flanders and Swann, Littles Boxes by Pete Seeger, Morningtown Ride by The Seekers, and The Elements by Tom Lehrer (actually a lot of Tom Lehrer, mostly entirely inappropriate for a funeral!). We thought of two solid funeral favourites, The Enigma Variations by Elgar – dad was interested in early computing and cryptography, visiting Bletchley Park where the German Enigma code was cracked. And Dvorak’s New World Symphony (better known as the Hovis advert music). It seems appropriate for dad to use music featuring a Yorkshireman providing a voice-over for a boy pushing a bicycle up a hill in Dorset, cycling, hills, Dorset and Yorkshire all being things he loved. We finished with Coronation Scot by Vivian Ellis – Coronation Scot was a famous locomotive inaugurated in the 1930s and the music has a steam-train theme to it.

We collected some photos of dad, they are here.

There is a lot of dad in me.

Rest in peace.

Book review: Black and British: A Forgotten History by David Olusoga

black_and_britishSince October was Black History Month I thought Black and British: A Forgotten History by David Olusoga would make a very appropriate read. Although, to be honest, I bought it before I realised and in all likelihood by the time you read this Black History Month will have finished.

The first thing that struck me about this book was the Preface where Olusoga writes about his motivation for writing the book. As a British-Nigerian this is visceral, the talk by Enoch Powell of “sending back” non-white citizens of Britain meant he feared he would be separated from his family as a boy. When the National Front were hounding people out of their homes, it was he who was being hounded out. This is absolutely in no way a criticism of Olusoga, or a reason to ignore the contents of this book. It is to contrast with my own detached, academic position as a white British reader.

Following an introduction which gives an outline of the contents of the whole book, the chapters proceed in chronological order with some themes relating to the same time covered in separate chapters. I’ve listed these out at the end of this review as a reminder to myself as much as anything.

There have been black people in Britain for thousands of years, the very first were identified during the Roman occupation. The ancient Romans and Greeks knew of Africa and sub-Saharan Africa, and the nature of the Roman Empire was that its subjects were mobile to a degree. After the fall of the Roman Empire, access to Africa was via the Arab/Muslim empire across North Africa with little contact with Europe. As a consequence European knowledge of African was limited to myths. The story picks up again in the 15th century with the Portuguese exploring the West African coast, they also started the slave trade in black Africans. The British took the first tentative steps in the “triangular slave trade” in the 16th century. The triangle trade saw the movement of manufactured goods from Britain to Africa, slaves from Africa to American and raw materials, sugar, tobacco, and cotton back to Britain.

At this time the West African states were powerful, and experienced in trade with the Portuguese and before them the Arabs. European explorers and merchants suffered large loses to disease – a situation which persisted into the 19th century. Black Africans were found as translators, and sailors, even courtiers in Britain. In Lisbon they made up as much as 20% of the population in the 16th century. They were the subject of curiosity, apparently little specific malice due to their colour, but lived under the Christian view that whiteness represented purity, and blackness the opposite.

British involvement in the slave trade picked up as it acquired colonies in the West Indies and US, the production of sugar and tobacco was lucrative if you had a good supply of cheap (slave) labour. It is at this point that black African slaves are dehumanised, the 1661 Barbados Slave Code puts this in writing. Plantation owners in the West Indies cannot see black Africans as human, they are too numerous and too economically valuable to be seen as such. The Royal African Company is formed as an exclusive vehicle for the slave trade in Britain, and is to take up to 75% of the slave trade in the late 17th century and early 18th century.

In Britain the situation is a bit different, there are a growing number of black people, often brought as the property of wealthy slavers, traders and plantation owners. But their legal status in Britain is hazy, and kept deliberately so for much of the 18th century. In the second half of the 18th century Granville Sharp started a campaign to release slaves in Britain, and later to campaign against slavery itself.  There was a degree of romanticism in the view that British air was too pure for a slave to breathe, so that none were slaves whilst at the same time profiting massively from slavery. From this start the Abolitionist movement grew, first ending British involvement in the slave trade (with Wilberforces 1807 bill), ending slavery in the West Indies in 1838 and then going on to try to end slavery globally.

This was seen as a moral crusade by the British, although there was a lively circuit of African-American speakers promoting the cause in Britain. Olusoga points out that the British have always been much more willing to talk about Abolition than slavery. In this context black Africans are still not seen as equal people, at least by some Abolitionists, but rather they wish to end slavery in the same way as they wish to see the end of cruelty to animals and children.

Freetown in Sierra Leone became an important location in the story, former slaves played a part fighting on the side of the British in the American Revolution, and their payment was freedom. Britain was squeamish about giving them their freedom in Britain. Some went to Nova Scotia, but there was also a plan to establish Freetown in Sierra Leone. The first attempt at this failed abysmally but eventually a colony was established there and the traces of that early history still remain in the modern city.

The British public appeared fairly well disposed towards black people in the first half of the 19th century but in the second half of the century there was a rise in Social Darwinism and scientific racism. Black people were increasingly spoken off as being mentally inferior, often child-like. These ideas grew from Darwin’s theory of evolution but they were motivated by a desire for conquest. In the final 30 years of the 19th century the white European powers colonised 90% of Africa in the “Scramble for Africa”. A theme that was to recur through the 20th century was an aversion to inter-racial relationships, specifically children fathered by black men with white women.

Britain’s attitude to black men for the two world wars was ambivalent, in both cases they were desperate for soldiers but, particularly in the First World War, very keen that black men should not fight white men – worrying this would give them unhelpful ideas when they returned to their homes in the minority white run colonies. In the Second World War the key feature was the huge influx of African American GIs to Britain, and the greatest issue was the treatment of Africa American GIs by their white colleagues (it was atrocious). British civilians were appalled by this. However in the aftermath of both wars there were racially motivated attacks on black men by organised white mobs. The motivation for this, at least in part, was that demobilised white men felt that black men had jobs that were rightfully theirs and economic times were hard. The official response to this was unhelpful to say the least, largely treating the black men as the transgressors. This treatment echoes down the years, and was part of the mis-trust of the police that fuelled the riots of the early eighties and, if we are honest, is still current today.

The book finishes with the post-war period, looking at the passengers on the Empire Windrush and the rise of Enoch Powell. The cry started by Powell in the seventies was to “send them back”, and picked up by the National Front. Powell was a culmination of a tacit program by governments of both stripes to justify the exclusion of black immigrants which had been ongoing since the Second World War. It was during the sixties that the public started to think the same way in larger numbers.

For West Indians and Africans from a number of modern states, Britain is the “home country”, in the same way as it is for white Canadians, New Zealanders and Australians. The difference is that immigrants from these countries are broadly officially welcomed and have been since the end of the British Empire. Black people have not been given that welcome.

Black and British is quite a long read, it packs a lot in but it is well-structured and readable. For me, as a white British middle class man, Olusoga presents from quite a different viewpoint. This is sometimes uncomfortable but I think necessarily so. It helps make more sense of the recent Black Lives Matter movement, but also the racism of the 1970s and the riots of the early eighties, in Britain, with smaller recurrences more recently.

Chapter Themes

  1. Sons of Ham – black people in Roman Britain and onwards, the start of the British slave trade in the 16th century;
  2. Blackamoors – black people in Tudor Britain, the development of the slave trade through to the end of the 18th century to service the tobacco and sugar plantations in the West Indies and America;
  3. For Blacks or Dogs – black people in Georgian Britain, the overspill of the slave trade;
  4. Too Pure an Air for Slaves – Granville Sharp and the start of the Abolitionist movement in the late 18th Century;
  5. Province of Freedom – Africa Americans and the American Revolution, leading to the foundation of Freetown in Sierra Leone;
  6. The Monster is Dead – the path to Abolition with the trade banned in 1806 and slavery  in the West Indies banned in 1838;
  7. Moral Mission – British mission to end slavery around the world in the Victorian period, with black speakers touring Britain. Minstrelism;
  8. Liberated Africans – the West Africa Squadron, aiming to abolish slavery by military means, the conquest of Lagos;
  9. Cotton is King – the US civil war and its impact on the cotton mills of northern England;
  10. Mercy in a Massacre – the rise of Social Darwinism and scientific racism in the second half of the 19th century;
  11. Darkest Africa – the 30 year Scrabble for Africa, when the Europeans colonised all but Ethiopia and Liberia. The rise of human zoos;
  12. We are a Coloured Empire – World War I and the black British Empire;
  13. We Prefer their Company – World War II and African American GIs;
  14. Swamped – immigration to post-war Britain;

Unit testing in Python using the unittest module

The aim of this blog post is to capture some simple “recipes” on testing code in Python that I can return to in the future. I thought it would also be worth sharing some of my thinking around testing more widely. The code in this GitHub gist illustrates the testing features I mention below.

#!/usr/bin/env python
# encoding: utf-8
"""
Some exercising of Python test functionality based on:
https://docs.python.org/3/library/doctest.html
https://docs.python.org/3/library/unittest.html
Generating tests dynamically with unittest
https://eli.thegreenplace.net/2014/04/02/dynamically-generating-python-test-cases
Supressing log output to console:
https://stackoverflow.com/questions/2266646/how-to-disable-and-re-enable-console-logging-in-python
The tests in this file are run using:
./tests.py -v
Ian Hopkinson 2020-11-18
"""
import unittest
import logging
def factorial(n):
"""Return the factorial of n, an exact integer >= 0.
>>> [factorial(n) for n in range(6)]
[1, 1, 2, 6, 24, 120]
>>> factorial(30)
265252859812191058636308480000000
>>> factorial(-1)
Traceback (most recent call last):
ValueError: n must be >= 0
Factorials of floats are OK, but the float must be an exact integer:
>>> factorial(30.1)
Traceback (most recent call last):
ValueError: n must be exact integer
>>> factorial(30.0)
265252859812191058636308480000000
It must also not be ridiculously large:
>>> factorial(1e100)
Traceback (most recent call last):
OverflowError: n too large
"""
import math
if not n >= 0:
raise ValueError("n must be >= 0")
if math.floor(n) != n:
raise ValueError("n must be exact integer")
if n+1 == n: # catch a value like 1e300
raise OverflowError("n too large")
result = 1
factor = 2
while factor <= n:
result *= factor
factor += 1
return result
class TestFactorial(unittest.TestCase):
test_cases = [(0, 1, "zero"),
(1, 1, "one"),
(2, 2, "two"),
(3, 5, "three"), # should be 6
(4, 24, "four"), # should be 24
(5, 120, "five")]
def test_that_factorial_30(self):
self.assertEqual(factorial(30), 265252859812191058636308480000000)
def test_that_factorial_argument_is_positive(self):
with self.assertRaises(ValueError):
factorial(-1)
def test_that_a_list_of_factorials_is_calculated_correctly(self):
# nosetests does not run subTests correctly:
# It does not report which case fails, and stops on failure
for test_case in self.test_cases:
with self.subTest(msg=test_case[2]):
print("Running test {}".format(test_case[2]), flush=True)
logging.info("Running test {}".format(test_case[2]))
self.assertEqual(factorial(test_case[0]), test_case[1], "Failure on {}".format(test_case[2]))
@unittest.skip("demonstrating skipping")
def test_nothing(self):
self.fail("shouldn't happen")
if __name__ == '__main__':
# Doctests will run if they are invoked before unittest but not vice versa
# nosetest will only invoke the unittests by default
import doctest
doctest.testmod()
# If you want your generated tests to be separate named tests then do this
# This is from https://eli.thegreenplace.net/2014/04/02/dynamically-generating-python-test-cases
def make_test_function(description, a, b):
def test(self):
self.assertEqual(factorial(a), b, description)
return test
testsmap = {
'test_one_factorial': [1, 1],
'test_two_factorial': [2, 3],
'test_three_factorial': [3, 6]}
for name, params in testsmap.items():
test_func = make_test_function(name, params[0], params[1])
setattr(TestFactorial, 'test_{0}'.format(name), test_func)
# This supresses logging output to console, like the –nologcapture flag in nosetests
logging.getLogger().addHandler(logging.NullHandler())
logging.getLogger().propagate = False
# Finally we run the tests
unittest.main(buffer=True) # supresses print output, like –nocapture in nosetests or you can use -b
view raw tests.py hosted with ❤ by GitHub

My journey with more formal code testing started about 10 years ago when I was programming in Matlab. It only really picked up a couple of years later when I moved to work at a software startup, coding in Python. I’ve read a couple of books on testing (BDD in action by John Ferguson Smart, Test-Driven Development with Python by Harry J.W. Percival) as well as Working effectively with legacy code by Michael C. Feathers which talks quite a lot about testing. I wrote a blog post a number of years ago about testing in Python when I had just embarked on the testing journey.

As it stands I now use unit testing fairly regularly although the test coverage in my code is not great.

Python has two built-in mechanisms for carrying out tests, the doctest and the unittest modules. Doctests are added as comments to the top of function definitions (see lines 27-51 in the gist above). They are run either by adding calling doctest.testmod() in a script, or adding doctest to a Python commandline as shown below.

python -m doctest -v tests.py

Personally I’ve never used doctest – I don’t like the way the tests are scattered around the code rather than being in one place, and the “replicating the REPL” seems a fragile process but I include them here for completeness.

That leaves us with the unittest module. In Python it is not unusual use a 3rd party testing library which runs on top of unittest, popular choices include nosetests and, more recently, pytest. These typically offer syntactic sugar in terms of making tests slightly easier to code, and read. There is also additional functionality in writing and running test suites. Unittest is based on the Java testing framework, Junit, as such it inherits an object-oriented approach that demands tests are methods of a class derived from unittest.TestCase. This is not particularly Pythonic, hence the popularity of 3rd party libraries.

I’ve used nosetest for a while, now but it looks like its use is no longer recommended since it is no longer being developed. Pytest is the new favoured 3rd party library. Personally, I’m probably going to revert to writing tests using unittest. As a result of writing this blog post I will probably stop using nosetests as a test runner and simply use pure unittest.

The core of unittest is to call the function under test with a set of parameters, and check that the function returns the correct response. This is done using one of the assert* methods of the unittest.TestCase class. I nearly always end up using assertEquals. This is shown in minimal form in lines 67-76 above.

With data science work we often have a list of quite similar tests to run, calling the same function with a list of arguments and checking off the response against the expected value. Writing a function for each test case is a bit laborious, unittest has a couple of features to help with this:

  • subTest puts all the test cases into a single test function, and executes them all, reporting only those that fail (see lines 82-90). This is a compact approach but not verbose. Note that nosetests does not run subTest correctly, it being a a feature of unittest only introduced in Python 3.4 (2014);
  • alternatively we can use a functional programming trip to programmatically generate test functions and add them to the unittest.TestCase class we have derived, this is shown on lines 105-116;

Sometimes you write tests that you don’t always want to run either because they are slow to run, or because you used them in addressing a particular problem and now want to keep for the purposes of documentation but not to run. Decorators in unittest are used to skip tests, @unittest.skip() is the simplest of these, this is an “opt-out”.

Once you’ve written your tests then you need to run them. I liked using nosetests for this, if you ran it in a directory then it would trundle off and find any files that looked like they contained tests and run them, reporting back on the results of the tests.

Unittest has some test discovery functionality which I haven’t yet explored, the simplest way of invoking it is simply by running the script file using:

python tests.py -v

The -v flag indicates that output should be “verbose”, the name of each test is shown with a pass/fail status, and debug output if a test fails. By default unittest shows print messages from the test functions and the code being tested on the console, and also logging messages which can confuse test output. These can be supressed by running tests with the -b flag at the commandline or setting the buffer argument to True in the call to unittest.main(). Logging messages can be supressed by adding a NullHandler, as shown in the gist above on lines 188-119.

The only functionality I’ve used in nosetests and can’t do using pure unittest is re-running only those tests that failed. This limitation could be worked around using the -k commandline flag and using a naming convention to track those test still failing.

Not covered in this blog post are the setUp and tearDown methods which can be run before and after each test method.  

I hope you found this blog post useful, I found writing it helpful in clarifying my thoughts and I now have a single point of reference in future.

Book review: The clock and the camshaft by John Farrell

camshaftThe clock and the camshaft by John Farrell is the story of technology through the Middle Ages which went on to support the Renaissance and the Scientific Revolution.

The book is structured by invention, and although some of the inventions are technologies as we would generally understand them there are also chapters on universities and monasteries, and languages. Each chapter looks at the ancient antecedents of a technology, where there is one, before looking at its place in the Middle Ages and how it played on to the Renaissance that followed. The antecedents are typically in the Roman Empire, China and the Middle East. The overall structure of the book is reminiscent of the technology “trees” one finds in a certain sort of computer game (Civilisation/Age of Empires).

There was a huge drop in population after the end of the Roman Empire in Europe in the 5th century CE until the 9th or 10th century. People no longer lived in towns or cities, and the art of building with stone appears to have been lost across much of Europe.

Food is a core concern at anytime and there were a couple of technological developments during the Middle Ages which helped here. The plough, used in the Mediterranean, was developed to better suit heavy Northern European soils. Horses were adopted to pull ploughs through the development of horse shoes and suitable harnesses.

In the Middle East water wheels were used in irrigation, from several centuries BCE. In Northern Europe irrigation was not quite such a concern but water wheels for power, in the first instance for milling wheat were important. This is not a simple technological development, for most individuals working the land it is convenient to hand mill wheat for your own consumption – a water powered mill is not worth the effort in maintenance or in initial capital outlay. This is where feudalism and monasteries get involved, feudal barons and monasteries can build and maintain a mill economically and they have subjects whose grain can be milled, for a price. Feudal masters obliged their subjects to use their mills, and pay a tariff to do so and under threat of punishment if they were found to be milling their own grain.

Once you have something that goes round and round, driven by a water or wind mill, then the next step is something that goes forwards and backwards. Or, more prosaically, converting rotation motion to linear motion. This might be to power a saw, or more often, to hammer things. Hammering things is important in the production of cloth (fulling), paper (pulping), and metal (crushing ore).Who would have thought hammering things was so important?

Paper is another key technology, the earliest writing is found in clay which was then superseded by papyrus – produced almost exclusively in Egypt. For rough notes codexes were used – parallel thin pieces of wood tied together. In Europe, after the fall of the Roman Empire, parchment made from the skins of goats or calves was used but this required a lot of dead animals. Meanwhile in China paper made from rags was being developed. This innovation was developed in Europe too, this arrival was key for new businesses. Now tradespeople could write things down relatively freely, critical for banking, and important in other businesses.

The challenge with clocks is to allow an power source to release its energy at a steady rate, this is done using an “escapement” mechanism. The first mechanical clocks were recorded in Europe towards the end of the 13th century.

Having forgotten how to build with stone at the end of the Roman Empire the cathedrals of the Middle Ages, built mostly in the 12th and 13th centuries were a sign that the skill of building with stone had been rediscovered. They were an evolution of Roman designs for grand buildings which allowed for much greater light through the insertion of windows. They followed the stone built castles of the Norman period around 1000 CE. Cathedrals are a rather more complex building than a castle but castles provided a good training ground.

Religion provided the impetuous for collecting manuscripts from the Arab world, during the 12th and 13th centuries with a view to improving their astronomic determinations of the date of Easter. Along the way they collected other manuscripts, returning to Spain and Italy to translate them.

Eye lenses were introduced in the first half of the 12th century, and appeared to evolve from glass used to display relics. There were antecedents of lenses found in ancient Egypt even back to the Bronze Age. The Venetians were early specialists in glass making, founding a guild in 1320. There was also expertise north of the Alps in Nurembourg but the quality of ground lenses dropped from 1500 with the first telescope makers towards the end of the century making their own lenses rather than buying them.

Monasteries, and monks, played an important role in carry knowledge across the Middle Ages after the fall of the Roman Empire. They were also important players in the material world, taking the part of a sort of feudal lord in some instances. Universities were in some senses a spin off from the collision between the Church and the Secular state, they arose originally as a place to study law – a topic which came to the fore in disputes between the Church and secular states over which had legal authority. Universities and monasteries are both examples of legal entities which were not people, an important innovation in law.

The book finishes with a chapter on lodestones which lead to the development of compasses for navigation, astrolabes and boats. Astrolabes were designed for astronomical measurement but also served as timekeepers, their design fed into the layout of the clock face. Boats were another technology which evolved as it moved north, the key innovation was switching to a skeleton-based design where the keel and ribs were laid down first, and then planks attached to them.

I liked this little book, much of what I’ve read in the history of science covers a later period – from the 17th century onward – The Clock and the Camshaft provides useful background, and is also very readable.

Book review: A house through time by David Olusoga & Melanie Backe-Hansen

olusogaI’ve recently enjoyed watching A house through time, a series presented by David Olusoga tracking the history of a single house and its inhabitants across the years. The most recent series looked at house in Bristol, the city where I was an undergraduate. A house through time by David Olusoga and Melanie Backe-Hansen is the book of the series.

Rather than focus on a single house, as the TV series does, the book is a much broader sweep which looks at the history of the domestic dwelling back to Roman times, research methods and some social history which gives the “why” behind the houses.

This is a busman’s holiday for me, a large chunk of my job over the last few years has been to build a property database to help answer buildings insurance application questions. One of these questions is the property age, and it has been the cause of greatest pain for me. A house is a good background to this type of work, it provides the type of context which can be really helpful in understanding the data I come across. The issue for me though is that A house is written for those wishing to understand their own homes, rather than work out property age for 25 million or so dwellings but this is a niche interest and shouldn’t be taken as a criticism.

The book starts with a chapter on methods: how do you find out about your house? This is supported by an extensive set of links and a bibliography which strikes the happy medium between not providing any references, and referencing alternate words. The Census, and various surveys conducted before and during World War II are core to this, although these are ostensibly about people they provide evidence that an address existed at a point in time give or take variability in addresses and levels of details in addresses. Numbering of houses, as opposed to names, only started to rise in the middle of the 18th century. Also relevant are Ordnance Survey’s historical maps.

I was a bit surprised that there was very little mention of the listed building data, English Heritage and its partner organisations in Wales and Scotland aim to list all building built in the Georgian period and before. The data provides descriptions of the listed structures, this is the entry for 10 Guinea Street, Bristol which featured in one of the TV programmes.

There then follows a set of chapters on different periods, working forward in time covering the pre-Georgian, Georgian, Victorian, Interwar and post-war periods. These are the divisions I use in my work with the insurance industry (with the addition of a modern period starting in 1980).

There are a number of themes threaded through the book, much of the technological development of home building was relatively early. After the Roman’s left Britons reverted to living in wattle-and-daub or timber buildings for 400 years. The next significant technological developments were the discovery, and widening use of the chimney in the late 14th century followed by the re-discovery of brick making in the later 15th century. After that the next clear developments in building were in prefabricated and high-rise buildings post-Second World War.

A second theme is the legislative framework in which buildings wear built, these are two-fold there are “public safety” acts which are used to try to ensure safer buildings are built, these include the laws put in place after the Great Fire and those used to address the unsanitary conditions in Victorian slums in the later 19th century. These acts often specified a limited number of “model” properties and wonder whether these can be used for dating. There were also acts relating to taxation: window and brick taxes. It is the brick taxes that led to the standardisation of bricks, originally bricks were taxed by number so people made larger bricks so as to reduce their tax bills!

It is perhaps inevitable that the Victorian period running from 1837 to 1901 takes a large chunk of the book. This was a time during which there was a great move to the cities in support of the industrial revolution and a degree of “push” with the Inclosures Acts, Slum dwelling grew common, sanitation and urban clearances were initiated to relieve the slum conditions and the suburbs grew – supported first by omnibuses and then by railways. Although overcrowding and insanitary conditions were recognised early in the Victorian period addressing them took some time, with major improvements in the sewerage system happening towards the end of the 19th century. Often “improvement” schemes were more about sweeping aside the poor with no regard as to where they might live.

Towards the end of the Victorian period the suburbs started to grow, enabled by omnibus and then rail transport. It is at this time that semi-detached properties started to become common. The early suburbs gave me the impression of more rural aspects than modern suburbs. Some of the homes built in the late 19th century are very similar to those built in great numbers between the wars. It was only after the First World War that state intervention in building homes became widespread, the green shoots of this movement started in the late 19th century.

Sadly there is little scope for me to apply these methods to my own homes, I have nearly always lived in late sixties or seventies homes oddly they have had house numbers clustered around 30. In Bristol, as a student I lived in a basement flat close to the developments by Benjamin Stickland built around 1850.

I found A house really readable, it would be a great starting point if you were looking into the history of your own house or were just interested to understand how the domestic built environment came into being in the United Kingdom.