Skip to content
Merged
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: 3 additions & 2 deletions .github/workflows/build-ubuntu.yml
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,10 @@ jobs:
exit 0
fi
set +x -euo pipefail
sudo apt-get update && sudo apt-get install -y clang-format-14 black
sudo apt-get update && sudo apt-get install -y clang-format-14
python -m pip install ruff==0.6.7
./scripts/format/clang_format.sh
./scripts/format/black.sh
./scripts/format/python.sh
git diff --name-only
git diff --exit-code || (echo "Code formatting failed" && exit 1)

Expand Down
16 changes: 8 additions & 8 deletions doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
master_doc = "index"

# General information about the project.
project = u"COLMAP"
copyright = u"2024, Johannes L. Schoenberger"
project = "COLMAP"
copyright = "2024, Johannes L. Schoenberger"

# The version info for the project you're documenting, acts as replacement for
# |version| and |release|, also used in various other places throughout the
Expand Down Expand Up @@ -202,8 +202,8 @@
(
"index",
"COLMAP.tex",
u"COLMAP Documentation",
u"Johannes L. Schoenberger",
"COLMAP Documentation",
"Johannes L. Schoenberger",
"manual",
),
]
Expand Down Expand Up @@ -237,8 +237,8 @@
(
"index",
"colmap",
u"COLMAP Documentation",
[u"Johannes L. Schoenberger"],
"COLMAP Documentation",
["Johannes L. Schoenberger"],
1,
)
]
Expand All @@ -256,8 +256,8 @@
(
"index",
"COLMAP",
u"COLMAP Documentation",
u"Johannes L. Schoenberger",
"COLMAP Documentation",
"Johannes L. Schoenberger",
"COLMAP",
"Structure-from-Motion and Multi-View Stereo.",
"Miscellaneous",
Expand Down
4 changes: 2 additions & 2 deletions pycolmap/generate_stubs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ FILES="$OUTPUT/pycolmap-stubs/*.pyi"
perl -i -pe's/: ceres::([a-zA-Z]|::)+//g' $FILES
perl -i -pe's/ -> ceres::([a-zA-Z]|::)+:$/:/g' $FILES

$PYTHON_EXEC -m black --line-length 80 $FILES
$PYTHON_EXEC -m isort --profile=black $FILES
COLMAP_DIR=$(dirname $( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd ))
ruff format --config ${COLMAP_DIR}/ruff.toml ${FILES}
3 changes: 1 addition & 2 deletions pycolmap/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ requires = [
"pybind11==2.13.0",
"pybind11_stubgen @ git+https://github.com/sarlinpe/pybind11-stubgen@sarlinpe/fix-2024-08",
"numpy",
"black==24.8.0",
"isort==5.13.2",
"ruff==0.6.7",
]
build-backend = "scikit_build_core.build"

Expand Down
1 change: 1 addition & 0 deletions ruff.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
line-length = 80
12 changes: 6 additions & 6 deletions scripts/format/black.sh → scripts/format/python.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#!/usr/bin/env bash

# This script runs the black Python formatter on the whole repository.
# This script runs the ruff Python formatter on the whole repository.

# Check version
version_string=$(black --version | sed -E 's/^.*(\d+\.\d+-.*).*$/\1/')
expected_version_string='21.12'
version_string=$(ruff --version | sed -E 's/^.*(\d+\.\d+-.*).*$/\1/')
expected_version_string='0.6.7'
if [[ "$version_string" =~ "$expected_version_string" ]]; then
echo "black version '$version_string' matches '$expected_version_string'"
echo "ruff version '$version_string' matches '$expected_version_string'"
else
echo "black version '$version_string' doesn't match '$expected_version_string'"
echo "ruff version '$version_string' doesn't match '$expected_version_string'"
exit 1
fi

Expand All @@ -22,4 +22,4 @@ num_files=$(echo $all_files | wc -w)
echo "Formatting ${num_files} files"

# shellcheck disable=SC2086
black --line-length 80 ${all_files}
ruff format --config ${root_folder}/ruff.toml ${all_files}
6 changes: 2 additions & 4 deletions scripts/python/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

IS_PYTHON3 = sys.version_info[0] >= 3

MAX_IMAGE_ID = 2 ** 31 - 1
MAX_IMAGE_ID = 2**31 - 1

CREATE_CAMERAS_TABLE = """CREATE TABLE IF NOT EXISTS cameras (
camera_id INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL,
Expand All @@ -60,9 +60,7 @@
camera_id INTEGER NOT NULL,
CONSTRAINT image_id_check CHECK(image_id >= 0 and image_id < {}),
FOREIGN KEY(camera_id) REFERENCES cameras(camera_id))
""".format(
MAX_IMAGE_ID
)
""".format(MAX_IMAGE_ID)

CREATE_POSE_PRIORS_TABLE = """CREATE TABLE IF NOT EXISTS pose_priors (
image_id INTEGER PRIMARY KEY NOT NULL,
Expand Down
7 changes: 1 addition & 6 deletions scripts/python/plyfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@

_types_list = []
_types_set = set()
for (_a, _b) in _data_type_relation:
for _a, _b in _data_type_relation:
if _a not in _types_set:
_types_list.append(_a)
_types_set.add(_a)
Expand Down Expand Up @@ -117,7 +117,6 @@ def make2d(array, cols=None, dtype=None):


class PlyParseError(Exception):

"""
Raised when a PLY file cannot be parsed.

Expand Down Expand Up @@ -153,7 +152,6 @@ def __repr__(self):


class PlyData(object):

"""
PLY file header and data.

Expand Down Expand Up @@ -378,7 +376,6 @@ def __repr__(self):


class PlyElement(object):

"""
PLY file element.

Expand Down Expand Up @@ -731,7 +728,6 @@ def __repr__(self):


class PlyProperty(object):

"""
PLY property description. This class is pure metadata; the data
itself is contained in PlyElement instances.
Expand Down Expand Up @@ -830,7 +826,6 @@ def __repr__(self):


class PlyListProperty(PlyProperty):

"""
PLY list property description.

Expand Down