Skip to content

Commit

Permalink
Use black formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
connoramoreno committed Sep 4, 2024
1 parent 13bf0db commit 9cb3464
Showing 1 changed file with 15 additions and 12 deletions.
27 changes: 15 additions & 12 deletions parastell/magnet_coils.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ def _extract_filament_data(self):
y = float(columns[1]) * self.scale
z = float(columns[2]) * self.scale
coords.append([x, y, z])

else:
coords.append(coords[0])
filament_coords.append(np.array(coords))
Expand Down Expand Up @@ -217,10 +217,10 @@ def _cut_magnets(self):
(Internal function not intended to be called externally)
"""
side_length = 1.25 * self.max_radial_distance

toroidal_region = cq.Workplane("XZ")
toroidal_region = toroidal_region.transformed(offset=(
side_length / 2, 0)
toroidal_region = toroidal_region.transformed(
offset=(side_length / 2, 0)
)
toroidal_region = toroidal_region.rect(side_length, side_length)
toroidal_region = toroidal_region.revolve(
Expand All @@ -246,8 +246,11 @@ def build_magnet_coils(self):

self.magnet_coils = [
MagnetCoil(
coords, center_of_mass, self._width, self._thickness,
self.sample_mod
coords,
center_of_mass,
self._width,
self._thickness,
self.sample_mod,
)
for coords, center_of_mass in zip(
self.filament_coords, self.filament_com
Expand Down Expand Up @@ -344,14 +347,14 @@ def coords(self, data):
# Compute tangents
tangents = np.subtract(
np.append(data[1:], [data[1]], axis=0),
np.append([data[-2]], data[0:-1], axis=0)
np.append([data[-2]], data[0:-1], axis=0),
)
tangents = tangents/np.linalg.norm(tangents, axis=1)[:, np.newaxis]
tangents = tangents / np.linalg.norm(tangents, axis=1)[:, np.newaxis]

# Sample filament coordinates and tangents by modifier
self._coords = data[0:-1:self.sample_mod]
self._coords = data[0 : -1 : self.sample_mod]
self._coords = np.append(self._coords, [self._coords[0]], axis=0)
self.tangents = tangents[0:-1:self.sample_mod]
self.tangents = tangents[0 : -1 : self.sample_mod]
self.tangents = np.append(self.tangents, [self.tangents[0]], axis=0)

def create_magnet(self):
Expand Down Expand Up @@ -397,7 +400,7 @@ def create_magnet(self):

coil_edge_coords.append(
[cq.Vector(tuple(pos)) for pos in coil_edge]
)
)

# Append first edge once again
coil_edge_coords.append(coil_edge_coords[0])
Expand Down

0 comments on commit 9cb3464

Please sign in to comment.