Skip to content

Commit

Permalink
Replace scipy usage with numpy
Browse files Browse the repository at this point in the history
  • Loading branch information
snuderl committed Sep 25, 2023
1 parent cc3d314 commit 9406aa2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scipy.stats
import numpy as np

from open_rarity.models.collection import Collection, CollectionAttribute
from open_rarity.models.token import Token
Expand Down Expand Up @@ -75,4 +75,9 @@ def _score_token(
collection_null_attributes=collection_null_attributes,
)

return scipy.stats.mstats.gmean(attr_scores, weights=attr_weights)
return g_mean(attr_scores, weights=attr_weights)


def g_mean(x, weights):
a = np.log(x)
return np.exp(np.average(a, axis=0, weights=weights))
6 changes: 1 addition & 5 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ authors = ["Dan Meshkov <[email protected]>", "Vicky Gong <vicky.gong@op
description = "Open-Rarity library is an open standard that provides an easy, explanable and reproducible computation for NFT rarity"
license = "Apache-2.0"
name = "open-rarity"
version = "0.7.4"
version = "0.7.5"

readme = "README.md"

Expand All @@ -25,7 +25,6 @@ numpy = ">=1.23.1"
pydantic = ">=1.9.1,<2.3"
python = ">=3.10,<3.13"
requests = ">=2.28.1"
scipy = ">=1.9.0"

[tool.poetry.group.dev.dependencies]
black = "^23.7.0"
Expand Down Expand Up @@ -53,6 +52,3 @@ known_first_party = "open_rarity"
multi_line_output = 3
profile = "black"

[[tool.mypy.overrides]]
module = ["scipy", "scipy.stats"]
ignore_missing_imports = true

0 comments on commit 9406aa2

Please sign in to comment.