Skip to content

CLEANING: some PEP8 tips

Example from there

    def Calculate_R_env(self):
        """ Check Planet_models_LoFo14.py for details on input and
            output parameters;
            R_env ~ t**0.18 for *enhanced opacities*;
            R_env ~ t**0.11 for *solar metallicities*
        """
        age_exponent = {"solarZ": -0.11, "enhZ": -0.18}
        R_env = 2.06 * self.mass**(-0.21) * (self.fenv/5)**0.59 * \
            self.flux**0.044 * \
            ((self.age/1e3)/5)**(age_exponent[self.metallicity])
        return R_env  # in units of R_earth

Great stuff

Documentation

As I told you the doc is very good already. So continue it will help. as a tip did you know that you could do:

import platypos

help(platypos.planet_LoFo14.Calculate_R_env)

it will print:

Check Planet_models_LoFo14.py for details on input and
            output parameters;
            R_env ~ t**0.18 for *enhanced opacities*;
            R_env ~ t**0.11 for *solar metallicities*

variable names

age_exponent is a good variable name it is clear.

Comments

You have a good balance of comments, keep it that way.

Issues

Documentation

You may have a look at the Sphynx package and Numpy documentation style. It will reward you with all the time you spend on writing docs.

So far they are good, but if you follow the Numpy standards you will really feel like a goddess when Sphynx can produce a website with the entire code documentation in 1 command line!!!

Variable names

  • R_env is not clear. radius of the environment? radius of the envelop I guess. You can keep the variable name like that but at least mention it in the doc.

  • fenv is a bad name, you should follow one rule: f_env or F_env

Comments

Stating units in comments is very good (because comments are for the developer and it is always nice to see the unit straight away, while developing). But the user needs it too! put it in the docs.

PEP8

R_env = 2.06 * self.mass**(-0.21) * (self.fenv/5)**0.59 * \
            self.flux**0.044 * \
            ((self.age/1e3)/5)**(age_exponent[self.metallicity])

should be (PEP8):

R_env = 2.06 * self.mass ** -0.21 * ( self.f_env / 5. ) ** 0.59 \
             * self.flux ** 0.044 \
             * ( self.age / 1.e3 / 5.) ** ( age_exponent[self.metallicity] )

I personally would write:

R_env = 2.06 * self.mass**(-0.21) * ( self.f_env / 5. )**(0.59) \
             * self.flux**(0.044) \
             * ( self.age / 1.e3 / 5.)**( age_exponent[self.metallicity] )