UCL / rsd-engineeringcourse

Course materials for Research Software Engineering course.
http://github-pages.ucl.ac.uk/rsd-engineeringcourse/
Other
108 stars 97 forks source link

Iterators and Generators page #115

Closed mattagape closed 5 years ago

mattagape commented 5 years ago
  1. We see iter(), __iter__(), next and __next__(). This is inconsistent. Is this due to notebook mark-up errors?

  2. It says # See future NumPy lecture for using reshape, but was that not in a previous lecture?

  3. In A shortcut to iterables: the iter method section, where is __iter__() called? I don't get this.

  4. Typo in "and return an something iterable." (an)

  5. The code says "@repeater(3)". Can we do this because we earlier defined a repeater() function? EDIT: ah I see further down this is indeed the case. But we should make this clear.

  6. Typo def assert_examplar should say def assert_exemplar

  7. On the same piece of code it would help if we could see an example of it being used to make things clearer.

  8. In def test_greeter(), there is a superfluous bracket in ) as fixtures_file:

  9. I don't really understand this code. And what does **fixture mean?

  10. In Negative test contexts managers section, we should show the output seen by running the code straight after "We have seen this:"

  11. My head was spinning by the time I got to def homemade_raises_decorator. I'm not sure I understand it. Then again, maybe people just need to know how to use these things without understanding all the details??!!

General comment: there are many new concepts to be understood in this page.

ageorgou commented 5 years ago
  1. Intro section:

    • "We've seen that in Python, anything which can be iterated over is called an iterable": I don't think we have.
    • "This would NOT work if we used more points": Be explicit, "because we would run out of memory!"
    • [typo] "We need to use a generator": missing "."
  2. Iterators:

    • Remove the unused ranges from the start
    • "In Python 3": just remove and be silent on version?
    • "ITERATOR": make bold instead of caps
    • "The iterator is an iterable which is not an list": sounds cryptic - reword?
    • "An generator object": range is not a generator, nor an iterator. Maybe "An iterator object, like we can get from range(3), works by defining a..."
    • We are calling a.___next__(), where I think next(a) is better. I don't know if we need to go into the magics of __next__, __iter__
    • Remove last code block computing total sum (duplicated from above)
  3. Defining Our Own Iterable:

    • "For each of the concepts, in Python, like sequence, container, iterable, python defines a": reword
    • Mentions of next in this section should be __next__ (but maybe not all?)
  4. A shortcut to iterables: the __iter__ method:

  5. Generators:

    • Might be worth being explicit: "Sometimes you may need to gather all values from a generator into a list before you can pass them to a function" (e.g. before the plotting, and move that after the other usage examples)
  6. Context managers:

    • Missing the example.yaml file (if we really need it - could just write instead).
    • Have we mentioned context managers before? (EDIT: We have, under "Working with files" in "Research Data in Python". But it would still be worth it to say that the context manager takes care of additional setup, cleanup, error-handling, ... so we don't have to write code explicitly for it)
  7. Decorators:

    • A lot of this may be too convoluted, I had some trouble following it too. Perhaps it could be marked as supplementary (either the whole section, or the parts recreating the nose/pytest functionality). It would be good for students to recognise the decorator syntax and understand in very broad lines what they do, but not necessarily how to write their own at this stage?
    • Are we using nose or pytest for the course?
dpshelio commented 5 years ago