Code optimization (hos)
Opened this issue · 0 comments
hubert-leterme commented
I worked on the hos
branch, but there are still some problems to fix and code to optimize.
Module pycs.astro.wl.mass_mapping
- Remove
for
loops wherever possible - Vectorize mass mapping methods: operate on stacks of images rather than single images.
- Class
massmap2d
: it would be better to create a separate class for each mass mapping method, inheriting from a base class implementing aforward
orpredict
method. This way, it would be easier to write code which is shared among all mass mapping methods. E.g.,BaseMassmap2d
,ProxWiener
,ProxMSE
,SparseWiener
. - Improve intermediate methods such as
massmap2d._prepare_data
,massmap2d._get_Wfc
andmassmap2d._noise_realizations
: instead of returning many variables, register them as instance attributes or properties for the classesmassmap2d
orshear_data
? - Class and variable names: should respect the Python standards.
- Classes
shear_data
,massmap2d
andstarlet2d
: put attribute declaration within the__init__
methods. Moreover, mergeinit_massmap
andinit_starlet
into the respective__init__
methods. - Are the attributes
nx
andny
really necessary formassmap2d
? What aboutstarlet2d
? - Remove argument
ind
from_prepare_data
(removenp.where
wherever possible; useless most of the time) - Improve
mask = (Ncv < 1e2).astype(int)
(could be placed before) - Bug correction in
gamma_to_cf_kappa
(raiseNotImplementedError
, to be done later if necessary) - Optimize
kappa_to_gamma
,gamma_to_cf_kappa
,gamma_to_kappa
,H_operator_eb2g
andH_adjoint_g2eb
: work on complex arrays - Remove redundancy with the above methods
Module pycs.sparsity.sparse2d.starlet
- Class
MRStarlet
: modify methodstransform
andrecons
in order them to operate on stacks of images (n-D tensors). Modify the C implementation, or implement them in PyTorch to take advantage of GPU acceleration. As a workaround, I usednp.vectorize
to achieve the same results, but computational efficiency could be widely improved.
Package pycs
- Work with
dtype = np.float32
andnp.complex64
, ordtype = np.float64
andnp.complex128
? Harmonize code. - Remove
np.copy()
wherever possible (useless memory usage)