Skip to content

Geometry utilities cast to single, casts integers to single too #678

@MargaretDuff

Description

@MargaretDuff

This bit of code:

def cast_to_single(self):
"""
Casts all number values in current instance to single prevision floating point types.
:return: None
"""
for attrib in self.__dict__:
if getattr(self, attrib) is not None:
try:
setattr(self, attrib, np.float32(getattr(self, attrib)))
except ValueError:
pass

Expected Behavior

Expect anything in double precision is cast to single precision

Actual Behavior

Casts everything to single precision including integers

Code to reproduce the problem (If applicable)

This caused an issue when I did

self.tigre_geom.cast_to_single()

img, qual= sart(
                proj=self.tigre_projections,
                geo=self.tigre_geom,
                angles=self.tigre_angles,
                init=self.tigre_initial,
                niter=self.niter,
                gpuids=self.gpuids,
                **self.kwargs

because sart allocates internally based on nVoxel in the geometry which now isn't an integer.

Specifications

  • MATLAB/python version: python
  • OS: linux
  • CUDA version: 12.9

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions