5

Why? I don't see any benefit to using this PixelComponent class over simply using the value type directly, because... Clamping ... clamping to min and max values is less helpful than it appears. We might want a color to be clamped to the range 0.f to 1.f in our output. However, it's very useful to do calculations with colors outside of that range as an ...


2

You have an iterator Your code implements an iterator, you are right. You have defined a __next__ method and it works well. I would tweak your code slightly, though: remove the check because iterators can be empty and that is okay; fix minor spacing issues around operators, etc; use augmented assignment to increment; change order of statements in __next__ ...


2

I would suggest moving this method into the TimeSpan class. Let a TimeSpan tell you about its overlaps. Don't interrogate it for internal details and then figure it out for yourself. Private helper methods will make the compareTo calls more readable. Assorted other thoughts: A checked exception is probably not right here. I'd suggest preferring ...


1

Not sure if you really need an own class definition. Also your code doesn't do anything apart from the automatic clamping. I would suggest using something like using PixelT = uint8_t; somewhere in your code. Maybe it would also be interesting to see an example of how your code is used to suggest alternatives. One alternative would surely be to use the std::...


1

For the first part of making sequence to intervals, you could do this instead (prob. more Pythonic?) (This can be converted to a function easier - leave for the exercise) >>> # if x-1 not in seq: x becomes start point >>> # if y+1 not in seq: y becomes end point >>> starts = [x for x in seq if x-1 not in seq] >>> ends = ...


Only top voted, non community-wiki answers of a minimum length are eligible