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

Improve test coverage, improve code where possible #366

Open
romeokienzler opened this issue Jan 14, 2025 · 3 comments · May be fixed by #390
Open

Improve test coverage, improve code where possible #366

romeokienzler opened this issue Jan 14, 2025 · 3 comments · May be fixed by #390
Assignees
Labels

Comments

@romeokienzler
Copy link
Collaborator

romeokienzler commented Jan 14, 2025

use tools to detect test coverage - instruction coverage test, path coverage test

@Joao-L-S-Almeida Joao-L-S-Almeida self-assigned this Jan 14, 2025
@romeokienzler romeokienzler self-assigned this Jan 16, 2025
@romeokienzler
Copy link
Collaborator Author

useful things to do:

  • improve logging (@Joao-L-S-Almeida )
  • don't log via print! <- we should have zero print statements
  • use coverage tool with pytest (@romeokienzler )
  • look/fix linter error

@Joao-L-S-Almeida Joao-L-S-Almeida linked a pull request Jan 31, 2025 that will close this issue
@romeokienzler
Copy link
Collaborator Author

This is the result of the coverage test

terratorch/__init__.py                                             3      0      0      0   100%
terratorch/__main__.py                                             3      3      0      0     0%   5-9
terratorch/cli_tools.py                                          267    122     78     15    48%   65, 69-72, 76, 81-87, 91-105, 112-128, 146-167, 174-189, 214->217, 247, 249->282, 252-253, 259-269, 271->282, 277->282, 282->299, 283->299, 388, 391, 394, 403-406, 425-430, 471-487, 504-523, 531-535, 547-553, 564-569
terratorch/datamodules/__init__.py                                41      1      2      1    95%   99
terratorch/datamodules/biomassters.py                             57     41     14      0    23%   91-124, 127-182, 201-203
terratorch/datamodules/burn_intensity.py                          33     22      8      0    27%   47-61, 64-98
terratorch/datamodules/carbonflux.py                              35     22      8      0    30%   59-79, 82-116
terratorch/datamodules/era5.py                                    58     39      8      0    29%   24-44, 79-99, 109, 129-134, 166-172, 175, 178-189, 197, 208, 218
terratorch/datamodules/fire_scars.py                              65     44     14      0    27%   56-70, 73-104, 127-129, 143-148, 151-173
terratorch/datamodules/forestnet.py                               35     21      8      0    33%   51-64, 67-98
terratorch/datamodules/generic_multimodal_data_module.py         202    174     82      0    10%   26-36, 43-56, 60-69, 74-76, 79-113, 121-124, 131-152, 312-417, 421-512, 527-544
terratorch/datamodules/generic_pixel_wise_data_module.py         134     51     20      3    60%   59-60, 65-66, 177-219, 225-286, 313-318, 538
terratorch/datamodules/generic_scalar_label_data_module.py        72     52     12      0    24%   29, 33-35, 38-49, 134-167, 173-219, 244-249
terratorch/datamodules/geobench_data_module.py                    30     19      8      0    29%   31-42, 47-75
terratorch/datamodules/landslide4sense.py                         31     18      8      0    33%   63-73, 78-100
terratorch/datamodules/m_SA_crop_type.py                          11      1      0      0    91%   57
terratorch/datamodules/m_bigearthnet.py                           11      1      0      0    91%   55
terratorch/datamodules/m_brick_kiln.py                            11      1      0      0    91%   57
terratorch/datamodules/m_cashew_plantation.py                     11      1      0      0    91%   58
terratorch/datamodules/m_chesapeake_landcover.py                  11      1      0      0    91%   29
terratorch/datamodules/m_eurosat.py                               11      1      0      0    91%   57
terratorch/datamodules/m_forestnet.py                             11      1      0      0    91%   44
terratorch/datamodules/m_neontree.py                              11      1      0      0    91%   41
terratorch/datamodules/m_nz_cattle.py                             11      1      0      0    91%   30
terratorch/datamodules/m_pv4ger.py                                11      1      0      0    91%   34
terratorch/datamodules/m_pv4ger_seg.py                            11      1      0      0    91%   30
terratorch/datamodules/m_so2sat.py                                11      1      0      0    91%   67
terratorch/datamodules/merra2_downscale.py                        45     43      8      0     4%   3-101
terratorch/datamodules/multi_temporal_crop_classification.py      42     27      8      0    30%   53-69, 72-109, 134-136
terratorch/datamodules/open_sentinel_map.py                       27     19      8      0    23%   26-41, 44-78
terratorch/datamodules/openearthmap.py                            31     18      8      0    33%   36-46, 49-62
terratorch/datamodules/pastis.py                                  25     17      8      0    24%   24-37, 40-68
terratorch/datamodules/sen1floods11.py                            42     26      8      0    32%   68-83, 86-120, 144-146
terratorch/datamodules/sen4agrinet.py                             29     21      8      0    22%   28-45, 48-88
terratorch/datamodules/sen4map.py                                 88     75     30      0    11%   27-97, 100-103, 106-137, 149, 152, 155
terratorch/datamodules/torchgeo_data_module.py                    72     36      8      0    45%   39-44, 74-81, 85, 89, 92, 95, 98, 101, 104, 134-141, 145, 149, 153, 157, 160, 163, 166, 169, 172, 175
terratorch/datamodules/utils.py                                   30     17      6      1    39%   13, 22-23, 27-29, 32-47
terratorch/datasets/__init__.py                                   32      0      0      0   100%
terratorch/datasets/biomassters.py                               258    220     86      0    11%   125-213, 216, 227-236, 247-250, 254-307, 312-317, 325-338, 341-372, 375-385, 388-396, 415-507
terratorch/datasets/burn_intensity.py                            144    111     26      0    19%   72-115, 119, 123-126, 129, 132-145, 148-176, 179-182, 195-250
terratorch/datasets/carbonflux.py                                135    105     22      0    19%   69-128, 131, 134-137, 141-160, 164-176, 179-212, 224-247
terratorch/datasets/fire_scars.py                                134     26     18      9    77%   70-71, 95-104, 107-116, 123-124, 138->140, 143-144, 150->152, 168-169, 178-179, 202-203, 210->213
terratorch/datasets/forestnet.py                                 143    108     30      0    20%   66-93, 96, 99-108, 111-120, 123-146, 150-162, 165-175, 178-184, 187-188, 192-194, 198-227
terratorch/datasets/generic_multimodal_dataset.py                355    307    160      0     9%   31-38, 43, 45-59, 150-350, 353, 356-411, 414-428, 517-543, 546-548, 562-580, 591-626, 709-711, 736-738, 753-771, 780-804, 893-921, 925-926, 942, 971-995
terratorch/datasets/generic_pixel_wise_dataset.py                181     57     50     13    63%   100-101, 124-125, 130-131, 155, 168, 169->171, 281-301, 312-347, 445, 446->448, 454->457, 458->463, 460->463, 490->494, 495
terratorch/datasets/generic_scalar_label_dataset.py               95     68     24      0    23%   75-134, 137, 140-157, 160-174, 177-179, 229-243, 246-248, 251
terratorch/datasets/hls.py                                        20      1      0      0    95%   75
terratorch/datasets/landslide4sense.py                            86     65     14      0    21%   59-79, 82, 85-100, 103-155
terratorch/datasets/m_SA_crop_type.py                             87     11     14      7    82%   68-69, 85-86, 93, 108->110, 127-128, 133->136, 160-163, 165->168
terratorch/datasets/m_bigearthnet.py                              79      7     12      6    86%   68-69, 91-92, 99, 117->120, 135-136, 141->144, 156->159
terratorch/datasets/m_brick_kiln.py                               75      7     12      6    85%   70-71, 87-88, 95, 112->115, 131-132, 137->140, 150->153
terratorch/datasets/m_cashew_plantation.py                       106     11     22     10    84%   72-73, 91-92, 102->108, 104->102, 109->113, 116, 132->134, 152-153, 158->161, 185-188, 190->193
terratorch/datasets/m_chesapeake_landcover.py                     87     11     14      7    82%   54-55, 71-72, 79, 94->96, 112-113, 118->121, 145-148, 150->153
terratorch/datasets/m_eurosat.py                                  79      7     12      6    86%   68-69, 91-92, 99, 117->120, 137-138, 143->146, 157->160
terratorch/datasets/m_forestnet.py                                91     18     14      7    76%   66-67, 85-86, 93, 110->113, 116-120, 133-136, 139-142, 156-157, 162->165, 173->176
terratorch/datasets/m_neontree.py                                 87     11     14      7    82%   54-55, 71-72, 79, 94->96, 112-113, 117->120, 144-147, 149->152
terratorch/datasets/m_nz_cattle.py                               106     18     18      8    77%   58-59, 77-78, 85, 106->108, 111-113, 119-123, 144-145, 150->153, 177-180, 182->185
terratorch/datasets/m_pv4ger.py                                   83      7     14      6    87%   58-59, 77-78, 85, 102->105, 131-132, 137->140, 148->151
terratorch/datasets/m_pv4ger_seg.py                               97     11     16      7    84%   57-58, 76-77, 84, 100->102, 129-130, 135->138, 162-165, 167->170
terratorch/datasets/m_so2sat.py                                   76      7     12      6    85%   75-76, 92-93, 100, 117->120, 137-138, 143->146, 156->159
terratorch/datasets/multi_temporal_crop_classification.py        154     11     34     10    89%   96-97, 152, 183->188, 189->191, 202->204, 204->206, 217, 234-235, 250, 265-268, 276->279
terratorch/datasets/open_sentinel_map.py                         151    127     50      0    12%   52-94, 97-98, 101-106, 109, 112-134, 142-157, 160-228
terratorch/datasets/openearthmap.py                               70     48      4      0    30%   29-44, 47-69, 72-77, 80-83, 86, 89-96, 99-106, 109, 112
terratorch/datasets/pastis.py                                    161    143     60      0     8%   76-158, 161, 164, 167-252, 256-278, 287-316
terratorch/datasets/sen1floods11.py                              131     10     22      8    88%   80-81, 125, 133, 165->167, 177->179, 195-196, 205-206, 229-230, 237->240
terratorch/datasets/sen1floods11_lat_lon.py                      128     91     20      0    25%   57-96, 99, 103-115, 118-125, 128-141, 144-145, 157-172, 181-216
terratorch/datasets/sen4agrinet.py                               148    125     42      0    12%   67-88, 91, 94-127, 131-193, 196-218, 221-250, 253-254
terratorch/datasets/sen4map.py                                   126    107     16      0    13%   73-103, 107-117, 120, 123-186, 189-192, 201-217, 220-226
terratorch/datasets/transforms.py                                116     70     32      3    33%   13-20, 23-26, 36-37, 42, 52-53, 58-60, 68, 74-75, 78-83, 86, 100-117, 120-129, 132, 141-143, 146, 149, 156-157, 160, 163, 167-170, 182-185, 188-203
terratorch/datasets/utils.py                                     150     24     32      7    81%   56-59, 72-75, 110-112, 123, 125->127, 141->143, 144, 156, 165-171, 175-181, 188
terratorch/datasets/wsf.py                                        32     11      4      0    58%   58, 75-89
terratorch/io/file.py                                             34     19     10      2    43%   11-24, 29-47, 54->exit, 58-61
terratorch/models/__init__.py                                     15      3      0      0    80%   17-19
terratorch/models/backbones/__init__.py                            9      0      0      0   100%
terratorch/models/backbones/clay_v1/__init__.py                    3      0      0      0   100%
terratorch/models/backbones/clay_v1/embedder.py                   68     24     12      2    60%   66, 70-89, 93-99, 109-112, 116-125, 128-137, 154->162
terratorch/models/backbones/clay_v1/modules.py                   204    105     22      1    47%   39, 56-69, 84-91, 131-132, 136-164, 190-230, 238-279, 318-345, 349-380, 390-392, 429-435, 467-497, 504->501, 521-527, 530-533
terratorch/models/backbones/clay_v1/utils.py                      27     23      0      0    15%   5-13, 19-29, 33-42
terratorch/models/backbones/dofa_vit.py                          104     38     32      3    57%   98-104, 108-114, 128-134, 140-164, 171-177, 184
terratorch/models/backbones/mmearth_convnextv2.py                122    122     22      0     0%   4-251
terratorch/models/backbones/multimae/criterion.py                 99     82     16      0    15%   33-37, 41-65, 76-80, 83-87, 90-94, 98-130, 141-145, 148-152, 155-159, 163-195
terratorch/models/backbones/multimae/input_adapters.py            92     74     14      0    17%   54-71, 80-100, 112, 121-142, 177-196, 205-245, 254, 263-289
terratorch/models/backbones/multimae/multimae.py                 204    179     78      0     9%   71-143, 146-152, 155, 159-173, 185-189, 208-247, 262-279, 282-300, 329-418, 443-467, 480-488
terratorch/models/backbones/multimae/multimae_utils.py           143    114      4      0    20%   26, 34-49, 55-87, 108, 119-128, 135-136, 139, 142, 154-160, 163-169, 181-189, 192-207, 212-222, 225-247, 264-276, 284-286, 302-323, 331-336
terratorch/models/backbones/multimae/output_adapter_utils.py     102     85     16      0    14%   34-49, 52-64, 75-107, 117-130, 134-192, 211-236, 243-258, 262, 281-286, 296-303
terratorch/models/backbones/multimae/output_adapters.py          306    266     64      0    11%   81-142, 151-154, 158, 164-181, 184-234, 251-282, 303-311, 320-327, 330-336, 339, 342-343, 349-356, 394-415, 424-428, 431-437, 441-448, 451-478, 506-520, 529-533, 536-542, 546-553, 556-573, 603-648, 657-710, 719-726, 729-759
terratorch/models/backbones/multimae_register.py                 144    115     54      0    15%   22, 119, 130-158, 163, 177-214, 223-248, 253-254, 257-273, 284-306, 319-349, 361-390
terratorch/models/backbones/prithvi_mae.py                       334    177     68     10    45%   66->68, 76, 103-118, 125->exit, 159, 163->165, 171-180, 188-200, 205-214, 220-229, 272-273, 275, 317-337, 347, 373-406, 427-429, 431-432, 483-516, 520-527, 535-555, 566-605, 631-664, 676-684, 699-709, 724-733, 742-750, 758
terratorch/models/backbones/prithvi_swin.py                      148     92     70      4    30%   41-90, 95-98, 103-159, 170, 173-174, 191, 205-207, 239->241, 270->272
terratorch/models/backbones/prithvi_vit.py                       160     77     50      6    43%   98-122, 130-158, 162-171, 194-201, 221-222, 225, 232-234, 236-247, 250->263, 273, 313, 323, 334-337, 346-349, 359, 369, 379, 388, 398
terratorch/models/backbones/scalemae.py                          134     28     20      3    73%   102->112, 173->177, 203-215, 248-258, 261-285, 293-295, 309
terratorch/models/backbones/select_patch_embed_weights.py         32      2     18      4    88%   16, 39->exit, 43->47, 48
terratorch/models/backbones/swin_encoder_decoder.py              402     76    106     22    75%   89, 91, 137, 150, 160, 182-183, 189->193, 246-247, 272-275, 322, 336, 352, 355-370, 388->391, 394->396, 460, 544-545, 563-564, 742, 798-801, 915-920, 929-930, 999-1000, 1003-1019, 1023-1028, 1032-1036, 1040, 1053, 1056-1057
terratorch/models/backbones/torchgeo_resnet.py                   347    211    104      3    33%   106-110, 114-118, 123-127, 132-136, 141-145, 150-154, 159-163, 168-172, 177-181, 186-190, 195-199, 204-208, 213-217, 223-227, 232-236, 240-244, 248-252, 256-260, 264-268, 272-276, 280-284, 288-292, 296-300, 304-308, 312-318, 322-328, 335->337, 342-348, 352-358, 362-366, 370-374, 378-382, 386-390, 394-398, 402-406, 411-415, 419-423, 427-431, 435-439, 447-467, 469->476
terratorch/models/backbones/torchgeo_swin_satlas.py              168     78     46      2    48%   119-123, 127-131, 135-139, 143-147, 151-155, 159-163, 175-179, 183-187, 191-195, 199-203, 207-211, 215-219, 223-227, 235-255, 257->265
terratorch/models/backbones/torchgeo_vit.py                      129    129     32      0     0%   3-209
terratorch/models/backbones/unet.py                               73     57     26      0    16%   95-194, 197-208, 213-218, 221-226
terratorch/models/backbones/utils.py                              74     54     12      0    23%   28-39, 94-116, 128, 136-139, 183-203, 208-212, 242-263, 268-272, 320-336, 341-345
terratorch/models/clay_model_factory.py                           94     38     26      8    57%   34-38, 41, 45, 48-52, 107, 115-116, 120-121, 136-144, 163-183, 212->exit, 224, 229-233
terratorch/models/decoders/__init__.py                             8      0      0      0   100%
terratorch/models/decoders/aspp_head.py                          102     16     22      8    79%   92->95, 95->98, 98->101, 133->exit, 159-167, 169, 201-203, 239->exit, 246->248, 279-291, 297-300, 305-308
terratorch/models/decoders/fcn_decoder.py                         41      2      4      1    93%   60-61
terratorch/models/decoders/identity_decoder.py                    13      0      0      0   100%
terratorch/models/decoders/mlp_decoder.py                         20     13      0      0    35%   23-30, 34-39
terratorch/models/decoders/satmae_head.py                         86     73      8      0    14%   17-47, 58-64, 70-95, 103-132, 143-149, 154-182
terratorch/models/decoders/unet_decoder.py                        15      0      0      0   100%
terratorch/models/decoders/upernet_decoder.py                     77      0     16      0   100%
terratorch/models/decoders/utils.py                               31      8     12      4    63%   19, 27-28, 49->62, 51-57
terratorch/models/encoder_decoder_factory.py                      83     20     34      6    71%   28, 41-46, 53-56, 125-126, 132-139, 143-145, 226->exit
terratorch/models/generic_unet_model_factory.py                   95     75     22      0    17%   20-21, 27-42, 69-109, 115-124, 127, 131, 136-150, 153, 156, 160-170
terratorch/models/heads/__init__.py                                4      0      0      0   100%
terratorch/models/heads/classification_head.py                    23      7      4      2    67%   35-40, 52-53
terratorch/models/heads/regression_head.py                        41      6      6      1    85%   66-78
terratorch/models/heads/segmentation_head.py                      16      5      2      1    67%   27-36
terratorch/models/model.py                                        33      3      2      1    89%   21, 25, 29, 33->exit
terratorch/models/necks.py                                       126     28     16      3    74%   27->exit, 77-79, 82-87, 90, 102-103, 106-114, 117, 150, 175-176, 179-181, 184, 196-197
terratorch/models/peft_utils.py                                   78     56     18      0    23%   11, 20-23, 34-42, 46-58, 63-89, 92-95, 101-112
terratorch/models/pincers/unet_pincer.py                          80     65     20      0    15%   9-37, 40-47, 52-77, 80-90, 107-123, 126-154, 157-158, 163-168, 171
terratorch/models/pixel_wise_model.py                             76     11     28      3    83%   77, 80, 97-103, 131-132, 136-137
terratorch/models/prithvi_model_factory.py                        30      4      8      3    82%   84-88, 91->96, 93-94
terratorch/models/satmae_model_factory.py                        151    119     52      0    16%   31-34, 39-50, 55-72, 75, 79, 83-85, 89-91, 94, 150-293, 312-323, 334-344
terratorch/models/scalar_output_model.py                          55     16     14      4    65%   12-13, 54-60, 68, 71, 74, 98-99, 105-106, 108-109
terratorch/models/smp_model_factory.py                           130     52     42     13    54%   62, 65, 68, 72, 75, 127-128, 137-138, 145->152, 147, 154-171, 206, 228, 229->exit, 233-239, 244, 250-253, 257, 262-265, 271-287, 291-292
terratorch/models/timm_model_factory.py                           43     26     14      0    30%   42-66, 71-72, 75, 78-81, 84-85
terratorch/models/utils.py                                        10      0      4      0   100%
terratorch/models/wxc_model_factory.py                            94     72     24      0    19%   26-27, 30-32, 35-37, 40-41, 44, 56-147
terratorch/registry/__init__.py                                    6      0      0      0   100%
terratorch/registry/custom_registry.py                            11      3      2      1    69%   13-15
terratorch/registry/mmseg_registry.py                             53     30      8      1    39%   34-35, 38, 47-51, 54, 60-75, 78, 81, 84, 87, 90, 94-95
terratorch/registry/registry.py                                  105     13     28      5    83%   8->exit, 9->exit, 10->exit, 45->44, 47-48, 73-75, 78, 92-93, 96-97, 100, 156, 159
terratorch/registry/smp_registry.py                               59     12      6      3    77%   58-59, 64, 69-71, 81->84, 113, 116, 119, 129, 132, 141
terratorch/registry/timm_registry.py                              38     11      2      0    68%   30, 45-49, 52, 55, 58, 64, 67
terratorch/samplers/__init__.py                                    1      1      0      0     0%   3
terratorch/samplers/single.py                                     28     28      6      0     0%   3-38
terratorch/tasks/__init__.py                                      18      4      2      1    75%   12-15, 26->exit
terratorch/tasks/base_task.py                                     57     20     22      5    58%   32-35, 43-44, 48, 51, 56-75, 100
terratorch/tasks/classification_tasks.py                         108     47     22      6    58%   24-25, 118, 120, 122->125, 129, 160-161, 205, 219-230, 240-248, 258-273, 286-294
terratorch/tasks/loss_handler.py                                  37     19     10      2    43%   48-70, 92
terratorch/tasks/multilabel_classification_tasks.py               63     45      4      0    27%   25-30, 35-40, 43-59, 63-64, 67-78, 81-89, 92-100
terratorch/tasks/optimizer_factory.py                             17     11      2      0    32%   34-46
terratorch/tasks/regression_tasks.py                             187     38     50     16    74%   42-46, 71, 74, 79-80, 100->104, 107-111, 117, 208, 210, 212->215, 219, 237, 250-251, 272, 328, 333->344, 337-342, 360-361, 382-395
terratorch/tasks/segmentation_tasks.py                           141     74     40      7    45%   28-29, 121, 123, 125->128, 132, 159-162, 169-172, 218, 232-244, 254-271, 280-320, 333-355
terratorch/tasks/tiled_inference.py                               64     46     24      0    20%   64-197
terratorch/tasks/wxc_downscaling_task.py                         144    122     18      0    14%   36-116, 119-125, 130-133, 152-164, 168-177, 181-191, 201-211, 214, 217-221
terratorch/tasks/wxc_task.py                                      29     17      4      0    36%   11-18, 21, 24-32, 35, 38
tests/__init__.py                                                  0      0      0      0   100%
tests/test_backbones.py                                           92      2      4      0    98%   30, 35
tests/test_clay_tasks.py                                          41      3      6      1    91%   22, 84-85
tests/test_datasets.py                                           660     18     60      0    97%   56-84
tests/test_decoders.py                                            25      0      0      0   100%
tests/test_encoder_decoder_model_factory.py                      169     26     36      0    84%   178-196, 205-229, 238-263
tests/test_encoder_decoder_torchgeo_models.py                     85      0      8      0   100%
tests/test_finetune.py                                            43      0      2      1    98%   23->exit
tests/test_generic_dataset.py                                    106      0     10      0   100%
tests/test_multi_source_registry.py                               61      4      0      0    93%   21, 24, 102, 113
tests/test_prithvi_model_factory.py                               97      0     18      0   100%
tests/test_prithvi_tasks.py                                       51      1     12      0    98%   28
tests/test_prithvi_vit.py                                         27      0      0      0   100%
tests/test_registry.py                                            50      4      0      0    92%   22, 63, 67, 84
tests/test_smp_model_factory.py                                   41      0      0      0   100%
tests/test_train.py                                                2      0      0      0   100%
----------------------------------------------------------------------------------------------------------
TOTAL                                                          13680   6445   2990    322    48%

@romeokienzler
Copy link
Collaborator Author

Please also add a test for #397

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants