Skip to main content

Eye prescription validation and conversion tools for eyeglasses and contact lenses.

Project description

👁️ EyeTestUtils — Eye Test & Contact Lens Utilities

EyeTestUtils is a Python library that helps you validate, convert, and format eye test and contact lens data easily.
It’s designed for developers building optical systems, clinics, or vision-related applications.


🚀 Features

  • ✅ Validate eye test values (SPH, CYL, AXIS, PD, ADD)
  • 🔄 Convert prescription data to contact lens parameters (Spheric / Toric)
  • 🧮 Calculate and validate vertex distance
  • 🧠 Normalize numeric formats (±00.00)
  • ⚙️ Ready to integrate with Django, FastAPI, or desktop apps

📦 Installation

From PyPI:

pip install eyeTestUtils

From source:

pip install -e .

🧰 Basic Usage

1️⃣ Validate eye test values

    from eyetools import EyeTestValidator

    validator = EyeTestValidator()

    print(validator.is_multiple_of_quarter(1.25))  # ✅ True
    print(validator.is_multiple_of_quarter(1.33))  # ❌ False

    # Axis validation
    print(validator.check_axis(180))  # ✅ True
    print(validator.check_axis(-1))    # ❌ False
    print(validator.check_axis(190))    # ❌ False

    # Add validation
    print(validator.check_add(2.25))  # ✅ True
    print(validator.check_add(-2.25))  # ❌ False

2️⃣ Convert to contact lens values

    from eyetools import ContactLensValidator

    validator = ContactLensValidator()
    data = {
    "SPH": "3.00",
    "CY": "-1.25",
    "AX": "90",
    "BV": "12", # optional
    "ADD": "0.00" # optional
    }

    toric_lens = validator.convert_to_toric(data)
    print(toric_lens)
    # Expected output:
    # {
    #   "Exact SPH": "+03.11",
    #   "Exact CY": "-1.32",
    #   "SPH": "+03.00",
    #   "CY": "-1.25",
    #   "AX": "090",
    #   "BV": "12",
    #   "ADD": "0.00" 
    # }
    
    spheric_lens = validator.convert_to_spheric(data)
    print(spheric_lens)
    # Expected output:
    # {
    #   "Exact SPH": "+02.38",
    #   "SPH": "+02.50",
    #   "BV": "12",
    #   "ADD": "0.00" 
    # }

Format powers

    from eyetools import EyeTestValidator

    validator = EyeTestValidator()

    print(validator.is_valida_eye_test_power(-1.25))   # "-01.25"
    print(validator.remove_sign("-2.50"))              # "2.50"

Vertex distance check

    from eyetools import EyeTestValidator

    validator = EyeTestValidator()

    print(validator.Check_vertex_distance(12))  # ✅ True
    print(validator.Check_vertex_distance(20))  # ❌ False

🧪 Testing

Run all tests using pytest:

pytest -v

eyetools/ ├── eyetools/ │ ├── init.py │ └── validators.py ├── tests/ │ ├── test_eye_validator.py │ └── test_contact_validator.py ├── LICENSE
├── pyproject.toml └── README.md

💡 Contributing

We welcome contributions! If you have suggestions for improving validation rules, finding bugs, or adding new features, please open an issue or submit a Pull Request.

GitHub Repository: https://github.com/Elhussin/eye-test-utils-python.git

👨‍💻 Author

Elhussini Taha Optical systems & Web developer 💡

GitHub

LinkedIn

💬 Support & Contact

If you have any questions, need technical support, or want to discuss features, feel free to reach out:

📜 License

This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

eyetestutils-0.1.1.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

eyetestutils-0.1.1-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

File details

Details for the file eyetestutils-0.1.1.tar.gz.

File metadata

  • Download URL: eyetestutils-0.1.1.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for eyetestutils-0.1.1.tar.gz
Algorithm Hash digest
SHA256 f98e0d0292a41df8f166ccfc6c061cfef6f5c9c0deb075a0a03d0b408acd7e68
MD5 69fd56ae265ca6e6edb3da08ee1e9b67
BLAKE2b-256 51e0f4db9d89f8e555addad3f5124a11594197e37803e8f79626907758eaaa33

See more details on using hashes here.

File details

Details for the file eyetestutils-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: eyetestutils-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for eyetestutils-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a4d0b9d8b41425bc2b0d222e161b23dd38e5f5555b76eab6517c37c5a51fc4a1
MD5 c03a913188d0d0f7435f128dca5f42eb
BLAKE2b-256 fac4980a3e83f1000d9b7ef155810173f1afef7aef0e44d98aeb18ca1c6ce69e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page