Skip to content

Commit

Permalink
support numpy 2.x now that gguf-py does (#61)
Browse files Browse the repository at this point in the history
  • Loading branch information
vgel authored Jan 8, 2025
1 parent d95f608 commit 96b4e20
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 117 deletions.
10 changes: 3 additions & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,16 @@ authors = [{ name = "Theia Vogel", email = "theia@vgel.me" }]
readme = "README.md"
requires-python = ">=3.10"
dependencies = [
"numpy <2.0.0",
"numpy>=1.26.4",
"scikit-learn>=1.4.0",
"torch>=2.1.2",
"transformers>=4.36.2",
"tqdm>=4.66.1",
"gguf>=0.6.0",
"gguf>=0.13.0",
]

[dependency-groups]
dev = [
"pytest>=8.0.2",
"black>=24.2.0", # make sure to keep this in sync with .github/workflows/ci.yml
"ruff>=0.8.3",
]
dev = ["pytest>=8.0.2", "ruff>=0.8.3"]

[tool.pytest.ini_options]
python_files = ["tests.py"]
Expand Down
6 changes: 3 additions & 3 deletions repeng/extract.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,16 +227,16 @@ def __neg__(self) -> "ControlVector":
directions[layer] = -self.directions[layer]
return ControlVector(model_type=self.model_type, directions=directions)

def __mul__(self, other: int | float | np.int_ | np.float_) -> "ControlVector":
def __mul__(self, other: int | float | np.number) -> "ControlVector":
directions: dict[int, np.ndarray] = {}
for layer in self.directions:
directions[layer] = other * self.directions[layer]
return ControlVector(model_type=self.model_type, directions=directions)

def __rmul__(self, other: int | float | np.int_ | np.float_) -> "ControlVector":
def __rmul__(self, other: int | float | np.number) -> "ControlVector":
return self.__mul__(other)

def __truediv__(self, other: int | float | np.int_ | np.float_) -> "ControlVector":
def __truediv__(self, other: int | float | np.number) -> "ControlVector":
return self.__mul__(1 / other)


Expand Down
Loading

0 comments on commit 96b4e20

Please sign in to comment.