Plasmapy: Add narrative documentation on @validate_quantities to development guide

Created on 5 May 2020  路  3Comments  路  Source: PlasmaPy/PlasmaPy

The validators created in #648 provide useful checks on arguments and returned values of functions and methods. While the @validate_quantities decorator has a well-written docstring, narrative documentation in the development guide would help put it in context for newcomers and help them understand why and how it is used.

Documentation

Most helpful comment

This would be great as an example (ekhm, notebook ;) ). That could then be linked from the appropriate docs.

All 3 comments

A possibility would be to have a section on the development guide that focuses on decorators for formulary-like functions. It might be useful to discuss @particle_input in there as well as @validate_quantities, although it would still be useful to at least briefly cover @particle_input in the narrative documentation in plasmapy.particles so people know it exists.

This would be great as an example (ekhm, notebook ;) ). That could then be linked from the appropriate docs.

Another thought is that it would be helpful to have an example of using validate_quantities with a setter in the docs, since I got confused about which decorator should go first. An example that could be expanded on would be:

class A: 

    @property 
    def x(self): 
        return 1 

    @x.setter 
    @validate_quantities  # though actually set some actual validations
    def x(self, y): 
        self.y = y 

The @x.setter decorator should go on the outside.

Was this page helpful?
0 / 5 - 0 ratings