-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
2,699 additions
and
193 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
from .copycat import Copycat, Reporter # noqa | ||
from .problem import Problem | ||
from .plot import plot_answers | ||
from .io import save_answers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
from .copycat import Copycat | ||
|
||
from pprint import pprint | ||
|
||
class Problem: | ||
def __init__(self, initial, modified, target, iterations, distributions=None, formulas=None): | ||
self.formulas = formulas | ||
if formulas is not None: | ||
assert hasattr(Copycat(), 'temperature') | ||
else: | ||
if hasattr(Copycat(), 'temperature'): | ||
self.formulas = set(Copycat().temperature.adj_formulas()) | ||
print(self.formulas) | ||
self.initial = initial | ||
self.modified = modified | ||
self.target = target | ||
|
||
self.iterations = iterations | ||
if distributions is None: | ||
self.distributions = self.solve() | ||
else: | ||
self.distributions = distributions | ||
print(self.formulas) | ||
|
||
def test(self, comparison, expected=None): | ||
print('-' * 120) | ||
print('Testing copycat problem: {} : {} :: {} : _'.format(self.initial, | ||
self.modified, | ||
self.target)) | ||
print('expected:') | ||
if expected is None: | ||
expected = self.distributions | ||
pprint(expected) | ||
|
||
actual = self.solve() | ||
print('actual:') | ||
pprint(actual) | ||
comparison(actual, expected) | ||
print('-' * 120) | ||
|
||
def solve(self): | ||
print('-' * 120) | ||
print('Testing copycat problem: {} : {} :: {} : _'.format(self.initial, | ||
self.modified, | ||
self.target)) | ||
copycat = Copycat() | ||
answers = dict() | ||
if self.formulas == None: | ||
if hasattr(copycat, 'temperature'): | ||
formula = copycat.temperature.getAdj() | ||
else: | ||
formula = None | ||
answers[formula] = copycat.run(self.initial, | ||
self.modified, | ||
self.target, | ||
self.iterations) | ||
else: | ||
print(self.formulas) | ||
for formula in self.formulas: | ||
copycat.temperature.useAdj(formula) | ||
answers[formula] = copycat.run(self.initial, | ||
self.modified, | ||
self.target, | ||
self.iterations) | ||
print('Done with {}'.format(formula)) | ||
return answers | ||
|
||
def generate(self): | ||
self.distributions = self.solve() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.