Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Linting #255

Merged
merged 14 commits into from
Aug 31, 2023
Merged

Linting #255

merged 14 commits into from
Aug 31, 2023

Conversation

MM1nd
Copy link
Contributor

@MM1nd MM1nd commented Oct 15, 2017

Some improvements to the looks of the code.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 85.776% when pulling 30dfb2b on MM1nd:linting into 4071a70 on Mindwerks:master.

2 similar comments
@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 85.776% when pulling 30dfb2b on MM1nd:linting into 4071a70 on Mindwerks:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.9%) to 85.776% when pulling 30dfb2b on MM1nd:linting into 4071a70 on Mindwerks:master.

@codecov-io
Copy link

codecov-io commented Oct 15, 2017

Codecov Report

Merging #255 into master will increase coverage by 0.79%.
The diff coverage is 78.43%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #255      +/-   ##
==========================================
+ Coverage   79.49%   80.29%   +0.79%     
==========================================
  Files          28       28              
  Lines        3468     3466       -2     
  Branches      651      651              
==========================================
+ Hits         2757     2783      +26     
+ Misses        526      493      -33     
- Partials      185      190       +5
Impacted Files Coverage Δ
worldengine/simulations/irrigation.py 96.29% <ø> (ø) ⬆️
worldengine/protobuf/World_pb2.py 100% <ø> (ø) ⬆️
worldengine/simulations/precipitation.py 98.03% <ø> (ø) ⬆️
worldengine/simulations/temperature.py 93.33% <ø> (ø) ⬆️
worldengine/simulations/hydrology.py 94.73% <ø> (ø) ⬆️
worldengine/simulations/erosion.py 70.11% <0%> (+10.83%) ⬆️
worldengine/common.py 85.05% <100%> (ø) ⬆️
worldengine/cli/main.py 79% <100%> (ø) ⬆️
worldengine/imex/__init__.py 10% <100%> (ø) ⬆️
worldengine/image_io.py 67.27% <100%> (ø) ⬆️
... and 12 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4071a70...30dfb2b. Read the comment docs.

@psi29a
Copy link
Member

psi29a commented Oct 16, 2017

This looks OK to me, I have a few... 'meh... why?' moments, but nothing that I'm like 'nonononono'.
@ftomassetti any comments?

Copy link
Member

@ftomassetti ftomassetti left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me. Thank you for another great contribution!

@@ -44,42 +44,45 @@ def _assert_img_equal(self, blessed_image_name, drawn_image):
"and/or amount of channels. Blessed %s, drawn %s"
% (str(blessed_img.array.shape), str(drawn_image.array.shape)))

# compare images; cmp_array will be an array of booleans in case of equal shapes (and a pure boolean otherwise)
# compare images;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be ":" instead of ";"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@@ -270,8 +270,9 @@ class TropicalRainForest(Biome, Jungle):

def biome_name_to_index(biome_name):
names = sorted(_BiomeMetaclass.biomes.keys())
for i in range(len(names)):
if names[i] == biome_name:

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we do not need this new extra line

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

@@ -426,7 +431,7 @@ def draw_satellite(world, target):
all_b.append(b)

# Making sure there is at least one valid tile to be smoothed before we attempt to average the values
if len(all_r) > 0:
if all_r:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these equivalent?

Copy link
Contributor Author

@MM1nd MM1nd Oct 17, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

# depending on the distance from the next land
# possible TODO: make this a parameter
factors = [0.0, 0.3, 0.5, 0.7, 0.9]

next_land = next_land_dynamic(world.layers['ocean'].data)

sea_depth = sea_level - world.layers['elevation'].data
result = sea_level - world.layers['elevation'].data
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not like the name result much here

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sea_depth is the name of the function and pylint rightfully complains that this redefines a name from the outer scope. Personally I use result a lot as a variable name, but I'm open to anything that is not sea_depth. Alternatively the function needs a new name.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

depth_of_sea (in the very french way of saying sea_depth)


# Humidity
if len(p_world.humidity.rows) > 0:
if p_world.humidity.rows:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is this equivalent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cf. above

@MM1nd
Copy link
Contributor Author

MM1nd commented Oct 17, 2017

"This looks OK to me, I have a few... 'meh... why?' moments, but nothing that I'm like 'nonononono'."

The answer to "why?" is almost certainly "because pylint said so" and in most cases likely "because the line was too long". I'm agnostic about all of this as witnessed by the three "whitespace" commits at the end of every of my PRs :)

@psi29a
Copy link
Member

psi29a commented Oct 17, 2017

I usually set my columns to 120 (from 80) and adjust linting accordingly...

@ftomassetti
Copy link
Member

Me too, I use 120 columns and that settings is suggested here (arguably very difficult to find)

@psi29a psi29a merged commit 000a2ac into Mindwerks:master Aug 31, 2023
1 check failed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants