jreades / fsds Goto Github PK
View Code? Open in Web Editor NEWThis project forked from kingsgeocomp/geocomputation
Introduction to Programming module for CASA MSc programmes.
Home Page: https://www.ucl.ac.uk/bartlett/casa/programmes
This project forked from kingsgeocomp/geocomputation
Introduction to Programming module for CASA MSc programmes.
Home Page: https://www.ucl.ac.uk/bartlett/casa/programmes
There might be an encoding error (not sure). When I copy the codes on lectures/3.2-LOLs.md
lines 130-134:
my_cities = [
['London', 51.5072, 0.1275, +0],
['New York', 40.7127, 74.0059, -5],
['Tokyo', 35.6833, 139.6833, +8]
]
It raised error:
['London', 51.5072, 0.1275, +0],
^
SyntaxError: invalid character in identifier
The same error raised on:
lectures/3.4-Functions.md
lines 63 lines 71-75
Using notepad++ to open these .md
file will see the difference.
i2p/lectures/9.1-Data_Space.md
The formula for 1D distance is slightly incorrect, as it could result in negative values. Therefore absolute values should be used.
Instead of
$$ d(i,j) = (i_{1}-j_{1}) $$
we should use
$$ d(i,j) = |i_{1}-j_{1}| $$
Not sure whether the difference between a global or local variable was covered in lectures or not? Either way, some students seemed confused in the implementation of the function with the naming conventions of city in both the functional definition and then calling later on when the tried to modify it. Potential solution:
def avg_tmp(city, temp):
print(f"The average temperature in {city} is {temp}")
temp_city="Belfast"
avg_tmp(temp_city, temperatures[cities.index(city)])
Alongside this, while avg_tmp
is clear in this scenario, may be worth making explicit with avg_temperature
or average_temperature
so that students are as clear as possible in naming their functions. Have seen some terrible function names before and this will just make it clear to students to clearly name their functions as to what they are doing.
In the notebook for practical 10 where we assign a particular Borough to work with, the variable LA = 'Waltham Forest'
is declared twice in sections 1.5.1 and 2.3. The latter needs to be dropped, since while changing the scope in the former declaration to a different borough is recommended, the latter impacts the title of the matplotlib plot which causes incorrect titles.
lectures/Practical-03-Foundations_2.ipynb
TOC Task 3.1. Reading a Remote File
I ran the following code and got an error URLError: <urlopen error [Errno 11004] getaddrinfo failed>
from urllib.request import urlopen
# Given the info you were given above, what do you
# think the value of 'url' should be? What
# type of variable is it? int or string?
url = 'https://github.com/jreades/i2p/raw/master/data/2020-08-24-sample-listings-simple.csv'
# Read the URL stream into variable called 'response'
# using the function that we imported above
response = urlopen(url)
# Now read from the stream, decoding so that we get actual text
datafile = response.read().decode('utf-8')
# You might want to explore what `__class__` and `__name__`
# offer, but basically the give us a way of finding out what
# is 'behind' more complex variables
print("datafile variable is of type: '" + datafile.__class__.__name__ + "'.\n")
It seems to be a proxy error as described here.
I tried to use different url url = "https://raw.githubusercontent.com/jreades/i2p/master/data/2020-08-24-sample-listings-simple.csv
, but it failed.
lectures/2.2-Principles_of_Programming.md
line 121 and line 169
count = count = 1
should be
count += 1
The solution to define avg_tmp in Task 1.1 does not use the input 'temp' in the function itself.
Proposed solution in workbook:
def avg_tmp(city, temp):
print(f"The average temperature in {city} is {temperatures[cities.index(city)]}")
city="Edinburgh"
avg_tmp(city, temperatures[cities.index(city)])
However, I think it should be temp within the print function, considering that we are passing the temp index. Otherwise, we don't really need the second input. It should work without it.
So, instead:
def avg_tmp(city, temp):
print(f"The average temperature in {city} is {temp}")
city="Edinburgh"
avg_tmp(city, temperatures[cities.index(city)])
Warm regards,
Divya
Hi, I was wondering whether you haven't changed the submission date for Assessment 2 and 3 (Data+Policy Briefing and Individual Reflection) or not because the due is 18 January 2022? Is it supposed to be 18 January 2023?
I notice that different indentation styles were used in file lectures/2.3-Python_the_Basics.md
. For example:
Four spaces on lines 225-228
if x < y:
print("x is less than y")
else:
print("x is not less than y"
and two spaces in other files.
This may get confusing. By the way, I think an introduction to the indentation style of python will be helpful for beginners.
practical 07
function as_markdown
is
checks for identity - if the two variables point to the exact same object. ==
checks for equality - if the two variables point at values are equal.In task 1.2 import os is done in the second code block where os is used in the first code block so it needs to be imported one line earlier
Minor issue, but Task 3.3 talks about the population of Sheffield when we have been working with Bangor and I don't think Sheffield is in the dataset -- suspect Sheffield comes from a previous iteration of this practical
There has been some confusion about Practical 3 Section 1.2.3. Students have been making the functional solution more complicated than it needs to be.
At the moment, the function is just a print statement – so could do with a clarification about how this, or could add the indexing into the function body (def city_avg_temp(city, temperatures).
Link:
fsds/practicals/Practical-03-Foundations_2.ipynb
Lines 246 to 267 in e4f26c5
Student lose access to their email once they graduate (potentially) so github should be set up with their personal email and then go through to add their UCL email separately to benefit from GitHub education benefits. Most will not make use of the github student benefits while they here anyway so having it on their personal account will probably be better to ensure that they still have access to it, even when they leave.
Student confusion over the use of:
test = rows[-1].split(',')
print(test)
print(f"The population of {test[0]} is {int(test[1]):,}")
In getting the comma to print in the number. Suggesting adding a link to: https://blog.teclado.com/python-formatting-numbers-for-printing/ about how to format numbers for printing.
it seems that s1.difference(s2) should output:
{'cherry', 'oranges', 'banana'}
Having a look at the first week practical.
I am running the docker image from the config.sh
file with mount point PWD
, but in my jupyter lab terminal I can't run the cmd:
cd ~/Documents/CASA/fsds/
quarto render articles/Template.qmd
because ~/Documents/CASA/fsds
does not exist.
Should we tell docker to download this repo?
In section 'Sets':
the output of s1.difference(s2) should be:
{'cherry', 'oranges', 'banana'}
Task 3.4
in Practical-06
:
xctr
should be -0.1050000...
but not -0.109999...
from math import floor, ceil
# Calculate min and max to two decimal points
xmin = floor(pdf['longitude'].min()*100)/100
xmax = ceil(pdf['longitude'].max()*100)/100
ymin = floor(pdf['latitude'].min()*100)/100
ymax = ceil(pdf['latitude'].max()*100)/100
print(xmin, xmax, ymin, ymax) ## -0.5 0.29 51.29 51.69
# Calculate the centre of the map
yctr = (ymax+ymin)/2
xctr = (xmax+xmin)/2 ## xctr = (0.29 + -0.5)/2 = -0.105000...
print(xctr, yctr) ## -0.10500000000000001 51.489999999999995
def to_type(cdata, ctype):
# If a string
if isinstance(cdata, str):
try:
if ctype==bool:
return cdata==True
In this part, when cdata='True' and ctype='bool', it will never and ever return True. Cuz a string 'True' won't equals a bool True.
So it should be
return cdata == True
Prac 4, Task 5.2
!touch dtools/init.py
!jupyter nbconvert --ClearOutputPreprocessor.enabled=True
--to python --output=dtools/notebook.py
Practical-04-Objects.ipynb
Instead of Practical-04-Objects-Answers.ipynb
In practical 3, task 4.1.2, setting everything up to run on one line can often be confusing and difficult to know what is happening. While students have just learned how to do this, it can seem relatively simple to know what goes where, but putting everything on one line teaches bad practices and can be especially hard to debug for students if an error is thrown (i.e. it could come from anywhere in the line). Suggest it is broken down into respective steps (just as we taught in the previous task) to make it clearer to students what they should be aiming for and best practices. See the potentially suggested code below:
import numpy as np
# Find the latitude of Manchester.
city = "Lerwick"
city_index = myData['Name'].index(city)
city_lat = myData["Latitude"][
city_index
]
print(f"{city}'s latitude is {city_lat}") # Notice how 'f-strings' work!
# # Find the easternmost city
max_long = np.max(myData["Longitude"])
max_long_position = myData["Longitude"].index( max_long)
city = myData['Name'][ max_long_position ]
print(f"The easternmost city is: {city}")
# # Print the location of Lerwick
city = "Lerwick"
print(f"The town of {city} can be found at " +
f"{abs(myData['Longitude'][myData['Name'].index(city)])}ºW, {myData['Latitude'][myData['Name'].index(city)]}ºN")
# # Find the mean population of the cities
# # using a handy package called numpy
mean = np.mean(myData['Population'])
print(f"The mean population is: {mean}")
Some students, if they do not open up the app, will not be able to used docker
commands (either through the bash script or in their own terminal) until they open up the desktop app themselves. It could be added as an extra step just to see that docker runs on their laptop and removes a likely error.
Hi, Jon!
It is not about a code but it is about z-score formula!
Shouldn't it be
z = x - mean/std?
https://github.com/jreades/i2p/blob/master/lectures/5.2-Randomness.md
the code might with something wrong maybe we can change the'result' in the last line into 'r3'?
Students were generally unclear of what this was doing or how to use it. While later explained, I think some students were confused of what class is and how to use __ __ in their code.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.