Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
nschloe committed Jan 31, 2024
1 parent 7574b19 commit 1e38ba0
Show file tree
Hide file tree
Showing 33 changed files with 61 additions and 23 deletions.
10 changes: 5 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out repo
uses: actions/checkout@v2
uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v5
- name: Run pre-commit
uses: pre-commit/action@v2.0.3
uses: pre-commit/action@v3.0.0

build:
needs: [lint]
Expand All @@ -27,7 +27,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macOS-latest]
python-version: ["3.7", "3.8", "3.9", "3.10"]
steps:
- uses: actions/setup-python@v2
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Checkout code
Expand All @@ -36,5 +36,5 @@ jobs:
run: |
pip install tox
tox -- --cov meshio --cov-report xml --cov-report term
- uses: codecov/codecov-action@v1
- uses: codecov/codecov-action@v3
if: ${{ matrix.python-version == '3.10' && matrix.os == 'ubuntu-latest' }}
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
repos:
- repo: https://github.com/PyCQA/isort
rev: 5.10.1
rev: 5.13.2
hooks:
- id: isort

- repo: https://github.com/psf/black
rev: 22.1.0
rev: 24.1.1
hooks:
- id: black
language_version: python3

- repo: https://github.com/PyCQA/flake8
rev: 4.0.1
rev: 7.0.0
hooks:
- id: flake8
2 changes: 1 addition & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version := `python3 -c "from configparser import ConfigParser; p = ConfigParser(); p.read('setup.cfg'); print(p['metadata']['version'])"`
version := `python -c "import tomllib; print(tomllib.load(open('pyproject.toml', 'rb'))['project']['version'])"`

default:
@echo "\"just publish\"?"
Expand Down
1 change: 1 addition & 0 deletions src/meshio/abaqus/_abaqus.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
I/O for Abaqus inp files.
"""

import pathlib
from itertools import count

Expand Down
1 change: 1 addition & 0 deletions src/meshio/ansys/_ansys.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<https://romeo.univ-reims.fr/documents/fluent/tgrid/ug/appb.pdf>
"""

import re

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/avsucd/_avsucd.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for AVS-UCD format, cf.
<https://lanl.github.io/LaGriT/pages/docs/read_avs.html>.
"""

import numpy as np

from ..__about__ import __version__ as version
Expand Down
1 change: 1 addition & 0 deletions src/meshio/cgns/_cgns.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
TODO link to specification?
"""

import numpy as np

from .._exceptions import ReadError
Expand Down
1 change: 1 addition & 0 deletions src/meshio/dolfin/_dolfin.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for DOLFIN's XML format, cf.
<https://people.sc.fsu.edu/~jburkardt/data/dolfin_xml/dolfin_xml.html>.
"""

import os
import pathlib
import re
Expand Down
1 change: 1 addition & 0 deletions src/meshio/exodus/_exodus.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
<https://src.fedoraproject.org/repo/pkgs/exodusii/922137.pdf/a45d67f4a1a8762bcf66af2ec6eb35f9/922137.pdf>,
in particular Appendix A (page 171, Implementation of EXODUS II with netCDF).
"""

import datetime
import re

Expand Down
2 changes: 2 additions & 0 deletions src/meshio/flac3d/_flac3d.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
I/O for FLAC3D format.
"""

from __future__ import annotations

import re
Expand Down Expand Up @@ -534,6 +535,7 @@ def _translate_zcells(points, cells):
normal vectors). Reorder corner points according to sign of scalar triple
products.
"""

# See <https://stackoverflow.com/a/42386330/353337>
def slicing_summing(a, b, c):
c0 = b[:, 1] * c[:, 2] - b[:, 2] * c[:, 1]
Expand Down
1 change: 1 addition & 0 deletions src/meshio/gmsh/_gmsh22.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for Gmsh's msh format, cf.
<http://gmsh.info//doc/texinfo/gmsh.html#File-formats>.
"""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/gmsh/_gmsh40.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for Gmsh's msh format (version 4.0, as used by Gmsh 4.1.5), cf.
<http://gmsh.info//doc/texinfo/gmsh.html#MSH-file-format-_0028version-4_0029>.
"""

from __future__ import annotations

from functools import partial
Expand Down
17 changes: 10 additions & 7 deletions src/meshio/gmsh/_gmsh41.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for Gmsh's msh format (version 4.1, as used by Gmsh 4.2.2+), cf.
<http://gmsh.info/doc/texinfo/gmsh.html#MSH-file-format>.
"""

from functools import partial

import numpy as np
Expand Down Expand Up @@ -209,13 +210,15 @@ def _read_elements(
(num_ele,) = fromfile(f, c_size_t, 1)
for physical_name, cell_set in cell_sets.items():
cell_set[k] = np.arange(
num_ele
if (
physical_tags
and field_data[physical_name][1] == dim
and field_data[physical_name][0] in physical_tags[dim][tag]
)
else 0,
(
num_ele
if (
physical_tags
and field_data[physical_name][1] == dim
and field_data[physical_name][0] in physical_tags[dim][tag]
)
else 0
),
dtype=type(num_ele),
)
tpe = _gmsh_to_meshio_type[type_ele]
Expand Down
1 change: 1 addition & 0 deletions src/meshio/h5m/_h5m.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for h5m, cf.
<https://www.mcs.anl.gov/~fathom/moab-docs/html/h5mmain.html>.
"""

from datetime import datetime

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/mdpa/_mdpa.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
The MDPA format is unsuitable for fast consumption, this is why:
<https://github.com/KratosMultiphysics/Kratos/issues/5365>.
"""

import numpy as np

from .._common import num_nodes_per_cell, raw_from_cell_data, warn
Expand Down
1 change: 1 addition & 0 deletions src/meshio/med/_med.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for MED/Salome, cf.
<https://docs.salome-platform.org/latest/dev/MEDCoupling/developer/med-file.html>.
"""

import numpy as np

from .._common import num_nodes_per_cell
Expand Down
1 change: 1 addition & 0 deletions src/meshio/medit/_medit.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Latest official up-to-date documentation and a reference C implementation at
<https://github.com/LoicMarechal/libMeshb>
"""

import struct
from ctypes import c_double, c_float

Expand Down
1 change: 1 addition & 0 deletions src/meshio/nastran/_nastran.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
I/O for Nastran bulk data.
"""

from __future__ import annotations

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/netgen/_netgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for Netgen mesh files
<https://github.com/NGSolve/netgen/blob/master/libsrc/meshing/meshclass.cpp>.
"""

import numpy as np

from ..__about__ import __version__
Expand Down
6 changes: 5 additions & 1 deletion src/meshio/neuroglancer/_neuroglancer.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
Adapted from https://github.com/HumanBrainProject/neuroglancer-scripts/blob/1fcabb613a715ba17c65d52596dec3d687ca3318/src/neuroglancer_scripts/mesh.py (MIT license)
"""

import struct

import numpy as np
Expand Down Expand Up @@ -57,7 +58,10 @@ def read_buffer(file):
if len(buf) != 4 * 3 * num_vertices:
raise ReadError("The precomputed mesh data is too short")
flat_vertices = np.frombuffer(buf, "<f")
vertices = np.reshape(flat_vertices, (num_vertices, 3),).copy(
vertices = np.reshape(
flat_vertices,
(num_vertices, 3),
).copy(
order="C"
) # TODO remove copy
# BUG: this could easily exhaust memory if reading a large file that is not
Expand Down
1 change: 1 addition & 0 deletions src/meshio/obj/_obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for the Wavefront .obj file format, cf.
<https://en.wikipedia.org/wiki/Wavefront_.obj_file>.
"""

import datetime

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/off/_off.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<https://en.wikipedia.org/wiki/OFF_(file_format)>,
<http://www.geomview.org/docs/html/OFF.html>.
"""

import numpy as np

from .._common import warn
Expand Down
1 change: 1 addition & 0 deletions src/meshio/permas/_permas.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
I/O for PERMAS dat files.
"""

import numpy as np

from ..__about__ import __version__
Expand Down
15 changes: 9 additions & 6 deletions src/meshio/ply/_ply.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<https://en.wikipedia.org/wiki/PLY_(file_format)>.
<https://web.archive.org/web/20161221115231/http://www.cs.virginia.edu/~gfx/Courses/2001/Advanced.spring.01/plylib/Ply.txt>.
"""

import collections
import datetime
import re
Expand Down Expand Up @@ -296,11 +297,13 @@ def _read_binary(
# Convert strings to proper numpy dtypes
dts = [
(
endianness + ply_to_numpy_dtype_string[dtype[0]],
endianness + ply_to_numpy_dtype_string[dtype[1]],
(
endianness + ply_to_numpy_dtype_string[dtype[0]],
endianness + ply_to_numpy_dtype_string[dtype[1]],
)
if isinstance(dtype, tuple)
else endianness + ply_to_numpy_dtype_string[dtype]
)
if isinstance(dtype, tuple)
else endianness + ply_to_numpy_dtype_string[dtype]
for dtype in cell_data_dtypes
]

Expand All @@ -311,7 +314,7 @@ def _read_binary(
buffer_position = 0

cell_data = {}
for (name, dt) in zip(cell_data_names, dts):
for name, dt in zip(cell_data_names, dts):
if isinstance(dt, tuple):
buffer_increment, cell_data[name] = _read_binary_list(
buffer[buffer_position:], dt[0], dt[1], num_cells, endianness
Expand Down Expand Up @@ -370,7 +373,7 @@ def parse_ragged(start, num_cells):
# `block_dtype` to include the initial counts in each row avoids any
# wasteful copy operations.
blocks = []
for (start, end) in block_bounds:
for start, end in block_bounds:
if start == end:
# This should only happen if the element was empty to begin with.
continue
Expand Down
1 change: 1 addition & 0 deletions src/meshio/stl/_stl.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for the STL format, cf.
<https://en.wikipedia.org/wiki/STL_(file_format)>.
"""

from __future__ import annotations

import os
Expand Down
1 change: 1 addition & 0 deletions src/meshio/su2/_su2.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O SU2 mesh format
<https://su2code.github.io/docs_v7/Mesh-File/>
"""

from itertools import chain, islice

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/tecplot/_tecplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<https://github.com/su2code/SU2/raw/master/externals/tecio/360_data_format_guide.pdf>,
<http://paulbourke.net/dataformats/tp/>.
"""

import numpy as np

from ..__about__ import __version__ as version
Expand Down
1 change: 1 addition & 0 deletions src/meshio/tetgen/_tetgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for the TetGen file format, c.f.
<https://wias-berlin.de/software/tetgen/fformats.node.html>
"""

import pathlib

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/ugrid/_ugrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
Node ordering described in
[3] <https://www.simcenter.msstate.edu/software/documentation/ug_io/3d_input_output_grids.html>
"""

import numpy as np

from .._common import _pick_first_int_data, warn
Expand Down
1 change: 1 addition & 0 deletions src/meshio/vtk/_vtk_42.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"""
I/O for VTK <https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf>.
"""

from functools import reduce

import numpy as np
Expand Down
1 change: 1 addition & 0 deletions src/meshio/vtu/_vtu.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<https://vtk.org/Wiki/VTK_XML_Formats>
<https://vtk.org/wp-content/uploads/2015/04/file-formats.pdf>
"""

import base64
import re
import sys
Expand Down
1 change: 1 addition & 0 deletions src/meshio/xdmf/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for XDMF.
https://xdmf.org/index.php/XDMF_Model_and_Format
"""

from .main import read, write
from .time_series import TimeSeriesReader, TimeSeriesWriter

Expand Down
1 change: 1 addition & 0 deletions src/meshio/xdmf/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
I/O for XDMF.
https://xdmf.org/index.php/XDMF_Model_and_Format
"""

import os
import pathlib
from io import BytesIO
Expand Down

0 comments on commit 1e38ba0

Please sign in to comment.