Skip to content

Commit

Permalink
Remove internal GCD function, check Real instead of Numbers
Browse files Browse the repository at this point in the history
  • Loading branch information
Daval-G committed Apr 5, 2024
1 parent 227fb4c commit dd18535
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 28 deletions.
24 changes: 2 additions & 22 deletions src/mrinufft/trajectories/maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import numpy as np
import numpy.linalg as nl


CIRCLE_PACKING_DENSITY = np.pi / (2 * np.sqrt(3))


Expand All @@ -12,26 +11,6 @@
##########


def compute_greatest_common_divider(p, q):
"""Compute the greatest common divider of two integers p and q.
Parameters
----------
p : int
First integer.
q : int
Second integer.
Returns
-------
int
The greatest common divider of p and q.
"""
while q != 0:
p, q = q, p % q
return p


def compute_coprime_factors(Nc, length, start=1, update=1):
"""Compute a list of coprime factors of Nc.
Expand All @@ -54,7 +33,8 @@ def compute_coprime_factors(Nc, length, start=1, update=1):
count = start
coprimes = []
while len(coprimes) < length:
if compute_greatest_common_divider(Nc, count) == 1:
# Check greatest common divider (gcd)
if np.gcd(Nc, count) == 1:
coprimes.append(count)
count += update
return coprimes
Expand Down
11 changes: 5 additions & 6 deletions src/mrinufft/trajectories/utils.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
"""Utility functions for the trajectory design."""

import numbers as nb
import numpy as np

from enum import Enum, EnumMeta
from numbers import Real

import numpy as np

#############
# CONSTANTS #
Expand Down Expand Up @@ -468,7 +467,7 @@ def initialize_tilt(tilt, nb_partitions=1):
Tilts
"""
if isinstance(tilt, nb.Number):
if isinstance(tilt, Real):
return tilt
elif tilt is None or tilt == Tilts.NONE:
return 0
Expand Down Expand Up @@ -499,7 +498,7 @@ def initialize_spiral(spiral):
float
Spiral power value.
"""
if isinstance(spiral, nb.Number):
if isinstance(spiral, Real):
return spiral
return Spirals[spiral]

Expand All @@ -517,6 +516,6 @@ def initialize_shape_norm(shape):
float
Shape p-norm value.
"""
if isinstance(shape, nb.Number):
if isinstance(shape, Real):
return shape
return NormShapes[shape]

0 comments on commit dd18535

Please sign in to comment.