Skip to content

Commit 4a90df1

Browse files
committed
fix cli testing issues
1 parent b29a23a commit 4a90df1

6 files changed

Lines changed: 62 additions & 11 deletions

File tree

kompot/anndata/differential_abundance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -442,7 +442,7 @@ def compute_differential_abundance(
442442

443443
# Create landmarks info
444444
landmarks_info = {
445-
'shape': landmarks_shape,
445+
'shape': list(landmarks_shape), # Convert tuple to list for HDF5 serialization
446446
'dtype': landmarks_dtype,
447447
'source': 'computed',
448448
'n_landmarks': landmarks_shape[0],

kompot/cli/da.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,12 @@ def add_da_parser(subparsers) -> argparse.ArgumentParser:
128128
help='Length scale multiplication factor (default: 10.0)'
129129
)
130130

131+
parser.add_argument(
132+
'--random-state',
133+
type=int,
134+
help='Random seed for reproducible landmark selection (default: None)'
135+
)
136+
131137
# Boolean flags
132138
parser.add_argument(
133139
'--store-landmarks',
@@ -171,7 +177,7 @@ def run_da(args):
171177
# Convert args to dict, removing None values and CLI-specific args
172178
args_dict = {
173179
k: v for k, v in vars(args).items()
174-
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose']
180+
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose', 'command']
175181
}
176182

177183
# Rename CLI args to match function parameters

kompot/cli/de.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,13 @@ def add_de_parser(subparsers) -> argparse.ArgumentParser:
130130
help='Number of null genes for FDR estimation (default: 2000)'
131131
)
132132

133+
parser.add_argument(
134+
'--null-seed',
135+
type=int,
136+
default=42,
137+
help='Random seed for null gene selection and shuffling (default: 42)'
138+
)
139+
133140
# Boolean flags
134141
parser.add_argument(
135142
'--no-progress',
@@ -185,7 +192,7 @@ def run_de(args):
185192
# Convert args to dict, removing None values and CLI-specific args
186193
args_dict = {
187194
k: v for k, v in vars(args).items()
188-
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose']
195+
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose', 'command']
189196
}
190197

191198
# Rename CLI args to match function parameters

kompot/cli/dm.py

Lines changed: 42 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,38 @@ def add_dm_parser(subparsers) -> argparse.ArgumentParser:
8484
)
8585

8686
parser.add_argument(
87-
'--use-adjacency-matrix',
88-
action='store_true',
89-
help='Use adjacency matrix if available'
87+
'--seed',
88+
type=int,
89+
default=0,
90+
help='Random seed for reproducibility (default: 0)'
91+
)
92+
93+
parser.add_argument(
94+
'--kernel-key',
95+
type=str,
96+
default='DM_Kernel',
97+
help='Key to store kernel in adata.obsp (default: DM_Kernel)'
98+
)
99+
100+
parser.add_argument(
101+
'--sim-key',
102+
type=str,
103+
default='DM_Similarity',
104+
help='Key to store similarity in adata.obsp (default: DM_Similarity)'
105+
)
106+
107+
parser.add_argument(
108+
'--eigval-key',
109+
type=str,
110+
default='DM_EigenValues',
111+
help='Key to store eigenvalues in adata.uns (default: DM_EigenValues)'
112+
)
113+
114+
parser.add_argument(
115+
'--eigvec-key',
116+
type=str,
117+
default='DM_EigenVectors',
118+
help='Key to store eigenvectors in adata.obsm (default: DM_EigenVectors)'
90119
)
91120

92121
parser.set_defaults(func=run_dm)
@@ -127,16 +156,22 @@ def run_dm(args):
127156
# Convert args to dict, removing None values and CLI-specific args
128157
args_dict = {
129158
k: v for k, v in vars(args).items()
130-
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose']
159+
if v is not None and k not in ['input', 'output', 'config', 'func', 'verbose', 'command']
131160
}
132161

133-
# Rename CLI args to match function parameters
162+
# Rename CLI args to match function parameters (convert hyphens to underscores)
134163
if 'pca_key' in args_dict:
135164
args_dict['pca_key'] = args_dict.pop('pca_key')
136165
if 'n_components' in args_dict:
137166
args_dict['n_components'] = args_dict.pop('n_components')
138-
if 'use_adjacency_matrix' in args_dict:
139-
args_dict['use_adjacency_matrix'] = args_dict.pop('use_adjacency_matrix')
167+
if 'kernel_key' in args_dict:
168+
args_dict['kernel_key'] = args_dict.pop('kernel_key')
169+
if 'sim_key' in args_dict:
170+
args_dict['sim_key'] = args_dict.pop('sim_key')
171+
if 'eigval_key' in args_dict:
172+
args_dict['eigval_key'] = args_dict.pop('eigval_key')
173+
if 'eigvec_key' in args_dict:
174+
args_dict['eigvec_key'] = args_dict.pop('eigvec_key')
140175

141176
# Merge with config (CLI args take precedence)
142177
params = merge_args_with_config(args_dict, config)

kompot/cli/main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ def main():
1919
parser.add_argument(
2020
'--version',
2121
action='version',
22-
version='%(prog)s 0.5.2'
22+
version='%(prog)s 0.6.0'
2323
)
2424

2525
parser.add_argument(

tests/test_cli.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,9 @@ def test_dm_missing_pca(self, sample_adata, temp_dir):
437437
"""Test error when PCA is missing."""
438438
input_file = Path(temp_dir) / 'input.h5ad'
439439
output_file = Path(temp_dir) / 'output.h5ad'
440+
441+
# Remove PCA from sample data
442+
del sample_adata.obsm['X_pca']
440443
sample_adata.write_h5ad(input_file)
441444

442445
# Run CLI without PCA in data

0 commit comments

Comments
 (0)