Skip to content

Commit

Permalink
fix: cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lwasser committed Oct 29, 2024
1 parent 785f5b5 commit 37a9831
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
5 changes: 4 additions & 1 deletion clean-modular-code/activity-3/clean-code-activity-3.md
Original file line number Diff line number Diff line change
Expand Up @@ -445,6 +445,7 @@ def clean_title(title):
editable: true
slideshow:
slide_type: ''
tags: [raises-exception]
---
# Add checks to the clean_title function to make sure this code runs
all_titles = []
Expand Down Expand Up @@ -493,14 +494,15 @@ slideshow:
slide_type: ''
---
print(f"The value is {joss_pubs_df['title'][0]}")
get_title(joss_pubs_df["title"][0])
clean_title(joss_pubs_df["title"][0])
```

```{code-cell} ipython3
---
editable: true
slideshow:
slide_type: ''
tags: [raises-exception]
---
clean_title(joss_pubs_df["title"][1])
```
Expand All @@ -520,6 +522,7 @@ Fix the workflow below so it runs. To do this, you can use the results of the fu
editable: true
slideshow:
slide_type: ''
tags: [raises-exception]
---
# Full code snippet
import json
Expand Down
9 changes: 6 additions & 3 deletions clean-modular-code/clean-code-present.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ kernelspec:

+++ {"editable": true, "slideshow": {"slide_type": "skip"}}

# notes
## Notes

```{code-cell} ipython3
---
Expand All @@ -42,8 +42,9 @@ slideshow:
slide_type: ''
---
# this code is not PEP8 compliant -- why?
def doStuff(a ,b):print ("Result:",a+b) ;return a+b
x=True; if x: print ( "Messy code.") ; print("Oops!")
def doStuff(a ,b):print ("Result:",a+b) ; return a+b
x=True
if x: print ( "Messy code.") ; print("Oops!")
```

```{code-cell} ipython3
Expand Down Expand Up @@ -419,6 +420,7 @@ df = pd.json_normalize(json_data)
editable: true
slideshow:
slide_type: slide
tags: [raises-exception]
---
# The same problem occurs in this code but it fails with a less useful message
import json
Expand Down Expand Up @@ -516,6 +518,7 @@ package_name
editable: true
slideshow:
slide_type: slide
tags: [raises-exception]
---
# In others you may want to intentionally raise an error with a custom message.
title = 999
Expand Down

0 comments on commit 37a9831

Please sign in to comment.