Beta

Approximating a higher-order differential equation using Euler's method

Description
Loading description...
Mathematics
Algorithms
  • Please sign in or sign up to leave a comment.
  • Voile Avatar

    If your program is passed any invalid values, it should raise a ValueError

    It is not specified what "invalid values" mean in the kata. Input validation without specification is an open-ended question, which boils down to everyone trying to read kata author's mind (which is bad, obviously).

    • StephenDonovan1 Avatar

      If you reread the descriptions of the different arguments to the function you should find that some include descriptions of what values are considered valid. This implies what most of the invalid cases are, and the rest are covered by the other part of that paragraph, about the function not being defined.

      I'll tweak the wording to try to communicate it more clearly but the relevant error cases are given from the information in the description.

    • Voile Avatar

      Well, it's made confusing because there is another related problem with the error checking tests: they don't fail when no exceptions are thrown. They only fail the test if an exception that's not ValueError is thrown.

  • Dr Gabo Avatar

    Hello! I think there are some changes that can be done:

    • It might be a good idea to indicate the tolerance to errors you have, since it seems like floats must be used.
    • Just as with the fun parameter, specifying the return type and semantics of the euler_sol function is a good addition.
    • This is more personal, but a simple example is always welcome in these mathematical exercises.

    Cheers :)

    Edit: using Python's type hints is also a very good addition to make your kata much more understandable and less prone to interpretation errors.

    • StephenDonovan1 Avatar

      Thanks for the comment, I've gone in and implemented the changes you suggested. Can you check to see if it's better now?

      Also, do you think the default error is too strict here?

    • Dr Gabo Avatar

      Okay, now the description is a little bit more clear. I would also suggest to use type hints here:

      [...] Implement the function euler_sol(fun, order, step, num_steps, *initial) [...]

      Also, getting to know both markdown and html is very important in order to make understandable descriptions, so maybe ussing a bullet list in the parameters descriptions would increase readability and things like that.

    • StephenDonovan1 Avatar

      Are you sure about adding the type hints to the description? I don't see it adding much, and the type hints are pretty long and messy.

      But yeah, I can add bullets if you want

    • Dr Gabo Avatar

      You are not wrong, it depends on how you structure the description. I just thought those might be some good ways to use them (I always include hints), but you can do as you like.