Skip to content
Open
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
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
exclude: configure|\.*.msh|\.*.rng|^h5hut/\.*|^libjudy\.*|^libmba2d\.*|^libmba3d\.*|^libspud\.*|^spatialindex-1.8.0\.*
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: check-ast
- id: check-builtin-literals
Expand All @@ -19,21 +19,21 @@ repos:
- id: mixed-line-ending
exclude: ref_vtk_hexahedra.vtu
- id: trailing-whitespace
- repo: https://github.com/psf/black
rev: 23.3.0
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 26.1.0
hooks:
- id: black
- repo: https://github.com/PyCQA/isort
rev: 5.12.0
rev: 7.0.0
hooks:
- id: isort
args: ["--profile", "black", "--filter-files"]
- repo: https://github.com/asottile/pyupgrade
rev: v3.6.0
rev: v3.21.2
hooks:
- id: pyupgrade
- repo: https://github.com/PyCQA/flake8
rev: 6.0.0
rev: 7.3.0
hooks:
- id: flake8
args: ["--max-line-length", "88", "--extend-ignore", "E203,E722"]
12 changes: 6 additions & 6 deletions examples/driven_cavity/driven_cavity.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def erturk_u(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][0]
Expand Down Expand Up @@ -217,7 +217,7 @@ def erturk_v(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][1]
Expand Down Expand Up @@ -269,7 +269,7 @@ def botella_u(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
norm = 0.0
for i in range(ilen):
diff = pts[i][3] - velocity[i][0]
Expand Down Expand Up @@ -320,7 +320,7 @@ def botella_v(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape

norm = 0.0
for i in range(ilen):
Expand Down Expand Up @@ -372,7 +372,7 @@ def botella_p1(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
pressure = u.ProbeData(pts, "Pressure")

pts0 = np.array(
Expand Down Expand Up @@ -430,7 +430,7 @@ def botella_p2(NN):
)

velocity = u.ProbeData(pts, "Velocity")
(ilen, jlen) = velocity.shape
ilen, jlen = velocity.shape
pressure = u.ProbeData(pts, "Pressure")

pts0 = np.array(
Expand Down
2 changes: 1 addition & 1 deletion examples/driven_cavity/generate_mesh
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ optparser = OptionParser(
description="""Generate the mesh files for a given resolution.""",
)

(options, argv) = optparser.parse_args()
options, argv = optparser.parse_args()

try:
NN = int(argv[0])
Expand Down
6 changes: 2 additions & 4 deletions examples/driven_cavity/plot_data
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import pylab


def usage():
print(
"""plot_data <NN>
print("""plot_data <NN>

<NN> is a space-separated list of the inverse mesh spacing."""
)
<NN> is a space-separated list of the inverse mesh spacing.""")


try:
Expand Down
12 changes: 4 additions & 8 deletions examples/lock_exchange/plot_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,10 @@
def Froudenumber(flmlname):
print("\n********** Calculating the Froude number\n")
# warn user about assumptions
print(
"""Froude number calculations makes three assumptions:
print("""Froude number calculations makes three assumptions:
i) domain height = 0.1m
ii) mid point domain is at x = 0.4
iii) initial temperature difference is 1.0 degC"""
)
iii) initial temperature difference is 1.0 degC""")
domainheight = 0.1
domainmid = 0.4
rho_zero, T_zero, alpha, g = le_tools.Getconstantsfromflml(flmlname)
Expand Down Expand Up @@ -184,11 +182,9 @@ def Froudenumber(flmlname):
def mixing(flmlname):
print("\n********** Calculating the mixing diagnostics\n")
# warn user about assumptions
print(
"""Background potential energy calculations makes two assumptions:
print("""Background potential energy calculations makes two assumptions:
i) domain height = 0.1m
ii) initial temperature difference is 1.0 degC"""
)
ii) initial temperature difference is 1.0 degC""")
domainheight = 0.1
rho_zero, T_zero, alpha, g = le_tools.Getconstantsfromflml(flmlname)

Expand Down
6 changes: 2 additions & 4 deletions examples/rotating_channel/plot_data
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,9 @@ import pylab


def usage():
print(
"""plot_data <layers>
print("""plot_data <layers>

<layers> is a space-separated list of layer counts."""
)
<layers> is a space-separated list of layer counts.""")


try:
Expand Down
2 changes: 1 addition & 1 deletion examples/tides_in_the_Mediterranean_Sea/Med-tides-probe.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@
)

M2amp = u.ProbeData(pts, "M2amp")
(ilen, jlen) = M2amp.shape
ilen, jlen = M2amp.shape
S2amp = u.ProbeData(pts, "S2amp")
K1amp = u.ProbeData(pts, "K1amp")
O1amp = u.ProbeData(pts, "O1amp")
Expand Down
6 changes: 2 additions & 4 deletions examples/top_hat/visualise.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,9 @@
try:
import vtktools
except ImportError:
sys.stderr.write(
"""You need to add the path to <FLUIDITY_SOURCE_LOCATION>/python/
sys.stderr.write("""You need to add the path to <FLUIDITY_SOURCE_LOCATION>/python/
to your PYTHONPATH environment variable, e.g.:
export PYTHONPATH=$PYTHONPATH:$HOME/svn/fluidity/python/\n"""
)
export PYTHONPATH=$PYTHONPATH:$HOME/svn/fluidity/python/\n""")
sys.exit(1)

# open one of the vtus output by fluidity
Expand Down
6 changes: 3 additions & 3 deletions mayavi/mayavi_amcg/filters/boundary_marker_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -193,9 +193,9 @@ def perform_mask(self):
# value is the new cell_id of the corresponding cell in the masked grid
self._cell_mappings = list(
map(
lambda masked, cell_id: None
if masked
else unmasked_cells_list.insert_next_id(cell_id),
lambda masked, cell_id: (
None if masked else unmasked_cells_list.insert_next_id(cell_id)
),
in_masked,
cell_ids,
)
Expand Down
1 change: 1 addition & 0 deletions mayavi/mayavi_amcg/filters/data_set_clipper.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Wouldn't have been able to code this otherwise.

"""

from traits.api import Button, Instance
from traitsui.api import Group, Item, View
from tvtk.api import tvtk
Expand Down
6 changes: 2 additions & 4 deletions mayavi/mayavi_amcg/filters/field_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,12 @@ class FieldOperations(Filter):
"z-component",
"Python function",
)
custom_function = Code(
"""
custom_function = Code("""
# Define a single-line operation in terms of
# the variable 'inputs' which is an array of
# input arrays. math and numpy are imported.
# The operation must return a single array.
"""
)
""")

# Input and output fields
scale_factor = Float(1.0)
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/annulus_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Annulus meshing tools
"""

import copy
import math
import unittest
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/bounds.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Geometric bounds utilities
"""

import unittest

import fluidity.diagnostics.calc as calc
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/elements.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Finite element element classes
"""

import unittest

import fluidity.diagnostics.debug as debug
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/era.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
ERA data set handling routines
"""

import datetime
import os
import unittest
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Event handling tools
"""

import unittest


Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/filehandling.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
File handling routines
"""

import glob
import os
import shutil
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/fluiditytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Fluidity related tools
"""

import glob
import os
import subprocess
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/gidtools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Tools for dealing with GiD files
"""

import copy
import os
import tempfile
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/mesh_halos.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
Finite element halo classes
"""

import os
import tempfile
import unittest
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/meshes.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Finite element mesh classes
"""

import unittest

import fluidity.diagnostics.bounds as bounds
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Routines concerning dimensionless numbers
"""

import math
import unittest

Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/polytools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Tools for dealing with .poly files.
"""

import copy
import os
import subprocess
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/simplices.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"""
Tools for dealing with tetrahedra
"""

import unittest

import fluidity.diagnostics.calc as calc
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/structured_fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Structured field classes
"""

import copy
import math
import unittest
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/triangletools.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Tools for dealing with triangle files
"""

import os
import sys
import tempfile
Expand Down
1 change: 1 addition & 0 deletions python/fluidity/diagnostics/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
"""
Some useful utility functions
"""

import copy
import time
import unittest
Expand Down
15 changes: 3 additions & 12 deletions python/fluidity/ocean_biology.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@ def pznd(state, parameters):
G_P = (g * p_P * P_n**2 * Z_n) / (k**2 + p_P * P_n**2 + p_D * D_n**2)

# Zooplankton grazing of detritus.
G_D = (g * (1 - p_P) * D_n**2 * Z_n) / (
k**2 + p_P * P_n**2 + p_D * D_n**2
)
G_D = (g * (1 - p_P) * D_n**2 * Z_n) / (k**2 + p_P * P_n**2 + p_D * D_n**2)

# Death rate of phytoplankton.
De_P = mu_P * P_n * P_n / (P_n + 0.2)
Expand Down Expand Up @@ -327,12 +325,7 @@ def six_component(state, parameters):

# Chl growth scaling factor
# R_P=(theta_m/theta)*J*(Q_N+Q_A)/(alpha*I_n+1e-7)
R_P = (
(theta_m / theta)
* (Q_N + Q_A)
* v
/ (v**2 + alpha**2 * I_n**2) ** 0.5
)
R_P = (theta_m / theta) * (Q_N + Q_A) * v / (v**2 + alpha**2 * I_n**2) ** 0.5

# Primary production
X_P = J * (Q_N + Q_A) * P_n
Expand All @@ -350,9 +343,7 @@ def six_component(state, parameters):
# G_D = (g * epsilon * (1 - p_P) * D_n**2 * Z_n) / (
# g + epsilon * (p_P * P_n**2 + p_D * D_n**2)
# )
G_D = (g * (1 - p_P) * D_n**2 * Z_n) / (
epsilon + (p_P * P_n**2 + p_D * D_n**2)
)
G_D = (g * (1 - p_P) * D_n**2 * Z_n) / (epsilon + (p_P * P_n**2 + p_D * D_n**2))

# Death rate of phytoplankton.
# There is an additional linear term because we have a unified model
Expand Down
Loading
Loading