Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove strenum optional dependancy #604

Merged
merged 3 commits into from
Jun 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,4 @@ flake8
flake8-bandit
flake8-docstrings
autopep8
StrEnum
ratelimit
ratelimit
5 changes: 3 additions & 2 deletions vip_hci/invprob/andromeda.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@

import numpy as np
from dataclasses import dataclass
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum

from typing import Union

from ..var.filters import frame_filter_highpass, cube_filter_highpass
Expand Down Expand Up @@ -155,7 +156,7 @@ class AndroParams:
min_sep: float = 0.5
annuli_width: float = 1.0
roa: float = 2
opt_method: LowEnum = OptMethod.LSQ
opt_method: Enum = OptMethod.LSQ
nsmooth_snr: int = 18
iwa: float = None
owa: float = None
Expand Down
14 changes: 7 additions & 7 deletions vip_hci/invprob/fmmf.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
from dataclasses import dataclass, field
import numpy as np
import numpy.linalg as la
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from skimage.draw import disk
from ..var import get_annulus_segments, frame_center
from ..preproc import frame_crop, cube_crop_frames, cube_derotate
Expand Down Expand Up @@ -106,7 +106,7 @@ class FMMFParams:
model: string, optional
Selected PSF-subtraction technique for the computation of the FMMF
detection map. FMMF work either with KLIP or LOCI. Default is 'KLIP'.
var: LowerCaseStrEnum, see `vip_hci.var.paramenum.VarEstim`
var: Enum, see `vip_hci.var.paramenum.VarEstim`
Model used for the residual noise variance estimation used in the
matched filtering (maximum likelihood estimation of the flux and SNR).
param: dict, optional
Expand All @@ -126,10 +126,10 @@ class FMMFParams:
crop: int, optional
Part of the PSF template considered in the estimation of the FMMF
detection map. Default is 5.
imlib : LowerCaseStrEnum, see `vip_hci.var.paramenum.Imlib`
imlib : Enum, see `vip_hci.var.paramenum.Imlib`
Parameter used for the derotation of the residual cube. See the
documentation of the ``vip_hci.preproc.frame_rotate`` function.
interpolation : LowerCaseStrEnum, see `vip_hci.var.paramenum.Interpolation`
interpolation : Enum, see `vip_hci.var.paramenum.Interpolation`
Parameter used for the derotation of the residual cube. See the
documentation of the ``vip_hci.preproc.frame_rotate`` function.
nproc : int or None, optional
Expand All @@ -148,13 +148,13 @@ class FMMFParams:
min_r: int = None
max_r: int = None
model: str = "KLIP"
var: LowEnum = VarEstim.FR
var: Enum = VarEstim.FR
param: dict = field(
default_factory=lambda: {"ncomp": 20, "tolerance": 5e-3, "delta_rot": 0.5}
)
crop: int = 5
imlib: LowEnum = Imlib.VIPFFT
interpolation: LowEnum = Interpolation.LANCZOS4
imlib: Enum = Imlib.VIPFFT
interpolation: Enum = Interpolation.LANCZOS4
nproc: int = 1
verbose: bool = True

Expand Down
2 changes: 1 addition & 1 deletion vip_hci/objects/pppca.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ def run(

Parameters
----------
runmode : LowerCaseStrEnum, see ``vip_hci.var.paramenum.Runmode``
runmode : Enum, see ``vip_hci.var.paramenum.Runmode``
Mode of execution for the PCA.
dataset : Dataset, optional
Dataset to process. If not provided, ``self.dataset`` is used (as
Expand Down
10 changes: 5 additions & 5 deletions vip_hci/psfsub/framediff.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from hciplot import plot_frames
from multiprocessing import cpu_count
from dataclasses import dataclass
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from sklearn.metrics import pairwise_distances
from ..var import get_annulus_segments
from ..var.object_utils import setup_parameters, separate_kwargs_dict
Expand Down Expand Up @@ -77,16 +77,16 @@ class FrameDiffParams:
cube: np.ndarray = None
angle_list: np.ndarray = None
fwhm: float = 4
metric: LowEnum = Metric.MANHATTAN
metric: Enum = Metric.MANHATTAN
dist_threshold: int = 50
n_similar: int = None
delta_rot: int = 0.5
radius_int: int = 2
asize: int = 4
ncomp: int = None
imlib: LowEnum = Imlib.VIPFFT
interpolation: LowEnum = Interpolation.LANCZOS4
collapse: LowEnum = Collapse.MEDIAN
imlib: Enum = Imlib.VIPFFT
interpolation: Enum = Interpolation.LANCZOS4
collapse: Enum = Collapse.MEDIAN
nproc: int = 1
verbose: bool = True
debug: bool = False
Expand Down
18 changes: 9 additions & 9 deletions vip_hci/psfsub/llsg.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from multiprocessing import cpu_count
from astropy.stats import median_absolute_deviation
from dataclasses import dataclass
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from ..config import time_ini, timing
from ..preproc import cube_derotate, cube_collapse
from ..var import get_annulus_segments, cube_filter_highpass
Expand Down Expand Up @@ -54,9 +54,9 @@ class LLSGParams:
low_rank_ref :
If True the first estimation of the L component is obtained from the
remaining segments in the same annulus.
low_rank_mode : LowerCaseStrEnum, see `vip_hci.var.paramenum.LowRankMode`
low_rank_mode : Enum, see `vip_hci.var.paramenum.LowRankMode`
Sets the method of solving the L update.
auto_rank_mode : LowerCaseStrEnum, see `vip_hci.var.paramenum.AutoRankMode`
auto_rank_mode : Enum, see `vip_hci.var.paramenum.AutoRankMode`
If ``rank`` is None, then ``auto_rank_mode`` sets the way that the
``rank`` is determined: the noise minimization or the cumulative
explained variance ratio (when 'svd' is used).
Expand All @@ -66,7 +66,7 @@ class LLSGParams:
cevr : float, optional
Float value in the range [0,1] for selecting the cumulative explained
variance ratio to choose the rank automatically (if ``rank`` is None).
thresh_mode : LowerCaseStrEnum, see `vip_hci.var.paramenum.ThreshMode`
thresh_mode : Enum, see `vip_hci.var.paramenum.ThreshMode`
Sets the type of thresholding.
nproc : None or int, optional
Number of processes for parallel computing. If None the number of
Expand All @@ -91,7 +91,7 @@ class LLSGParams:
first with the mode ``median-subt`` and a large window, and then with
``laplacian-conv`` and a kernel size equal to ``high_pass``. 5 is an
optimal value when ``fwhm`` is ~4.
collapse : LowerCaseStrEnum, see `vip_hci.var.paramenum.Collapse`
collapse : Enum, see `vip_hci.var.paramenum.Collapse`
Sets the way of collapsing the frames for producing a final image.
full_output: bool, optional
Whether to return the final median combined image only or with other
Expand All @@ -109,19 +109,19 @@ class LLSGParams:
thresh: float = 1
max_iter: int = 10
low_rank_ref: bool = False
low_rank_mode: LowEnum = LowRankMode.SVD
auto_rank_mode: LowEnum = AutoRankMode.NOISE
low_rank_mode: Enum = LowRankMode.SVD
auto_rank_mode: Enum = AutoRankMode.NOISE
residuals_tol: float = 1e-1
cevr: float = 0.9
thresh_mode: LowEnum = ThreshMode.SOFT
thresh_mode: Enum = ThreshMode.SOFT
nproc: int = 1
asize: int = None
n_segments: int = 4
azimuth_overlap: int = None
radius_int: int = None
random_seed: int = None
high_pass: int = None
collapse: LowEnum = Collapse.MEDIAN
collapse: Enum = Collapse.MEDIAN
full_output: bool = False
verbose: bool = True
debug: bool = False
Expand Down
26 changes: 13 additions & 13 deletions vip_hci/psfsub/loci.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
from multiprocessing import cpu_count
from sklearn.metrics import pairwise_distances
from dataclasses import dataclass
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from typing import Tuple, Union
from ..var import get_annulus_segments
from ..var.object_utils import setup_parameters, separate_kwargs_dict
Expand Down Expand Up @@ -55,7 +55,7 @@ class LOCIParams:
e.g. with ``vip_hci.preproc.find_scal_vector``).
fwhm : float, optional
Size of the FHWM in pixels. Default is 4.
metric : LowerCaseStrEnum, see `vip_hci.var.paramenum.Metric`
metric : Enum, see `vip_hci.var.paramenum.Metric`
Distance metric to be used ('cityblock', 'cosine', 'euclidean', 'l1',
'l2', 'manhattan', 'correlation', etc). It uses the scikit-learn
function ``sklearn.metrics.pairwise.pairwise_distances`` (check its
Expand Down Expand Up @@ -87,7 +87,7 @@ class LOCIParams:
Number of processes for parallel computing. If None the number of
processes will be set to cpu_count()/2. By default the algorithm works
in single-process mode.
solver : LowerCaseStrEnum, see `vip_hci.var.paramenum.Solver`
solver : Enum, see `vip_hci.var.paramenum.Solver`
Choosing the solver of the least squares problem. ``lstsq`` uses the
standard scipy least squares solver. ``nnls`` uses the scipy
non-negative least-squares solver.
Expand All @@ -102,7 +102,7 @@ class LOCIParams:
similar to LOCI. The optimization segments share the same inner radius,
mean angular position and angular width as their corresponding
subtraction segments.
adimsdi : LowerCaseStrEnum, see `vip_hci.var.paramenum.Adimsdi`
adimsdi : Enum, see `vip_hci.var.paramenum.Adimsdi`
Changes the way the 4d cubes (ADI+mSDI) are processed.

``skipadi``: the multi-spectral frames are rescaled wrt the largest
Expand All @@ -113,11 +113,11 @@ class LOCIParams:
(as in the ``skipadi`` case). Then the residuals are processed again in
an ADI fashion.

imlib : LowerCaseStrEnum, see `vip_hci.var.paramenum.Imlib`
imlib : Enum, see `vip_hci.var.paramenum.Imlib`
See the documentation of the ``vip_hci.preproc.frame_rotate`` function.
interpolation : LowerCaseStrEnum, see `vip_hci.var.paramenum.Interpolation`
interpolation : Enum, see `vip_hci.var.paramenum.Interpolation`
See the documentation of the ``vip_hci.preproc.frame_rotate`` function.
collapse : LowerCaseStrEnum, see `vip_hci.var.paramenum.Collapse`
collapse : Enum, see `vip_hci.var.paramenum.Collapse`
Sets the way of collapsing the frames for producing a final image.
verbose: bool, optional
If True prints info to stdout.
Expand All @@ -130,21 +130,21 @@ class LOCIParams:
angle_list: np.ndarray = None
scale_list: np.ndarray = None
fwhm: float = 4
metric: LowEnum = Metric.MANHATTAN
metric: Enum = Metric.MANHATTAN
dist_threshold: int = 100
delta_rot: Union[float, Tuple[float]] = (0.1, 1)
delta_sep: Union[float, Tuple[float]] = (0.1, 1)
radius_int: int = 0
asize: int = 4
n_segments: int = 4
nproc: int = 1
solver: LowEnum = Solver.LSTSQ
solver: Enum = Solver.LSTSQ
tol: float = 1e-2
optim_scale_fact: float = 2
adimsdi: LowEnum = Adimsdi.SKIPADI
imlib: LowEnum = Imlib.VIPFFT
interpolation: LowEnum = Interpolation.LANCZOS4
collapse: LowEnum = Collapse.MEDIAN
adimsdi: Enum = Adimsdi.SKIPADI
imlib: Enum = Imlib.VIPFFT
interpolation: Enum = Interpolation.LANCZOS4
collapse: Enum = Collapse.MEDIAN
verbose: bool = True
full_output: bool = False

Expand Down
14 changes: 7 additions & 7 deletions vip_hci/psfsub/medsub.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@
import numpy as np
from multiprocessing import cpu_count
from dataclasses import dataclass
from enum import Enum
from typing import Tuple, Union
from strenum import LowercaseStrEnum as LowEnum
from ..config import time_ini, timing
from ..var import get_annulus_segments, mask_circle
from ..var.paramenum import Imlib, Interpolation, Collapse
Expand Down Expand Up @@ -102,11 +102,11 @@ class MedsubParams:
sdi_only: bool, optional
In the case of IFS data (ADI+SDI), whether to perform median-SDI, or
median-ASDI (default).
imlib : LowerCaseStrEnum, see `vip_hci.var.paramenum.Imlib`
imlib : Enum, see `vip_hci.var.paramenum.Imlib`
See the documentation of ``vip_hci.preproc.frame_rotate``.
interpolation : LowerCaseStrEnum, see `vip_hci.var.paramenum.Interpolation`
interpolation : Enum, see `vip_hci.var.paramenum.Interpolation`
See the documentation of the ``vip_hci.preproc.frame_rotate`` function.
collapse : LowerCaseStrEnum, see `vip_hci.var.paramenum.Collapse`
collapse : Enum, see `vip_hci.var.paramenum.Collapse`
Sets how temporal residual frames should be combined to produce an
ADI image.
nproc : None or int, optional
Expand All @@ -132,9 +132,9 @@ class MedsubParams:
mode: str = "fullfr"
nframes: int = 4
sdi_only: bool = False
imlib: LowEnum = Imlib.VIPFFT
interpolation: LowEnum = Interpolation.LANCZOS4
collapse: LowEnum = Collapse.MEDIAN
imlib: Enum = Imlib.VIPFFT
interpolation: Enum = Interpolation.LANCZOS4
collapse: Enum = Collapse.MEDIAN
nproc: int = 1
full_output: bool = False
verbose: bool = True
Expand Down
18 changes: 9 additions & 9 deletions vip_hci/psfsub/nmf_fullfr.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import numpy as np
from sklearn.decomposition import NMF
from dataclasses import dataclass, field
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from typing import Tuple
from ..preproc import cube_derotate, cube_collapse
from ..preproc.derotation import _compute_pa_thresh, _find_indices_adi
Expand Down Expand Up @@ -51,7 +51,7 @@ class NMFParams:
ncomp : int, optional
How many components are used as for low-rank approximation of the
datacube.
scaling : LowerCaseStrEnum, see `vip_hci.var.paramenum.Scaling`
scaling : Enum, see `vip_hci.var.paramenum.Scaling`
With None, no scaling is performed on the input data before SVD. With
"temp-mean" then temporal px-wise mean subtraction is done, with
"spat-mean" then the spatial mean is subtracted, with "temp-standard"
Expand All @@ -76,20 +76,20 @@ class NMFParams:
Default is 1 (excludes 1xFHWM on each side of the considered frame).
fwhm : float, optional
Known size of the FHWM in pixels to be used. Default value is 4.
init_svd: LowerCaseStrEnum, see `vip_hci.var.paramenum.Initsvd`
init_svd: Enum, see `vip_hci.var.paramenum.Initsvd`
Method used to initialize the iterative procedure to find H and W.
'nndsvd': non-negative double SVD recommended for sparseness
'nndsvda': NNDSVD where zeros are filled with the average of cube;
recommended when sparsity is not desired
'random': random initial non-negative matrix
collapse : LowerCaseStrEnum, see `vip_hci.var.paramenum.Collapse`
collapse : Enum, see `vip_hci.var.paramenum.Collapse`
Sets the way of collapsing the frames for producing a final image.
full_output: boolean, optional
Whether to return the final median combined image only or with other
intermediate arrays.
verbose : {True, False}, bool optional
If True prints intermediate info and timing.
handle_neg: LowerCaseStrEnum, see `vip_hci.var.paramenum.HandleNeg`
handle_neg: Enum, see `vip_hci.var.paramenum.HandleNeg`
Determines how to handle negative values: mask them, set them to zero,
or subtract the minimum value in the arrays. Note: 'mask' or 'null'
may leave significant artefacts after derotation of residual cube
Expand All @@ -104,19 +104,19 @@ class NMFParams:
angle_list: np.ndarray = None
cube_ref: np.ndarray = None
ncomp: int = 1
scaling: LowEnum = None
scaling: Enum = None
max_iter: int = 10000
random_state: int = None
mask_center_px: int = None
source_xy: Tuple[int] = None
delta_rot: float = 1
fwhm: float = 4
init_svd: LowEnum = Initsvd.NNDSVD
collapse: LowEnum = Collapse.MEDIAN
init_svd: Enum = Initsvd.NNDSVD
collapse: Enum = Collapse.MEDIAN
full_output: bool = False
verbose: bool = True
cube_sig: np.ndarray = None
handle_neg: LowEnum = HandleNeg.MASK
handle_neg: Enum = HandleNeg.MASK
nmf_args: dict = field(default_factory=lambda: {})


Expand Down
14 changes: 7 additions & 7 deletions vip_hci/psfsub/nmf_local.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sklearn.decomposition import NMF
from dataclasses import dataclass, field
from typing import Tuple, List, Union
from strenum import LowercaseStrEnum as LowEnum
from enum import Enum
from ..preproc import cube_derotate, cube_collapse, check_pa_vector
from ..preproc.derotation import _find_indices_adi, _define_annuli
from ..var import get_annulus_segments, matrix_scaling
Expand Down Expand Up @@ -123,20 +123,20 @@ class NMFAnnParams:
n_segments: int = 1
delta_rot: Union[float, Tuple[float]] = (0.1, 1)
ncomp: int = 1
init_svd: LowEnum = Initsvd.NNDSVD
init_svd: Enum = Initsvd.NNDSVD
nproc: int = 1
min_frames_lib: int = 2
max_frames_lib: int = 200
scaling: LowEnum = None
imlib: LowEnum = Imlib.VIPFFT
interpolation: LowEnum = Interpolation.LANCZOS4
collapse: LowEnum = Collapse.MEDIAN
scaling: Enum = None
imlib: Enum = Imlib.VIPFFT
interpolation: Enum = Interpolation.LANCZOS4
collapse: Enum = Collapse.MEDIAN
full_output: bool = False
verbose: bool = True
theta_init: float = 0
weights: List = None
cube_sig: np.ndarray = None
handle_neg: LowEnum = HandleNeg.MASK
handle_neg: Enum = HandleNeg.MASK
max_iter: int = 1000
random_state: int = None
nmf_args: dict = field(default_factory=lambda: {})
Expand Down
Loading