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

Feature/add ruff #61

Closed
wants to merge 9 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions examples/energy_ratio/energy_ratio_in_turbine_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,13 @@
import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
from floris.tools.visualization import visualize_cut_plane
from floris.utilities import wrap_360

from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc.energy_ratio import energy_ratio_suite
from flasc.visualization import plot_floris_layout

from floris.tools.visualization import visualize_cut_plane
from floris.utilities import wrap_360


def load_data():
# Load dataframe with artificial SCADA data
Expand Down
9 changes: 4 additions & 5 deletions examples/energy_ratio/energy_ratio_vs_wd_for_multiple_dfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,16 @@
# the License.


import matplotlib.pyplot as plt
import os
import pandas as pd

import matplotlib.pyplot as plt
import pandas as pd
from floris import tools as wfct
from floris.utilities import wrap_360

from flasc.energy_ratio import energy_ratio_suite
from flasc.dataframe_operations import \
dataframe_manipulations as dfm
from flasc import floris_tools as fsatools
from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc.energy_ratio import energy_ratio_suite


def load_data():
Expand Down
10 changes: 5 additions & 5 deletions examples/energy_ratio/energy_ratio_vs_wd_for_single_df.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
# the License.


import matplotlib.pyplot as plt
import os
import pandas as pd

import matplotlib.pyplot as plt
import pandas as pd
from floris import tools as wfct
from flasc.energy_ratio import energy_ratio
from flasc.dataframe_operations import \
dataframe_manipulations as dfm

from flasc import floris_tools as fsatools
from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc.energy_ratio import energy_ratio


def load_data():
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import os

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd

import seaborn
from floris.utilities import wrap_360

from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc import floris_tools as ftools
from flasc.dataframe_operations import dataframe_manipulations as dfm
from flasc.energy_ratio import energy_ratio_suite
from flasc.visualization import plot_floris_layout

Expand Down Expand Up @@ -146,7 +147,7 @@ def _plot_single_wd(df):
# an unreliable wind direction measurement. Here, for explanation purposes,
# we just exclude turbine 3 from our analysis.
nturbs = len(fi.layout_x)
bad_turbs = [3] # Just hypothetical situation: assume turbine 3 gave faulty wind directions so we ignore it
bad_turbs = [3] # hypothetical situation: assume turbs 3 gave faulty wind dirs so ignore it
turb_wd_measurement = [i for i in range(nturbs) if i not in bad_turbs]

# We use a wind direction bin width of 15 deg. Thus, if we look at
Expand Down
15 changes: 8 additions & 7 deletions examples/energy_ratio/wake_steering_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@
# License for the specific language governing permissions and limitations under
# the License.

import numpy as np
import matplotlib.pyplot as plt
import os

import matplotlib.pyplot as plt
import numpy as np
import pandas as pd
import seaborn as sns

from floris import tools as wfct
from floris.utilities import wrap_360

from flasc.energy_ratio import energy_ratio_suite
# from flasc import floris_tools as fsatools

# from flasc import floris_tools as fsatools
from flasc.visualization import plot_layout_with_waking_directions


if __name__ == "__main__":

# Construct a simple 3-turbine wind farm with a
Expand All @@ -39,7 +38,8 @@
# Show the wind farm
plot_layout_with_waking_directions(fi)

# Create a time history of points where the wind speed and wind direction step different combinations
# Create a time history of points where the wind speed
# and wind direction step different combinations
ws_points = np.arange(5.0,10.0,1.0)
wd_points = np.arange(250.0, 290.0, 1.,)
num_points_per_combination = 5 # How many "seconds" per combination
Expand Down Expand Up @@ -100,7 +100,8 @@
'pow_002':power_wakesteering_downstream
})

# Create alternative versions of each of the above dataframes where the wd/ws are perturbed by noise
# Create alternative versions of each of the
# above dataframes where the wd/ws are perturbed by noise
df_baseline_noisy = pd.DataFrame({
'wd':wd_array + np.random.randn(len(wd_array))*5,
'ws':ws_array + np.random.randn(len(ws_array)),
Expand Down
111 changes: 111 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,111 @@
[build-system]
requires = ["setuptools >= 40.6.0", "wheel"]
build-backend = "setuptools.build_meta"


[coverage.run]
# Coverage.py configuration file
# https://coverage.readthedocs.io/en/latest/config.html
branch = true
source = "flasc/*"
omit = [
"setup.py",
"tests/*"
]


[tool.pytest.ini_options]
testpaths = "tests"
filterwarnings = [
"ignore::DeprecationWarning:pandas.*:"
]


[tool.ruff]
src = ["flasc", "tests"]
line-length = 100
target-version = "py310"

# See https://github.com/charliermarsh/ruff#supported-rules
# for rules included and matching to prefix.
select = ["E", "F", "I"]

# F401 unused-import: Ignore until all used isort flags are adopted in ruff
ignore = ["F401"]

# Allow autofix for all enabled rules (when `--fix`) is provided.
# fixable = ["A", "B", "C", "D", "E", "F"]
fixable = ["E", "F", "I"]
unfixable = []

# Exclude a variety of commonly ignored directories.
exclude = [
".bzr",
".direnv",
".eggs",
".git",
".hg",
".mypy_cache",
".nox",
".pants.d",
".ruff_cache",
".svn",
".tox",
".venv",
"__pypackages__",
"_build",
"buck-out",
"build",
"dist",
"node_modules",
"venv",
]

# Allow unused variables when underscore-prefixed.
dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$"

# [tool.ruff.per-file-ignores]
# # F841 unused-variable: ignore since this file uses numexpr and many variables look unused
# "floris/simulation/wake_deflection/jimenez.py" = ["F841"]
# "floris/simulation/wake_velocity/jensen.py" = ["F841"]
# "floris/simulation/wake_velocity/gauss.py" = ["F841"]

# # FIXME
# "floris/tools/interface_utilities.py" = ["F821"]
# "floris/tools/wind_rose.py" = ["F821"]

[tool.ruff.isort]
combine-as-imports = true
known-first-party = ["flasc"]
order-by-type = false

# [tool.ruff.mccabe]
# # Unlike Flake8, default to a complexity level of 10.
# max-complexity = 10


[tool.isort]
sections = [
"FUTURE",
"STDLIB",
"THIRDPARTY",
"FIRSTPARTY",
"LOCALFOLDER"
]
known_first_party = [
"flasc"
]
multi_line_output = 3
combine_as_imports = true
force_grid_wrap = 3
include_trailing_comma = false
use_parentheses = true
lines_after_imports = 2
line_length = 100
order_by_type = false

# length_sort = true
# case_sensitive: False
# force_sort_within_sections: True
# reverse_relative: True
# sort_relative_in_force_sorted_sections: True
4 changes: 3 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@

# Package meta-data.
NAME = "flasc"
DESCRIPTION = "FLASC provides a rich suite of analysis tools for SCADA data filtering & analysis, wind farm model validation, field experiment design, and field experiment monitoring."
DESCRIPTION = "FLASC provides a rich suite of analysis tools for SCADA data filtering" \
" & analysis, wind farm model validation, field experiment design, and " \
" field experiment monitoring."
URL = "https://github.com/NREL/flasc"
EMAIL = "paul.fleming@nrel.gov"
AUTHOR = "NREL National Wind Technology Center"
Expand Down