Download tests/test_missing_features.py from QPromaQ/Docking_project: direct link, hf CLI and curl.
- Browser
- Download file 1.34 kB
-
https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_missing_features.py
- Command line
-
hf download hf://datasets/QPromaQ/Docking_project@f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_missing_features.py
-
curl -L -o test_missing_features.py https://huggingface.co/datasets/QPromaQ/Docking_project/resolve/f0c54945b8efdf337d23cac2d5ca433de70a02da/tests/test_missing_features.py
1.34 kB
| from __future__ import annotations | |
| import unittest | |
| import numpy as np | |
| from libs.adaptive.features import FeatureBundle, FeatureValue, bundles_to_wide_frames | |
| class TestMissingFeatures(unittest.TestCase): | |
| def test_missing_features_are_masked_and_not_silent_zero(self) -> None: | |
| b1 = FeatureBundle( | |
| object_id="lig_1", | |
| features={ | |
| "f_present": FeatureValue(value=1.5, available=True, source="test", feature_type="exact"), | |
| "f_missing": FeatureValue(value=None, available=False, source="test", feature_type="proxy"), | |
| }, | |
| ) | |
| b2 = FeatureBundle( | |
| object_id="lig_2", | |
| features={ | |
| "f_present": FeatureValue(value=2.5, available=True, source="test", feature_type="exact"), | |
| "f_missing": FeatureValue(value=3.0, available=True, source="test", feature_type="proxy"), | |
| }, | |
| ) | |
| values, masks, names = bundles_to_wide_frames([b1, b2]) | |
| self.assertIn("f_missing", names) | |
| lig1 = values.loc[values["ligand_id"] == "lig_1"].iloc[0] | |
| lig1_mask = masks.loc[masks["ligand_id"] == "lig_1"].iloc[0] | |
| self.assertTrue(np.isnan(float(lig1["f_missing"]))) | |
| self.assertEqual(int(lig1_mask["mask_f_missing"]), 0) | |
| if __name__ == "__main__": | |
| unittest.main() | |