-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for references in formulas for Stock's initial value.
Previously, you couldn't include references in initial formulas, because we didn't have support for detecting cycles in those references. Now we do! If there aren't any circular references, then we'll properly create the initial values, and otherwise we'll throw a systems.errors.CircularReferences exception.
- Loading branch information
Showing
8 changed files
with
114 additions
and
46 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
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,22 @@ | ||
"Collection of reused algorithms." | ||
|
||
|
||
def find_cycles(in_graph, out_graph): | ||
cycles = out_graph.copy() | ||
deps = [] | ||
changed = True | ||
while changed: | ||
changed = False | ||
for node, edges in cycles.items(): | ||
# if you have no incoming edges and do have outgoing edges, | ||
# then trim those edges away | ||
if in_graph[node] == [] and edges != []: | ||
for edge in edges: | ||
in_graph[edge].remove(node) | ||
cycles[node] = [] | ||
deps.append(node) | ||
changed = True | ||
|
||
has_cycle = any([len(x) > 0 for x in cycles.values()]) | ||
deps = list(reversed(deps)) | ||
return has_cycle, cycles, deps |
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