Skip to content

Conversation

@SourceryAI
Copy link

Thanks for starring sourcery-ai/sourcery ✨ 🌟 ✨

Here's your pull request refactoring your most popular Python repo.

If you want Sourcery to refactor all your Python repos and incoming pull requests install our bot.

Review changes via command line

To manually merge these changes, make sure you're on the master branch, then run:

git fetch https://github.com/sourcery-ai-bot/peak-flow-calculator master
git merge --ff-only FETCH_HEAD
git reset HEAD^

Peak-Flow Calculator "Lite". Use with pre-calculated slope and flow direction rasters.
"""
output_data = main(
return main(
Copy link
Author

Choose a reason for hiding this comment

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

Function lite refactored with the following changes:

Comment on lines -70 to +69
output_data = main(
return main(
Copy link
Author

Choose a reason for hiding this comment

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

Function full refactored with the following changes:

Comment on lines -39 to +43
tc_hr = const_a * math.pow(max_flow_length, const_b) * math.pow((mean_slope / 100), const_c)
return tc_hr
return (
const_a
* math.pow(max_flow_length, const_b)
* math.pow((mean_slope / 100), const_c)
)
Copy link
Author

Choose a reason for hiding this comment

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

Function calculate_tc refactored with the following changes:

Comment on lines -33 to +35

# Skip the first 10 rows of the csv, which are assorted header information.
for j in range (1, 11):
for _ in range (1, 11):
Copy link
Author

Choose a reason for hiding this comment

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

Function precip_table_etl_cnrccep refactored with the following changes:

Comment on lines -92 to +97
h = tuple([
i for i in list(etl.header(t2)) if (int(i) >= frequency_min and int(i) <= frequency_max)
])
h = tuple(
i
for i in list(etl.header(t2))
if (int(i) >= frequency_min and int(i) <= frequency_max)
)

Copy link
Author

Choose a reason for hiding this comment

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

Function precip_table_etl_noaa refactored with the following changes:

if not isinstance(dem,Raster):
dem = Raster(dem)

Copy link
Author

Choose a reason for hiding this comment

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

Function prep_cn_raster refactored with the following changes:

Comment on lines -157 to +158

cs = env.outputCoordinateSystem.exportToString()

# SOILS -------------------------------------

Copy link
Author

Choose a reason for hiding this comment

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

Function build_cn_raster refactored with the following changes:

Comment on lines -332 to 337
results = {}

# make a raster object with the catchment raster
if not isinstance(catchment_areas,Raster):
c = Raster(catchment_areas)
else:
if isinstance(catchment_areas,Raster):
c = catchment_areas
Copy link
Author

Choose a reason for hiding this comment

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

Function derive_data_from_catchments refactored with the following changes:

Comment on lines -60 to +66
if where == "in_memory":
location = "in_memory"
elif where == "fgdb":
location = env.scratchGDB
elif where == "folder":
if where == "folder":
location = env.scratchFolder
elif where == "in_memory":
location = "in_memory"
else:
location = env.scratchGDB

Copy link
Author

Choose a reason for hiding this comment

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

Function so refactored with the following changes:

  • Simplify conditional into switch-like form (switch)

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.

1 participant