Skip to content

Conversation

@theelderbeever
Copy link
Collaborator

No description provided.



class TokenCollection:
""" """
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a placeholder. Needs the docstring completed


def __init__(
self,
token_type: Literal["non-fungible", "semi-fungible"],
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps should alias it as a type?

"metric.information",
"metric.information_entropy",
"metric.unique_trait_count",
"metric.max_trait_information",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is max_trait_information? Also suggest to make it a type with enums

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the maximum information content on a single trait for a token. It doesn't have a fixed value so Enums wouldn't apply here.


@property
def entropy(self) -> float | None:
return self._entropy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

entropy is also computed and should follow the same assignment pattern in the code, no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this self._entropy is the calculated value and using @property to decorate a method like this effectively creates a read only variable.

"metric.max_trait_information",
],
...,
] = ("metric.unique_trait_count", "metric.information_entropy"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that assignment looks a bit cryptic to me. Should We simplify this by bringing the type to some predefined static variable something like OR_SORT_FUNCTION =("metric.unique_trait_count", "metric.information_entropy")

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am indifferent. Its the openrarity library and a default value was provided so it can be assumed that it is the OR preferred one. Masking it with a static variable will mess up introspection I believe.

return self._input_checksum + self._ranks_checksum

@overload
def rank_collection( # type: ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need better documentation in methods , otherwsie not clear why those overloads exists and why we need them

"metric.unique_trait_count",
"metric.max_trait_information",
],
...,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not familiar with ... syntax, what is it doing?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The ... in tuple[] just means that it can be of arbitrary length. So specifically the above typing says that it is a tuple with any number of the above literal values.

(self._token_supply, self._tokens) = validate_tokens(token_type, tokens)

# Derived data
self._vertical_attribute_data: list[ValidatedTokenAttribute] = []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is vertical_attribute_data? Not clear naming suggest to rename

return json.loads(Path(path).read_text())


def from_csv(path: str | Path) -> dict[str | int, dict[Any, Any]]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

perhaps remove it? why keep not implemented method?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Was thinking it would be implemented eventually but honestly now I really don't intend to.

Parameters
----------
counts : list[AttributeStatistic]
_description_
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

doc

AttributeStatistic,
{
**attr,
"metric.probability": min(1, attr["attribute.supply"] / total),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how it can be >1, if it's >1 it's more like a bug no?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

numeric precision

{
**attr,
"metric.probability": min(1, attr["attribute.supply"] / total),
"metric.information": max(0, -log2(attr["attribute.supply"] / total)),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same comment here , not sure if we should be defensive in code here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again numeric precision

list[AttributeStatistic]
Augmented Tokens
"""
return []
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

?

def count_traits(
attributes: list[MetadataAttribute],
) -> list[MetadataAttribute]:
"""Count the number of traits on a given token and append it as an attribute named
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure i understand the logic , how it's working ? in the code is can see how we append something to an array.

Copy link
Collaborator Author

@theelderbeever theelderbeever Jan 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code uses list comprehension to generate the array with the token and its count. Documentation can be better though.

In python doing

lst = []
for val in something:
  lst.append(val)

is significantly less performant than list comprehensions. List comprehensions are very pythonic so I am going to fight back against removing them.

List comp

lst = [val for val in something]

from tqdm.asyncio import tqdm_asyncio # type: ignore


async def semaphore_gather(num: int, coros: Coroutine[Any, Any, Any]) -> list[Any]:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps small doc on utility of this asyncIO tooling will be helpful

pandas = "^1.4.3"
scipy = "^1.9.0"
requests = "^2.28.1"
aiolimiter = "^1.0.0"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'd like us to keep depdency footprint limited. Let's discuss in chat what each new dependency brings.

@@ -0,0 +1,555 @@
# import argparse
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

commented code need to remove it or keep it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants