Skip to content

Commit

Permalink
flake8
Browse files Browse the repository at this point in the history
  • Loading branch information
Davide-sd committed Dec 26, 2024
1 parent 0c34b86 commit 409d230
Show file tree
Hide file tree
Showing 26 changed files with 14 additions and 79 deletions.
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import panel as pn
from pygasflow.interactive.diagrams.isentropic import IsentropicDiagram
from pygasflow.interactive.diagrams.fanno import FannoDiagram
from pygasflow.interactive.diagrams.rayleigh import RayleighDiagram
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/conical_shock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from bokeh.models import HoverTool
import numpy as np
from pygasflow.interactive.diagrams.shock_base import ShockCommon
from pygasflow.shockwave import (
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/de_laval.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from bokeh.models import (
Range1d, HoverTool, LinearAxis,
)
import numpy as np
import param
import panel as pn
from pygasflow.nozzles import CD_TOP_Nozzle
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/fanno.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from bokeh.models import HoverTool
import itertools
import numpy as np
from pygasflow.interactive.diagrams.flow_base import FlowCommon
from pygasflow.solvers import fanno_solver

Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/gas.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
from bokeh.models import HoverTool, Range1d
from bokeh.plotting import figure
import itertools
import numpy as np
import panel as pn
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/isentropic.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from bokeh.models import HoverTool, Range1d, LinearAxis
import itertools
import numpy as np
import param
from pygasflow.interactive.diagrams.flow_base import FlowCommon
from pygasflow.solvers import isentropic_solver
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/oblique_shock.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
from bokeh.models import HoverTool
import numpy as np
from pygasflow.interactive.diagrams.shock_base import ShockCommon
from pygasflow.shockwave import (
Expand Down
2 changes: 0 additions & 2 deletions pygasflow/interactive/diagrams/pressure_deflection.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
from bokeh.models import (
ColumnDataSource, Arrow, VeeHead, Label, CustomJS, Circle
)
from bokeh.plotting import show as bokeh_show
import itertools
import numpy as np
import panel as pn
Expand Down Expand Up @@ -33,7 +32,6 @@ def _compute_arrows_position(x, y, num_arrows=1, dir=1):
s = s[idx]

arrow_locs = np.linspace(0, 1, num_arrows + 2)[1:-1]
arrows = []
x_start, y_start, x_end, y_end = [], [], [], []
for loc in arrow_locs:
n = np.searchsorted(s, s[-1] * loc)
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/diagrams/rayleigh.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from bokeh.models import HoverTool
import itertools
import numpy as np
from pygasflow.interactive.diagrams.flow_base import FlowCommon
from pygasflow.solvers import rayleigh_solver

Expand Down
8 changes: 0 additions & 8 deletions pygasflow/interactive/diagrams/shock_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,14 @@
from bokeh.models import (
HoverTool,
Range1d,
VeeHead,
Arrow,
LabelSet,
ColumnDataSource,
Line,
Patch,
GlyphRenderer,
)
import itertools
from pygasflow.interactive.diagrams.flow_base import (
CommonParameters,
BasePlot,
BasePlot
)
from numbers import Number
import numpy as np
import panel as pn
import param

Expand Down
3 changes: 0 additions & 3 deletions pygasflow/interactive/pages/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
from io import StringIO
from itertools import product
from bokeh.models.widgets.tables import NumberFormatter
from pygasflow.interactive.diagrams.flow_base import BasePlot
from pygasflow.shockwave import max_theta_from_mach


pn.extension()
Expand Down Expand Up @@ -383,7 +381,6 @@ def compute(self):
)
results[current_key_1] = v1
results[current_key_2] = v2
error_msg = "%s" % err
info.append("ValueError: %s" % err)

results["gamma"] = g * np.ones_like(results["mu"])
Expand Down
3 changes: 0 additions & 3 deletions pygasflow/interactive/pages/conical_shock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import numpy as np
import pandas as pd
import panel as pn
import param
from pygasflow.interactive.diagrams import ConicalShockDiagram
Expand All @@ -11,7 +9,6 @@
)
from pygasflow.shockwave import sonic_point_conical_shock
from pygasflow.solvers import conical_shockwave_solver
from itertools import product


class ConicalShockSection(ShockSection):
Expand Down
11 changes: 2 additions & 9 deletions pygasflow/interactive/pages/de_laval.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
import param
import pandas as pd
import panel as pn
from io import StringIO
from bokeh.models.widgets.tables import NumberFormatter
from pygasflow.solvers import De_Laval_Solver
from pygasflow.nozzles import (
CD_Conical_Nozzle,
Expand All @@ -12,13 +9,9 @@
from pygasflow.nozzles.nozzle_geometry import Nozzle_Geometry
from pygasflow.interactive.pages.base import (
BasePage,
BaseSection,
_get_tab_header_hover_bg
)
from pygasflow.interactive.diagrams.de_laval import (
NozzleDiagram,
DeLavalDiagram
BaseSection
)
from pygasflow.interactive.diagrams.de_laval import DeLavalDiagram


class DeLavalSection(BaseSection):
Expand Down
3 changes: 1 addition & 2 deletions pygasflow/interactive/pages/fanno.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import param
import panel as pn
from pygasflow.solvers import fanno_solver
from pygasflow.interactive.diagrams import FannoDiagram
from pygasflow.interactive.pages.base import (
Expand Down Expand Up @@ -57,7 +56,7 @@ class FannoPage(FlowPage):
"Critical Friction parameter 4fL*/D (subsonic case)": "friction_sub",
"Critical Friction parameter 4fL*/D (supersonic case)": "friction_super",
"Entropy parameter (s*-s)/R (subsonic case)": "entropy_sub",
"Entropy parameter (s*-s)/R (subsonic case)": "entropy_super"
"Entropy parameter (s*-s)/R (supersonic case)": "entropy_super"
},
doc="The input parameter to be used in the fanno computation."
)
Expand Down
17 changes: 2 additions & 15 deletions pygasflow/interactive/pages/gas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import pandas as pd
import panel as pn
import param
from pygasflow.interactive.diagrams import GasDiagram, SonicDiagram
from pygasflow.interactive.diagrams import GasDiagram
from pygasflow.interactive.pages.base import (
BasePage,
BaseSection,
Expand Down Expand Up @@ -181,7 +181,7 @@ def compute(self):
"prs": np.nan,
"ars": np.nan,
"trs": np.nan,
"T": t,
"T": np.nan,
"a": np.nan,
"gamma": g
})
Expand Down Expand Up @@ -339,19 +339,6 @@ def update_inputs_labels_ideal_gas_section(self):
"input_value_5": "287.05",
})

@param.depends(
"input_value_1", "input_value_2", "input_temperature",
watch=True, on_init=True
)
def update_gas_section(self):
self.sections[0].param.update({
"input_parameter_1": self.input_parameter_1[0],
"input_parameter_2": self.input_parameter_1[1],
"input_value_1": _parse_input_string(self.input_value_1),
"input_value_2": _parse_input_string(self.input_value_2),
"input_temperature": _parse_input_string(self.input_temperature),
})

@param.depends(
"input_parameter_1", "input_value_1", "input_value_2",
"input_temperature", "gamma",
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/pages/isentropic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import param
import panel as pn
from pygasflow.solvers import isentropic_solver
from pygasflow.interactive.diagrams import IsentropicDiagram
from pygasflow.interactive.pages.base import (
Expand Down
1 change: 0 additions & 1 deletion pygasflow/interactive/pages/normal_shock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import param
import panel as pn
from pygasflow.solvers import normal_shockwave_solver
from pygasflow.interactive.diagrams import NormalShockDiagram
from pygasflow.interactive.pages.base import (
Expand Down
3 changes: 0 additions & 3 deletions pygasflow/interactive/pages/oblique_shock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import numpy as np
import pandas as pd
import panel as pn
import param
from pygasflow.interactive.diagrams import ObliqueShockDiagram
Expand All @@ -11,7 +9,6 @@
)
from pygasflow.shockwave import sonic_point_oblique_shock
from pygasflow.solvers import shockwave_solver
from itertools import product


class ObliqueShockSection(ShockSection):
Expand Down
3 changes: 1 addition & 2 deletions pygasflow/interactive/pages/rayleigh.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import param
import panel as pn
from pygasflow.solvers import rayleigh_solver
from pygasflow.interactive.diagrams import RayleighDiagram
from pygasflow.interactive.pages.base import (
Expand Down Expand Up @@ -61,7 +60,7 @@ class RayleighPage(FlowPage):
"Critical Total Temperature Ratio T0/T0* (subsonic case)": "total_temperature_sub",
"Critical Total Temperature Ratio T0/T0* (supersonic case)": "total_temperature_super",
"Entropy parameter (s*-s)/R (subsonic case)": "entropy_sub",
"Entropy parameter (s*-s)/R (subsonic case)": "entropy_super"
"Entropy parameter (s*-s)/R (supersonic case)": "entropy_super"
},
doc="The input parameter to be used in the rayleigh computation."
)
Expand Down
1 change: 0 additions & 1 deletion pygasflow/isentropic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
from scipy.optimize import bisect

from pygasflow.utils.roots import apply_bisection
from pygasflow.utils.decorators import check
Expand Down
1 change: 0 additions & 1 deletion pygasflow/nozzles/cd_conical.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import numpy as np
import param
from pygasflow.nozzles.nozzle_geometry import Nozzle_Geometry
from pygasflow.nozzles.utils import (
convergent,
Expand Down
3 changes: 2 additions & 1 deletion pygasflow/nozzles/moc.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,8 @@ def tand(angle):
y[j + 1] = left_runn_chars[j]["y"][i - j]

# add the point of the current left-running characteristic
if i == 0: j = -1
if i == 0:
j = -1
x[j+2:] = left_runn_chars[i]["x"]
y[j+2:] = left_runn_chars[i]["y"]

Expand Down
2 changes: 1 addition & 1 deletion pygasflow/nozzles/rao_parabola_angles.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ def area_ratio_from_Lf_angle(self, Lf=60, **kwargs):
angle = kwargs["theta_e"]
angle_name = "theta_e"
theta_dict = self._theta_e
if angle == None:
if angle is None:
raise ValueError("Either theta_n or theta_e must be given in input.")

# function to compute area ratio given the angle and fractional length
Expand Down
16 changes: 4 additions & 12 deletions pygasflow/shockwave.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import numpy as np
import param
from scipy.optimize import bisect, minimize_scalar, fsolve
from scipy.optimize import bisect, minimize_scalar
from scipy.integrate import solve_ivp

from pygasflow.utils.common import ret_correct_vals
Expand Down Expand Up @@ -649,8 +649,8 @@ def get_upstream_normal_mach_from_ratio(ratioName, ratio, gamma=1.4):
ratioName = ratioName.lower()
if ratioName == "mn2":
warnings.warn(
f"Key 'mn2' is deprecated and will be removed in the future."
f" Use 'mnd' instead.",
"Key 'mn2' is deprecated and will be removed in the future."
" Use 'mnd' instead.",
stacklevel=1
)
ratioName="mnd"
Expand Down Expand Up @@ -976,7 +976,7 @@ def func(beta, M1, gamma):
# TODO: figure it out a better way to skip check and to deal with
# scalar input to functions that requires arrays
theta_sonic[i] = theta_from_mach_beta(m, beta_sonic[i], gamma)
except ValueError as err:
except ValueError:
beta_sonic[i] = np.nan
theta_sonic[i] = np.nan

Expand Down Expand Up @@ -1078,14 +1078,6 @@ def mach_beta_from_theta_ratio(theta, ratio_name, ratio_value, gamma=1.4):
f"`ratio_name` must be one of the following: {allowed_ratios}."
f" Instead, '{ratio_name}' was received.")

func_map = {
'pressure': pressure_ratio,
'temperature': temperature_ratio,
'density': density_ratio,
'total_pressure': total_pressure_ratio
}
ratio_func = func_map[ratio_name]

def func(M1, theta, gamma, Mn_target, region):
beta = beta_from_mach_theta(M1, theta, gamma)[region]
Mn1 = M1 * np.sin(np.deg2rad(beta))
Expand Down
5 changes: 1 addition & 4 deletions pygasflow/solvers/de_laval.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
import param
from numbers import Number
from scipy.optimize import bisect
import matplotlib.pyplot as plt
import matplotlib.patches as patches

import pygasflow.shockwave as shockwave
from pygasflow.isentropic import (
Expand Down Expand Up @@ -337,7 +335,6 @@ def _update_logic(self):
# quantities and find if and where a shockwave is present

Lc = self.nozzle.length_convergent
Ld = self.nozzle.length_divergent

# copy the arrays: we do not want to modify the original nozzle in
# case of shock wave at the exit plane
Expand Down Expand Up @@ -634,7 +631,7 @@ def to_string(n):
def _update_flow_condition(self):
r1, r2, r3 = self.limit_pressure_ratios

if self.Pb_P0_ratio == None:
if self.Pb_P0_ratio is None:
fc = "Undefined"
if np.isclose(self.Pb_P0_ratio, 1):
fc = "No flow"
Expand Down
2 changes: 0 additions & 2 deletions pygasflow/solvers/shockwave.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,10 @@
mach_cone_angle_from_shock_angle,
shock_angle_from_mach_cone_angle,
beta_from_upstream_mach,
theta_from_mach_beta,
mach_beta_from_theta_ratio,
mach_downstream,
)
from pygasflow.utils.common import (
convert_to_ndarray,
ShockResults,
_should_solver_return_dict,
_print_results_helper,
Expand Down

0 comments on commit 409d230

Please sign in to comment.