-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
minifying pynars requirements to allow running in constrained environ… #103
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,7 +10,6 @@ | |
from ordered_set import OrderedSet | ||
from typing import Set | ||
from pynars.utils.tools import list_contains | ||
import numpy as np | ||
from pynars.Global import States | ||
|
||
|
||
|
@@ -358,9 +357,13 @@ def equal(self, o: Type['Compound']) -> bool: | |
set2: Iterable[Term] = o.terms - self.terms | ||
if len(set1) == len(set2) == 0: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I meant to put the comment on the equality function. Couldnt we end on this line? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that’s a question for @bowen-xu There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It is for handling variable things. |
||
return True | ||
eq_array = np.array([[term1.equal(term2) | ||
for term2 in set2] for term1 in set1]) | ||
if np.prod(eq_array.sum(axis=0)) > 0 and np.prod(eq_array.sum(axis=1)) > 0: | ||
# ChatGPT: directly returns the result of the logical AND condition, | ||
# checking if all column sums and all row sums are greater than zero. | ||
# This uses the built-in all() function to ensure every sum in each direction (column and row) | ||
# is greater than zero. The zip(*eq_array) unpacks each row of eq_array into columns. | ||
eq_array = [[term1.equal(term2) | ||
for term2 in set2] for term1 in set1] | ||
if all(sum(col) > 0 for col in zip(*eq_array)) and all(sum(row) > 0 for row in eq_array): | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In terms of numpy equivalence, I think in this case they are equivalent, but not in all cases. I can see a difference in the behaviors of the previous code vs this code if the "sum()" values could possibly result in negative integers/floats. I think that will not be an issue here, since it seems like we are summing Boolean values here, which are interpreted as 1 and 0. Though summing Booleans in the first place seems iffy. |
||
return True | ||
else: | ||
return False | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# ale-py>=0.7.3 | ||
# git+git://github.com/mila-iqia/atari-representation-learning.git | ||
# AutoROM>=0.4.2 | ||
# AutoROM.accept-rom-license>=0.4.2 | ||
bidict>=0.21.2 | ||
depq>=1.5.5 | ||
jstyleson>=0.0.2 | ||
lark==0.12.0 | ||
ordered-set>=4.0.2 | ||
sty>=1.0.0rc2 | ||
tqdm<=3.1.4 | ||
typing>=3.7.4.3 | ||
typing_extensions>=4.0.1 | ||
sparse-lut>=1.0.0 | ||
miniKanren>=1.0.3 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems pretty complicated. Is it not enough to check equality of 1.) term connector and 2.) constituent terms?