MCPcopy Create free account
hub / github.com/apple/ml-sharp / is_power_of_two

Method is_power_of_two

src/sharp/models/alignment.py:75–79  ·  view source on GitHub ↗

Check if a number is a power of two.

(n: int)

Source from the content-addressed store, hash-verified

73 dim_in = 2
74
75 def is_power_of_two(n: int) -> bool:
76 """Check if a number is a power of two."""
77 if n <= 0:
78 return False
79 return (n & (n - 1)) == 0
80
81 if not is_power_of_two(stride):
82 raise ValueError(f"Stride {stride} is not a power of two.")

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected