File: packing.py

package info (click to toggle)
python-laspy 2.5.4-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,928 kB
  • sloc: python: 9,065; makefile: 20
file content (20 lines) | stat: -rw-r--r-- 463 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
""" This module contains functions to pack and unpack point dimensions
"""

import numpy as np


def least_significant_bit_set(mask: int) -> int:
    """Return the least significant bit set

    The index is 0-indexed.
    Returns -1 is no bit is set

    >>> least_significant_bit_set(0b0000_0001)
    0
    >>> least_significant_bit_set(0b0001_0000)
    4
    >>> least_significant_bit_set(0b0000_0000)
    -1
    """
    return (mask & -mask).bit_length() - 1