Skip to content

Commit

Permalink
Improve docs/errors/warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
clbarnes committed Jun 10, 2022
1 parent 942b4ee commit 9af8a3b
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions ncollpyde/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,7 @@ def interpret_threads(threads: Optional[Union[int, bool]], default=DEFAULT_THREA
threads = int(threads)

warnings.warn(
"ncollpyde's API has changed "
"and fine-grained control of threading is no longer possible; "
"`threads` should now be a boolean. "
"ncollpyde's API has changed; `threads` should now be a boolean. "
"See https://github.com/clbarnes/ncollpyde/issues/27 for more details",
DeprecationWarning,
)
Expand Down Expand Up @@ -96,6 +94,10 @@ def __init__(
vert, tri = self._validate(vert, tri)
self.threads = self._interpret_threads(threads)
if ray_seed is None:
logger.warning(
"Using unseeded random number generator for containment-checking rays; "
"results may be inconsistent across repeats."
)
ray_seed = random.randrange(0, 2**64)

self._impl = TriMeshWrapper(vert, tri, int(n_rays), ray_seed)
Expand Down Expand Up @@ -252,7 +254,7 @@ def from_meshio(
validate=False,
threads=None,
n_rays=DEFAULT_RAYS,
ray_seed=None,
ray_seed=DEFAULT_SEED,
) -> "Volume":
"""
Convenience function for instantiating a Volume from a meshio Mesh.
Expand All @@ -266,17 +268,19 @@ def from_meshio(
:return: Volume instance
"""
try:
return cls(
mesh.points,
mesh.cells_dict["triangle"],
validate,
threads,
n_rays,
ray_seed,
)
triangles = mesh.cells_dict["triangle"]
except KeyError:
raise ValueError("Must have triangle cells")

return cls(
mesh.points,
triangles,
validate,
threads,
n_rays,
ray_seed,
)

@property
def points(self) -> NDArray[np.float64]:
"""
Expand Down

0 comments on commit 9af8a3b

Please sign in to comment.