Skip to content

Commit

Permalink
pass black
Browse files Browse the repository at this point in the history
  • Loading branch information
hovey committed Dec 17, 2024
1 parent adac4a7 commit f687952
Show file tree
Hide file tree
Showing 29 changed files with 68 additions and 32 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/blacktest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ jobs:
python -m pip install --upgrade pip
# pip install black
# pip install black==21.10b0 # specify version 21.10b0 exactly
pip install black==22.3.0
# pip install black==22.3.0
pip install black
pip install flake8
- name: Test with Black
run: |
Expand Down
10 changes: 9 additions & 1 deletion cli/io/example/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,19 @@ Given a comma separated values (`.csv`) file, plot columns with `xyfigure`

## Getting Started

Create a virtual environment:

```sh
cd ~/sibl
python -m venv .venv
```

Activate the virtual environment:

```sh
cd ~/sibl/cli
source ~/sibl/.venv/bin/activate
cd ~/sibl/cli
pip install -e .
```

## Example 1
Expand Down
1 change: 0 additions & 1 deletion cli/process/exodus/visualization.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
> python visualization.py
"""


import os

import numpy as np
Expand Down
2 changes: 0 additions & 2 deletions cli/process/tpav/test_three_points_angular_velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def test_t0_t1(self):

@unittest.expectedFailure
def test_t0_insufficient_rank_omega_perpendicular(self):

"""
This function tests a single time step input with a rank-insufficient
configuration space (rOR gets set to rOQ, which fails to span R3).
Expand Down Expand Up @@ -353,7 +352,6 @@ def test_t0_insufficient_rank_omega_perpendicular(self):

@unittest.expectedFailure
def test_t0_insufficient_rank_omega_parallel(self):

"""
This function tests a single time step input with a rank-insufficient
configuration space (rOR gets set to rOQ, which fails to span R3).
Expand Down
2 changes: 1 addition & 1 deletion cli/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ classifiers = [
"Operating System :: OS Independent",
]
dependencies = [
"black==22.6.0", "flake8", "matplotlib", "pytest", "pytest-cov", "pyyaml", "scipy"
"black", "flake8", "matplotlib", "pytest", "pytest-cov", "pyyaml", "scipy"
]

# Entry Points
Expand Down
4 changes: 3 additions & 1 deletion cli/src/xyfigure/xymodel.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,9 @@ def __init__(self, guid, **kwargs):
]
),
)
except IndexError: # handle 2D input files, append 0.0 as z coordinate
except (
IndexError
): # handle 2D input files, append 0.0 as z coordinate
new_nodes = (
tuple(
[
Expand Down
4 changes: 4 additions & 0 deletions cli/src/xyfigure/xytypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

class Kwargs(NamedTuple):
"""The keyword arguments, kwargs, forwarded to Matplotlib."""

alpha: float = 0.5
color: str = "blue"
label: str = "label"
Expand All @@ -17,6 +18,7 @@ class Kwargs(NamedTuple):

class Model(NamedTuple):
"""The basic ingredients to create a single (x, y) trace."""

folder: Path
file: Path
plot_kwargs: Kwargs
Expand All @@ -26,13 +28,15 @@ class Model(NamedTuple):

class RhsAxis(NamedTuple):
"""The constituents of a right hand side vertical axis."""

scale: float
label: str
yticks: list[float] | None


class View(NamedTuple):
"""The plot on which the models are placed."""

folder: Path
file: Path
size: list[float]
Expand Down
1 change: 1 addition & 0 deletions cli/tests/img_same_diff/image_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Typical use case:
$ python image_diff.py image_a image_b
"""

# https://www.python.org/dev/peps/pep-0008/#imports
# standard library imports
import sys
Expand Down
1 change: 1 addition & 0 deletions cli/tests/img_same_diff/test_image_diff.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
$ python -m unittest -v test_image_diff.py # for higher verbosity
"""

# https://www.python.org/dev/peps/pep-0008/#imports
# standard library imports
from unittest import TestCase, main
Expand Down
1 change: 1 addition & 0 deletions cli/tests/service/xyfigure_deprecatedtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
# e.g., to test the test_same() method
$ python -m unittest xyfigure_test.TestImageDiff.test_same
"""

# https://www.python.org/dev/peps/pep-0008/#imports
# standard library imports
import os
Expand Down
2 changes: 0 additions & 2 deletions cli/tests/tpav/test_three_points_angular_velocity.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,6 @@ def test_t0_t1(self):

@unittest.expectedFailure
def test_t0_insufficient_rank_omega_perpendicular(self):

"""
This function tests a single time step input with a rank-insufficient
configuration space (rOR gets set to rOQ, which fails to span R3).
Expand Down Expand Up @@ -353,7 +352,6 @@ def test_t0_insufficient_rank_omega_perpendicular(self):

@unittest.expectedFailure
def test_t0_insufficient_rank_omega_parallel(self):

"""
This function tests a single time step input with a rank-insufficient
configuration space (rOR gets set to rOQ, which fails to span R3).
Expand Down
1 change: 1 addition & 0 deletions geo/doc/dual/lesson_21_deprecated.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# update lesson_21.py as needed
> python lesson_21.py
"""

import math
from pathlib import Path
from typing import Final
Expand Down
1 change: 1 addition & 0 deletions geo/doc/plot_voronoi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
> conda activate siblenv
> python plot_voronoi.py
"""

# import argparse
import numpy as np
import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions geo/doc/snakes_baseline.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
1. Snakes: Active contour models. Kass, M.; Witkin, A.; Terzopoulos, D. International Journal of Computer Vision 1 (4): 321 (1988). DOI:10.1007/BF00133570
"""

from pathlib import Path

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions geo/examples/bspline_surface_Bezier_recovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
> conda activate siblenv
> python bspline_surface_Bezier_recovery.py
"""

import numpy as np
import matplotlib.pyplot as plt
from matplotlib import rc
Expand Down
1 change: 1 addition & 0 deletions geo/examples/quadtree_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
> cd ~/sibl/geo/examples
> python quadtree_example.py
"""

from pathlib import Path

import matplotlib.pyplot as plt
Expand Down
1 change: 1 addition & 0 deletions geo/src/post/benchmark.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
# update benchmark.py as needed
> python benchmark.py
"""

# from itertools import repeat
import math
from pathlib import Path
Expand Down
4 changes: 2 additions & 2 deletions geo/src/ptg/bspline_basis_manual.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ def bspline_basis_manual(
print(f"f(t) = {f_of_t}")

if p == 1:
for (eix, te) in enumerate(t): # e for evaluations, ix for index
for eix, te in enumerate(t): # e for evaluations, ix for index
if te >= knot_vector_t[knot_i] and te < knot_vector_t[knot_i + 1]:
f_of_t[eix] = (te - knot_vector_t[knot_i]) / (
knot_vector_t[knot_i + 1] - knot_vector_t[knot_i]
Expand All @@ -121,7 +121,7 @@ def bspline_basis_manual(
)

if p == 2:
for (eix, te) in enumerate(t): # e for evaluations, ix for index
for eix, te in enumerate(t): # e for evaluations, ix for index
if te >= knot_vector_t[knot_i] and te < knot_vector_t[knot_i + 1]:

a_1 = (te - knot_vector_t[knot_i]) / (
Expand Down
4 changes: 3 additions & 1 deletion geo/src/ptg/copyright.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@


def text_block() -> str:
copyright_text: Final = "# Copyright 2020 National Technology and Engineering Solutions of Sandia, LLC (NTESS).\n# Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains\n# certain rights in this software.\n"
copyright_text: Final = (
"# Copyright 2020 National Technology and Engineering Solutions of Sandia, LLC (NTESS).\n# Under the terms of Contract DE-NA0003525 with NTESS, the U.S. Government retains\n# certain rights in this software.\n"
)
return copyright_text


Expand Down
32 changes: 20 additions & 12 deletions geo/src/ptg/domain_merge.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,18 +195,22 @@ def domain_merge(
# renumber faces to global numbering scheme
faces0 = tuple(
tuple(
domain0.mesh.connectivity[i][j] + nnp0
if domain0.mesh.connectivity[i][j] < 0
else domain0.mesh.connectivity[i][j]
(
domain0.mesh.connectivity[i][j] + nnp0
if domain0.mesh.connectivity[i][j] < 0
else domain0.mesh.connectivity[i][j]
)
for j in range(0, nen0)
)
for i in range(0, n_faces0)
)
faces1 = tuple(
tuple(
domain1.mesh.connectivity[i][j] + nnp1 + nnp0
if domain1.mesh.connectivity[i][j] < 0
else domain1.mesh.connectivity[i][j] + nnp0
(
domain1.mesh.connectivity[i][j] + nnp1 + nnp0
if domain1.mesh.connectivity[i][j] < 0
else domain1.mesh.connectivity[i][j] + nnp0
)
for j in range(0, nen1)
)
for i in range(0, n_faces1)
Expand All @@ -215,18 +219,22 @@ def domain_merge(
# renumber boundaries to global numbering scheme
bounds0 = tuple(
tuple(
domain0.boundaries[i][j] + nnp0
if domain0.boundaries[i][j] < 0
else domain0.boundaries[i][j]
(
domain0.boundaries[i][j] + nnp0
if domain0.boundaries[i][j] < 0
else domain0.boundaries[i][j]
)
for j in range(0, n_pts_per_bound0[i])
)
for i in range(0, n_bound0)
)
bounds1 = tuple(
tuple(
domain1.boundaries[i][j] + nnp1 + nnp0
if domain1.boundaries[i][j] < 0
else domain1.boundaries[i][j] + nnp0
(
domain1.boundaries[i][j] + nnp1 + nnp0
if domain1.boundaries[i][j] < 0
else domain1.boundaries[i][j] + nnp0
)
for j in range(0, n_pts_per_bound1[i])
)
for i in range(0, n_bound1)
Expand Down
4 changes: 1 addition & 3 deletions geo/src/ptg/modified_bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,9 +168,7 @@ def modified_bezier(
N0 = np.array(tuple(map(lambda t: 0.5 * (1.0 - t) ** 2, t))) # $\hat{N}_0$
N1 = np.array(
tuple(
map(
lambda t: 0.5 * (1.0 - t) ** 2 + 2 * (1.0 - t) * t + 0.5 * t**2, t
)
map(lambda t: 0.5 * (1.0 - t) ** 2 + 2 * (1.0 - t) * t + 0.5 * t**2, t)
)
) # $\hat{N}_1$
N2 = np.array(tuple(map(lambda t: 0.5 * t**2, t))) # $\hat{N}_2$
Expand Down
8 changes: 5 additions & 3 deletions geo/src/ptg/quadtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -687,9 +687,11 @@ def _domain_dual(
n_subquads_per_quad: Final = 4 # given transition from level -> level + 1
quad_levels_recursive_parent = tuple(
(
(level + 1,)
if x == 1
else tuple(repeat((level + 2,), n_subquads_per_quad))
(
(level + 1,)
if x == 1
else tuple(repeat((level + 2,), n_subquads_per_quad))
)
for x in n_parent_quads
)
)
Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
$ cd ~/sibl
$ pytest geo/tests/test_bspline.py -v
"""

from unittest import TestCase, main
import pytest
import numpy as np
Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
For flake8:
flake8 --ignore E203,E501,W503 geo/tests/test_mesh.py --statistics
"""

from math import isinf, isnan
from pathlib import Path

Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_mesh_morph.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
For flake8:
flake8 --ignore E203,E501,W503 geo/tests/test_mesh_morph.py --statistics
"""

import numpy as np

import ptg.mesh_morph as morph
Expand Down
5 changes: 3 additions & 2 deletions geo/tests/test_translator.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
For flake8:
flake8 --ignore E203,E501,W503 geo/tests/test_translator.py --statistics
"""

from pathlib import Path

import pytest
Expand All @@ -38,7 +39,7 @@ def test_string_to_vertex():
translator.MeshFileVertex(x=-0.51, y=-0.87, z=-0.08, face_id=42),
translator.MeshFileVertex(x=-0.55, y=-0.88, z=-0.09, face_id=12),
)
for (x, y) in zip(xs, ys):
for x, y in zip(xs, ys):
fx = translator.string_to_vertex(vertex_string=x)
assert y == fx

Expand Down Expand Up @@ -95,7 +96,7 @@ def test_string_to_hexahedron():
translator.MeshFileHexahedron(nodes=(2, 3, 6, 5, 11, 12, 15, 14), vol_id=1),
translator.MeshFileHexahedron(nodes=(4, 5, 8, 7, 13, 14, 17, 16), vol_id=1),
)
for (x, y) in zip(xs, ys):
for x, y in zip(xs, ys):
fx = translator.string_to_hexahedron(hex_string=x)
assert y == fx

Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_view_bernstein_surface.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$ pytest geo/tests/test_view_bernstein_surface.py -v
$ pytest geo/tests/test_view_bernstein_surface.py -v --cov=geo/src/ptg --cov-report term-missing
"""

from unittest import TestCase, main

import ptg.view_bernstein_surface as bsurf
Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_view_bezier.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$ pytest geo/tests/test_view_bezier.py -v
$ pytest geo/tests/test_view_bezier.py -v --cov=geo/src/ptg --cov-report term-missing
"""

# import runpy
# import sys
from pathlib import Path # stop using os.path, use pathlib instead
Expand Down
1 change: 1 addition & 0 deletions geo/tests/test_view_bspline.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
$ pytest geo/tests/test_view_bspline.py -v
$ pytest geo/tests/test_view_bspline.py -v --cov=geo/src/ptg --cov-report term-missing
"""

# import runpy
# import sys
from pathlib import Path # stop using os.path, use pathlib instead
Expand Down

0 comments on commit f687952

Please sign in to comment.