Run skinmap code through black

Issue #852 resolved
Ed McDonagh created an issue

Previously left as code is being reworked by @wens but it should be done as the new skinmap code is likely to be after release 1.0 and it currently causes issues with checking the rest of the code for black (forever having to revert).

Refs issue #841

Comments (9)

  1. Ed McDonagh reporter

    @Jonathan Cole @David Platten @wens @Luuk Can I have some advice please?

    In make_skin_map.py we are currently using old_div, and I want to remove the dependency but I am not sure what the right thing to do is.

    In release 0.9.0, the code in question looked like this:

            my_exp_map.my_dose.totalDose = np.roll(my_exp_map.my_dose.totalDose,
                                                   int(my_exp_map.phantom.phantom_flat_dist / 2),
                                                   axis=0)
            try:
                my_exp_map.my_dose.totalDose = np.rot90(my_exp_map.my_dose.totalDose)
            except ValueError:
                pass
    

    In preparation for moving to Python 3, the automatic tools I used imported old_div and changed it to this in 0.9.1 and the current release:

            my_exp_map.my_dose.totalDose = np.roll(my_exp_map.my_dose.totalDose,
                                                   int(old_div(my_exp_map.phantom.phantom_flat_dist, 2)),
                                                   axis=0)
            try:
                my_exp_map.my_dose.totalDose = np.rot90(my_exp_map.my_dose.totalDose)
            except ValueError:
                pass
    

    I want to remove the import and just have a Python 3 division, but I don’t know if we need float division `/` or floor division Python 2 style `//`.

    Please advise!

  2. Jonathan Cole

    Given that I wrapped it in an int I suspect floor division would reproduce the same output as the current code. It certainly doesn’t need the added precision of making it all float and would probably break something further on if we did add that precision in.

  3. Log in to comment