Skip to content

Commit

Permalink
First pass at linting changes based on ruff
Browse files Browse the repository at this point in the history
  • Loading branch information
mprib committed Sep 15, 2024
1 parent 7696946 commit ec978ad
Show file tree
Hide file tree
Showing 79 changed files with 625 additions and 732 deletions.
10 changes: 5 additions & 5 deletions caliscope/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
# default to storing projects in user/__package_name__
USER_SETTINGS = {"recent_projects":[],
"last_project_parent":str(__user_dir__) # default initially to home...this will be where the 'New' folder dialog starts
}
}



with open(__settings_path__, "a") as f:
rtoml.dump(USER_SETTINGS, f)

Expand All @@ -68,9 +68,9 @@
with open(test_file, 'w') as f:
f.write('Test')
print(f"Test file created at: {test_file}")


import os
parent = r'C:\Users\Mac Prible\AppData\Local'
print(os.path.exists(parent))
print(os.listdir(parent))
print(os.listdir(parent))
12 changes: 6 additions & 6 deletions caliscope/calibration/capture_volume/capture_volume.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class CaptureVolume:

def __post__init__():
logger.info("Creating capture volume from estimated camera array and stereotriangulated points...")

def _save(self, directory: Path, descriptor: str = None):
if descriptor is None:
pkl_name = "capture_volume_stage_" + str(self.stage) + ".pkl"
Expand Down Expand Up @@ -80,7 +80,7 @@ def get_rmse_summary(self):
rmse_string+=f" {key: >9}: {round(float(value),2)}\n"

return rmse_string

def get_xy_reprojection_error(self):
vectorized_params = self.get_vectorized_params()
error = xy_reprojection_error(vectorized_params, self)
Expand Down Expand Up @@ -195,7 +195,7 @@ def xy_reprojection_error(current_param_estimates, capture_volume: CaptureVolume
# iterate across cameras...while this injects a loop in the residual function
# it should scale linearly with the number of cameras...a tradeoff for stable
# and explicit calculations...

for port, cam in capture_volume.camera_array.cameras.items():
cam_points = np.where(capture_volume.point_estimates.camera_indices == port)
object_points = points_3d_and_2d[cam_points][:, 1:4]
Expand Down Expand Up @@ -250,9 +250,9 @@ def rms_reproj_error(xy_reproj_error, camera_indices):

# camera_array = get_camera_array(config)
# point_estimates = load_point_estimates(config)
# capture_volume = CaptureVolume(camera_array, point_estimates)

# capture_volume = CaptureVolume(camera_array, point_estimates)
# capture_volume.stage = config["capture_volume"]["stage"]
# # capture_volume.origin_sync_index = config["capture_volume"]["origin_sync_index"]

# return capture_volume
# return capture_volume
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,11 @@ def get_point_estimates(camera_array:CameraArray, point_data_path: Path) -> Poin
data structured in a way that is amenable to bundle adjustment
"""


logger.info("Creating point history object based on camera_array and stereotriangulated_table")
stereotriangulated_points = get_stereotriangulated_table(camera_array, point_data_path)


points_3d_df = get_points_3d_df(stereotriangulated_points)
merged_point_data = get_merged_2d_3d(stereotriangulated_points)

Expand Down
17 changes: 7 additions & 10 deletions caliscope/calibration/capture_volume/point_estimates.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,11 @@
import caliscope.logger
logger = caliscope.logger.get(__name__)

from pathlib import Path

from scipy.sparse import lil_matrix

import pandas as pd
import numpy as np
from dataclasses import dataclass
from caliscope.calibration.capture_volume.helper_functions.get_stereotriangulated_table import get_stereotriangulated_table

CAMERA_PARAM_COUNT = 6 # this will evolve when moving from extrinsic to intrinsic

Expand All @@ -24,7 +21,7 @@ class PointEstimates:
Initialized from triangulated_points.csv to provide the formatting of data required for bundle adjustment
"full" is used here because there is currently a method to filter the data based on reprojection error
Not sure if it will be used going forward, but it remains here if so.
"""
"""

sync_indices: np.ndarray # the sync_index from when the image was taken
camera_indices: np.ndarray # camera id associated with the img point
Expand All @@ -41,7 +38,7 @@ def __post_init__(self):
self.point_id = self.point_id.astype(np.uint16)
self.img = self.img.astype(np.float64)
self.obj_indices = self.obj_indices.astype(np.int32)
self.obj = self.obj.astype(np.float64)
self.obj = self.obj.astype(np.float64)

@property
def n_cameras(self):
Expand Down Expand Up @@ -84,15 +81,15 @@ def update_obj_xyz(self, least_sq_result_x):
Provided with the least_squares estimate of the best fit of model parameters (including camera 6DoF)
parse out the x,y,z object positions and update self.obj
"""

xyz = least_sq_result_x[self.n_cameras * CAMERA_PARAM_COUNT :]
xyz = xyz.reshape(-1, 3)

self.obj = xyz




def load_point_estimates(config:dict)->PointEstimates:
point_estimates_dict = config["point_estimates"]

Expand Down
Loading

0 comments on commit ec978ad

Please sign in to comment.