📚 Dependencies

kNNpy makes use of the following packages:

These need to be installed before using the package, preferably in a fresh virtual environment (see instructions below).

💡 Optional dependencies

  • scikit-learn can be skipped if you do not intend to use the kNNpy.kNN_2D_Ang module
  • astropy-healpix can be skipped if you do not intend to use the Auxiliary.TPCF.TracerField2D module.
  • healpy and matplotlib can be skipped if you do not intend to use the kNNpy.kNN_2D_Ang, kNNpy.Auxiliary.TPCF.TracerField2D and kNNpy.Auxiliary.PeakStatistics modules.

🛠 Installation

🐧 Linux/macOS

Change to your preferred installation directory, create a Python virtual environment and install the dependencies.

⚠️ Warning: Do not use anaconda or miniconda for the virtual environment as it may cause conflicts with Pylians. Also, do not name the virtual environment kNNpy to avoid namespace issues.

cd /path/to/installation/directory
python3 -m venv kNNpy_env
source kNNpy_env/bin/activate
pip install numpy scipy pyfftw Pylians healpy scikit-learn astropy-healpix matplotlib

💡 Note on Pylians installation
Sometimes, the Pylians installation fails when using pip (especially on macOS). If that happens:

  • First install all other dependencies (without Pylians)
  • Then install Pylians in development mode following their official instructions:
    👉 Pylians_documentation

If you do not want the optional dependencies, replace the last line above by:

pip install numpy scipy pyfftw Pylians

📥 Clone this repository

git clone https://github.com/vikhyat108/kNNpy.git

🧭 Set your PYTHONPATH

Export the path to the installed repository to your Python path:

export PYTHONPATH="${PYTHONPATH}:/path/to/installation/directory/kNNpy/"

✅ Test the installation

To check if kNNpy is successfully installed and ready to use, run the following command:

cd /path/to/installation/directory/
cd kNNpy/Tests/
python3 import_all_modules.py

If you did not install the optional dependencies, replace the last line above by:

python3 import_required_modules.py

If no error message is returned, the installation is succesful.


🪟 Windows

Unfortunately, kNNpy is currently not supported on Windows. Future support may be added in later releases.


▶️ Usage

Change to your working directory:

cd /my/working/directory

Activate your virtual environment:

source /path/to/virtual/environment/bin/activate

Set the PYTHONPATH (if not already done) and in your Python scripts or notebooks, you can now:

import kNNpy

💡 Note: If you skipped the optional dependencies, use the from kNNpy import <MODULE NAME> idiom instead of import kNNpy.