Skip to content

Commit

Permalink
review all files
Browse files Browse the repository at this point in the history
  • Loading branch information
Saransh-cpp committed Jan 9, 2025
1 parent fd0256e commit 0c60e84
Show file tree
Hide file tree
Showing 34 changed files with 738 additions and 1,440 deletions.
11 changes: 5 additions & 6 deletions ch00git/11Miscellany.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
# ---

# %% [markdown]
# # Git Stash
# # Git miscellany
# ## Git Stash

# %% [markdown]
# **NOTE:** using bash/git commands is not fully supported on jupyterlite yet (due to single
Expand Down Expand Up @@ -159,8 +160,6 @@
# * with -X: Only remove .gitignore files

# %% [markdown]
# ## Hunks
#
# ## Git Hunks
#
# A "Hunk" is one git change. This changeset has three hunks:
Expand Down Expand Up @@ -206,7 +205,7 @@
# %% [markdown]
# ## GitHub pages
#
# ## Yaml Frontmatter
# ### Yaml Frontmatter
#
# GitHub will publish repositories containing markdown as web pages, automatically.
#
Expand Down Expand Up @@ -236,7 +235,7 @@
# git commit -m "Add github pages YAML frontmatter"

# %% [markdown]
# ## The gh-pages branch
# ### The gh-pages branch
#
# GitHub creates github pages when you use a special named branch.
#
Expand All @@ -258,7 +257,7 @@
# http://UCL.github.io/github-example/

# %% [markdown]
# ## UCL layout for GitHub pages
# ### UCL layout for GitHub pages
#
# You can use GitHub pages to make HTML layouts, here's an [example of how to do it](http://github.com/UCL/ucl-github-pages-example),
# and [how it looks](http://github-pages.ucl.ac.uk/ucl-github-pages-example). We won't go into the detail of this now,
Expand Down
4 changes: 2 additions & 2 deletions ch00git/12Remotes.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
# %% [markdown]
# ## Hosting Servers
#
# ## Hosting a local server
# ### Hosting a local server
#
# * Any repository can be a remote for pulls
# * Can pull/push over shared folders or ssh
Expand Down Expand Up @@ -123,7 +123,7 @@
# If you have a colleague on a shared file system, you can use this approach to collaborate through that file system.

# %% [markdown]
# ## Home-made SSH servers
# ### Home-made SSH servers
#
# Classroom exercise: Try creating a server for yourself using a machine you can SSH to:

Expand Down
16 changes: 8 additions & 8 deletions ch00git/15Workflow.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
# Collaborators need to go to the leader's GitHub profile and find the repository we created for that lesson. Mine is in https://github.com/jamespjh/github-example

# %% [markdown]
# #### 1. Fork repository
# ### 1. Fork repository
#
# You will see on the top right of the page a `Fork` button with an accompanying number indicating how many GitHub users have forked that repository.
#
Expand All @@ -65,7 +65,7 @@
# Collaborators: note how GitHub has redirected you to your own GitHub page and you are now looking at an exact copy of the team leader's repository.

# %% [markdown]
# #### 2. Clone your forked repo
# ### 2. Clone your forked repo
#
# Collaborators: go to your terminal and clone the newly created fork.
#
Expand All @@ -74,7 +74,7 @@
# ```

# %% [markdown]
# #### 3. Create a feature branch
# ### 3. Create a feature branch
#
# It's a good practice to create a new branch that'll contain the changes we want. We'll learn more about branches later on. For now, just think of this as a separate area where our changes will be kept not to interfere with other people's work.
#
Expand All @@ -83,7 +83,7 @@
# ```

# %% [markdown]
# #### 4. Make, commit and push changes to new branch
# ### 4. Make, commit and push changes to new branch
#
# For example, let's create a new file called `SouthWest.md` and edit it to add this text:
#
Expand All @@ -102,7 +102,7 @@
# ```

# %% [markdown]
# #### 5. Create Pull Request
# ### 5. Create Pull Request
#
# Go back to the collaborator's GitHub site and reload the fork. GitHub has noticed there is a new branch and is presenting us with a green button to `Compare & pull request`. Fantastic! Click that button.
#
Expand All @@ -113,7 +113,7 @@
# Now, the leader needs to go to their GitHub site. They have been notified there is a pull request in their repo awaiting revision.

# %% [markdown]
# #### 6. Feedback from team leader
# ### 6. Feedback from team leader
#
# Leaders can see the list of pull requests in the vertical menu of the repo, on the right hand side of the screen. Select the pull request the collaborator has done, and inspect the changes.
#
Expand All @@ -124,7 +124,7 @@
# GitHub allows you to add a comment about that specific part of the change. Your collaborator has forgotten to add a title at the beginning of the file right before "Exmoor", so tell them so in the form presented after clicking the `+` button.

# %% [markdown]
# #### 7. Fixes by collaborator
# ### 7. Fixes by collaborator
#
# Collaborators will be notified of this comment by email and also in their profiles page. Click the link accompanying this notification to read the comment from the team leader.
#
Expand All @@ -149,7 +149,7 @@
# This change will automatically be added to the pull request you started.

# %% [markdown]
# #### 8. Leader accepts pull request
# ### 8. Leader accepts pull request
# The team leader will be notified of the new changes that can be reviewed in the same fashion as earlier.
#
# Let's assume the team leader is now happy with the changes.
Expand Down
78 changes: 25 additions & 53 deletions ch01dataanddesign/061internet.ipynb.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,27 +13,20 @@

# %% [markdown]
# # Getting data from the internet

# %% [markdown]
#
# We've seen about obtaining data from our local file system.

# %% [markdown]
#
# The other common place today that we might want to obtain data is from the internet.

# %% [markdown]
#
# It's very common today to treat the web as a source and store of information; we need to be able to programmatically
# download data, and place it in Python objects.

# %% [markdown]
#
# We may also want to be able to programmatically *upload* data, for example, to automatically fill in forms.

# %% [markdown]
#
# This can be really powerful if we want to, for example, do automated meta-analysis across a selection of research papers.

# %% [markdown]
#
# ## Uniform resource locators

# %% [markdown]
#
# All internet resources are defined by a [_uniform resource locator_ (URL)](https://en.wikipedia.org/wiki/URL) which are a particular type of [_uniform resource identifier_ (URI)](https://en.wikipedia.org/wiki/Uniform_Resource_Identifier). For example

# %%
Expand All @@ -47,25 +40,18 @@
# * A *port* (optional, most protocols have a typical port associated with them, e.g. 80 for HTTP, 443 for HTTPS)
# * A *path* (analogous to a file path on the machine, here it is just `vt`)
# * A *query* part after a ?, (optional, usually ampersand `&` separated *parameters* e.g. `x=658` or `z=10`)

# %% [markdown]
#
# **Supplementary materials**: These can actually be different for different protocols, the above is a simplification, you can see more, for example, at
# [the Wikipedia article on URIs](https://en.wikipedia.org/wiki/URI_scheme).

# %% [markdown]
#
# URLs are not allowed to include all characters; we need to, for example, [_escape_](https://en.wikipedia.org/wiki/Escape_character) a space that appears inside the URL, replacing it with `%20`, so e.g. a request of `http://some example.com/` would need to be `http://some%20example.com/`.
#

# %% [markdown]
# **Supplementary materials**: The code used to replace each character is the [ASCII](http://www.asciitable.com) code for it.

# %% [markdown]
#
# **Supplementary materials**: The escaping rules are quite subtle. See [the Wikipedia article on percent-encoding](https://en.wikipedia.org/wiki/Percent-encoding). The standard library provides the [urlencode](https://docs.python.org/3/library/urllib.parse.html#urllib.parse.urlencode) function that can take care of this for you.

# %% [markdown]
#
# ## Requests

# %% [markdown]
#
# The Python [Requests](http://docs.python-requests.org/en/latest/) library can help us manipulate URLs and requesting the content associated with them. It is easier to use than the `urllib` library that is part of the standard library, and is included with Anaconda and Canopy. It sorts out escaping, parameter encoding, and so on for us.

# %%
Expand Down Expand Up @@ -129,14 +115,11 @@

# %% [markdown]
# To get a more useful representation of the data, we will therefore need to process the content we get using a Python function which understands the byte-encoding of the corresponding file format.

# %% [markdown]
#
# Again, it is important to separate the *transport* model, (e.g. a file system, or a HTTP request for the web), from the data model of the data that is returned.

# %% [markdown]
#
# ## Example: sunspots

# %% [markdown]
#
# Let's try to get something scientific: the sunspot cycle data from the [Sunspot Index and Long-term Solar Observations website](http://sidc.be/silso/home)

# %%
Expand All @@ -147,18 +130,14 @@

# %% [markdown]
# This looks like semicolon-separated data, with different records on different lines. Line separators come out as `\n` which is the escape-sequence corresponding a newline character in Python.

# %% [markdown]
#
# There are many many scientific datasets which can now be downloaded like this - integrating the download into your data
# pipeline can help to keep your data flows organised.

# %% [markdown]
#
# ## Writing our own parser

# %% [markdown]
#
# We'll need a Python library to handle semicolon-separated data like the sunspot data.

# %% [markdown]
#
# You might be thinking: "But I can do that myself!":

# %%
Expand All @@ -180,30 +159,23 @@
# has three fields, the first of which is
#
# Something; something
#

# %% [markdown]
#
# Our naive code above would however not correctly parse this input:

# %%
'"Something; something"; something; something'.split(';')

# %% [markdown]
# You'll never manage to get all that right; so you'll be better off using a library to do it.

# %% [markdown]
#
# ## Writing data to the internet

# %% [markdown]
#
# Note that we're using `requests.get`. `get` is used to receive data from the web.
# You can also use `post` to fill in a web-form programmatically.

# %% [markdown]
#
# **Supplementary material**: Learn about using `post` with [Requests](http://docs.python-requests.org/en/latest/user/quickstart/).

# %% [markdown]
#
# **Supplementary material**: Learn about the different kinds of [HTTP request](https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods): [Get, Post, Put, Delete](https://en.wikipedia.org/wiki/Create,_read,_update_and_delete)...

# %% [markdown]
#
# This can be used for all kinds of things, for example, to programmatically add data to a web resource. It's all well beyond
# our scope for this course, but it's important to know it's possible, and start to think about the scientific possibilities.
Loading

0 comments on commit 0c60e84

Please sign in to comment.