#!/usr/bin/env python3 # -*- coding: utf-8 -*- """! Author: J.A. de Jong - ASCEE Description: LASP configuration """ import numpy as np from .lasp_cpp import LASP_DOUBLE_PRECISION __all__ = ["zeros", "ones", "empty", "LASP_NUMPY_FLOAT_TYPE", "LASP_NUMPY_COMPLEX_TYPE"] if LASP_DOUBLE_PRECISION: LASP_NUMPY_FLOAT_TYPE = np.float64 LASP_NUMPY_COMPLEX_TYPE = np.complex128 else: LASP_NUMPY_FLOAT_TYPE = np.float32 LASP_NUMPY_COMPLEX_TYPE = np.float64 def zeros(shape, dtype=float, order="F"): if dtype is float: return np.zeros(shape, dtype=LASP_NUMPY_FLOAT_TYPE, order=order) elif dtype is complex: return np.zeros(shape, dtype=LASP_NUMPY_COMPLEX_TYPE, order=order) else: raise RuntimeError(f"Unknown dtype: {dtype}") def ones(shape, dtype=float, order="F"): if dtype is float: return np.ones(shape, dtype=LASP_NUMPY_FLOAT_TYPE, order=order) elif dtype is complex: return np.ones(shape, dtype=LASP_NUMPY_COMPLEX_TYPE, order=order) else: raise RuntimeError(f"Unknown dtype: {dtype}") def empty(shape, dtype=float, order="F"): if dtype is float: return np.empty(shape, dtype=LASP_NUMPY_FLOAT_TYPE, order=order) elif dtype is complex: return np.empty(shape, dtype=LASP_NUMPY_COMPLEX_TYPE, order=order) else: raise RuntimeError(f"Unknown dtype: {dtype}")