From 18b2d4d33b1ae011bde086b96d8aea437832232f Mon Sep 17 00:00:00 2001 From: Bhavik Sheth Date: Tue, 3 Sep 2024 16:16:26 -0700 Subject: [PATCH] Prevent reordering of imports by auto formatter to avoid crashes (#3826) Summary: Pull Request resolved: https://github.com/facebookresearch/faiss/pull/3826 Apparently this is the generally accepted way to do this. https://usort.readthedocs.io/en/stable/guide.html#import-blocks What do you tihnk? Reviewed By: kuarora, mengdilin Differential Revision: D62147522 --- tests/torch_test_contrib.py | 11 ++++++----- tests/torch_test_neural_net.py | 17 +++++++++-------- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/tests/torch_test_contrib.py b/tests/torch_test_contrib.py index 429e7c0e91..e26a79c6bb 100644 --- a/tests/torch_test_contrib.py +++ b/tests/torch_test_contrib.py @@ -3,11 +3,12 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -import torch -import unittest -import numpy as np -import faiss -import faiss.contrib.torch_utils +import torch # usort: skip +import unittest # usort: skip +import numpy as np # usort: skip + +import faiss # usort: skip +import faiss.contrib.torch_utils # usort: skip class TestTorchUtilsCPU(unittest.TestCase): # tests add, search diff --git a/tests/torch_test_neural_net.py b/tests/torch_test_neural_net.py index 8a150de18c..ef37ac6a28 100644 --- a/tests/torch_test_neural_net.py +++ b/tests/torch_test_neural_net.py @@ -3,14 +3,15 @@ # This source code is licensed under the MIT license found in the # LICENSE file in the root directory of this source tree. -import torch -from torch import nn -import unittest -import numpy as np -import faiss - -from faiss.contrib import datasets -from faiss.contrib.inspect_tools import get_additive_quantizer_codebooks +import torch # usort: skip +from torch import nn # usort: skip +import unittest # usort: skip +import numpy as np # usort: skip + +import faiss # usort: skip + +from faiss.contrib import datasets # usort: skip +from faiss.contrib.inspect_tools import get_additive_quantizer_codebooks # usort: skip class TestLayer(unittest.TestCase):