Skip to content

Commit

Permalink
use Path types everywhere (#30)
Browse files Browse the repository at this point in the history
* use Path types everywhere

* refactor soft edge generation into a function (#31)

* soft edge written as a function (refactored)

* make soft edge function work on copy of the original array and returning and output instead of changing 'in place'

* restructure cli imports (#29)

* restructure cli imports

* refactor soft edge generation into a function (#31)

* soft edge written as a function (refactored)

* make soft edge function work on copy of the original array and returning and output instead of changing 'in place'

* restructure cli imports

* remove redundant imports

---------

Co-authored-by: milesagraham <[email protected]>

* use Path types everywhere

---------

Co-authored-by: milesagraham <[email protected]>
  • Loading branch information
alisterburt and milesagraham authored Jun 5, 2024
1 parent 764147c commit 42bf153
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/ttmask/_cli.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import typer

cli = typer.Typer(name="ttmask")
cli = typer.Typer(name="ttmask")
4 changes: 3 additions & 1 deletion src/ttmask/cone.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import numpy as np
import einops
import typer
Expand All @@ -14,7 +16,7 @@ def cone(
cone_base_diameter: float = typer.Option(...),
soft_edge_width: int = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("cone.mrc"),
output: Path = typer.Option(Path("cone.mrc"))
):
c = sidelength // 2
center = np.array([c, c, c])
Expand Down
4 changes: 3 additions & 1 deletion src/ttmask/cube.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import numpy as np
import einops
import typer
Expand All @@ -13,7 +15,7 @@ def cube(
cube_sidelength: float = typer.Option(...),
soft_edge_width: float = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("cube.mrc"),
output: Path = typer.Option(Path("cube.mrc")),
wall_thickness: float = typer.Option(0),
):
c = sidelength // 2
Expand Down
4 changes: 3 additions & 1 deletion src/ttmask/cuboid.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import numpy as np
import einops
import typer
Expand All @@ -17,7 +19,7 @@ def cuboid(
cuboid_sidelengths: Annotated[Tuple[float, float, float], typer.Option()] = (None, None, None),
soft_edge_width: float = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("cuboid.mrc"),
output: str = typer.Option(Path("cuboid.mrc")),
wall_thickness: float = typer.Option(0),
):
c = sidelength // 2
Expand Down
4 changes: 3 additions & 1 deletion src/ttmask/cylinder.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from pathlib import Path

import numpy as np
import einops
import typer
Expand All @@ -15,7 +17,7 @@ def cylinder(
wall_thickness: float = typer.Option(0),
soft_edge_width: int = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("cylinder.mrc")
output: Path = typer.Option(Path("cylinder.mrc"))
):
cylinder_radius = cylinder_diameter / 2

Expand Down
8 changes: 4 additions & 4 deletions src/ttmask/ellipsoid.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
from pathlib import Path

import numpy as np
import einops
import typer
import mrcfile
from .soft_edge import add_soft_edge

from ._cli import cli

from .soft_edge import add_soft_edge
from ._cli import cli


Expand All @@ -17,7 +17,7 @@ def ellipsoid(
depth: float = typer.Option(...),
soft_edge_width: int = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("ellipsoid.mrc"),
output: Path = typer.Option(Path("ellipsoid.mrc")),
wall_thickness: float = typer.Option(0),
):
c = sidelength // 2
Expand Down
5 changes: 4 additions & 1 deletion src/ttmask/sphere.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
from pathlib import Path

from ._cli import cli
import numpy as np
import einops
import typer
Expand All @@ -13,7 +16,7 @@ def sphere(
sphere_diameter: float = typer.Option(...),
soft_edge_width: int = typer.Option(0),
pixel_size: float = typer.Option(...),
output: str = typer.Option("sphere.mrc"),
output: Path = typer.Option(Path("sphere.mrc")),
wall_thickness: float = typer.Option(0),
):
sphere_radius = sphere_diameter / 2
Expand Down

0 comments on commit 42bf153

Please sign in to comment.