Skip to content
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

Merge ast and parser from forward #3

Merged
merged 68 commits into from
Jun 10, 2022
Merged
Changes from 1 commit
Commits
Show all changes
68 commits
Select commit Hold shift + click to select a range
53844ed
Update poetry configuration
Legotier May 6, 2022
e6a9c16
Add testreport to gitignore
Legotier May 6, 2022
0e4ffaa
Merge new stuff from forward into ast.py
Legotier May 6, 2022
7fbc8bd
Minimal changes to make the tests pass
Legotier May 6, 2022
4fc36c1
Rename float types to real types
Legotier May 6, 2022
c296998
Update docs to include new classes
Legotier May 6, 2022
9d167e3
Use autodata instead of autoclass for union types
Legotier May 6, 2022
7adbe0f
changed workflow to python version 3.9
LKlinke May 10, 2022
7021d76
Enable type aliases for union types in the docs
Legotier May 11, 2022
816dc31
Merge branch 'brand-new' of https://github.com/Philipp15b/probably in…
Legotier May 11, 2022
697e1d1
Remove forward type references in ast.py
Legotier May 11, 2022
b2ede13
resolved dep issues
May 11, 2022
1d5af7a
Disallow edges to None in ControlFlowGraph.to_networkx()
Legotier May 13, 2022
6eb0df9
Merge parser from forward
Legotier May 13, 2022
b8f7cf3
A helpful comment so people don't have to spend hours figuring out wh…
Legotier May 13, 2022
15f59e7
Update test_uniform_checks
Legotier May 13, 2022
9012370
Fix precedence of likelyhood operator
Legotier May 18, 2022
077a5eb
Add test for basic operator precedence
Legotier May 18, 2022
f8b3e08
Revert "Add test for basic operator precedence"
Legotier May 18, 2022
9cc3a75
Add test for basic operator precedence
Legotier May 18, 2022
8833b7f
Test for correct parsing of distributions
Legotier May 18, 2022
3835e4d
Test for using minus with likely
Legotier May 18, 2022
2afe578
Only allow natural numbers and parameters in distribution expressions
Legotier May 18, 2022
7912125
Revert "Only allow natural numbers and parameters in distribution exp…
Legotier May 19, 2022
ce569fb
Minor fixes
Legotier May 20, 2022
c179a25
Revert to older version (2.5) of networkx
Legotier May 20, 2022
5de84e6
Remove test for parser check that is no longer done
Legotier May 20, 2022
a3a3246
Clear parameter dict for every new program that is parsed
Legotier May 20, 2022
fe6feab
Fix almost all pylint problems
Legotier May 20, 2022
017ad52
Split ast module into several files
Legotier May 25, 2022
1bfd89c
I forgot to add the new files to git
Legotier May 25, 2022
9fd0257
Move documentation of ast module to __init__.py
Legotier May 25, 2022
8557c91
Fix pylint cyclic import warnings
Legotier May 25, 2022
e300fd3
Fix mypy errors
Legotier May 25, 2022
b22519b
Update mypy to newer version
Legotier May 25, 2022
9189730
Move Bounds class to types file
Legotier May 25, 2022
6ec6e8a
Move unused import to doctest
Legotier May 27, 2022
5bdf111
Merge typechecker from forward
Legotier May 27, 2022
3e25603
Add tests for some of the typechecking
Legotier May 27, 2022
965da72
Revert "Remove test for parser check that is no longer done"
Legotier May 27, 2022
8404efa
Fix bug in typechecking test
Legotier May 27, 2022
02dc6dd
Remove 'parameters' parameter from Program.from_parse
Legotier May 27, 2022
9943cb9
Remove VarExpr.is_parameter
Legotier May 27, 2022
a1f93d9
Fix unsafe return type of get_type for iid expressions
Legotier Jun 1, 2022
8cc2a56
Prettify linear checks
Legotier Jun 1, 2022
2aa93a3
Fix unsafe default value warning
Legotier Jun 1, 2022
f96efa4
Add some old checks from the parser to the typechecker
Legotier Jun 1, 2022
ecd08e9
Fix precedence of modulo operator
Legotier Jun 2, 2022
476940a
Fix (suppressed) cyclic dependency warnings
Legotier Jun 2, 2022
16e31c4
Fix typechecking for IidSampleExpr
Legotier Jun 2, 2022
5ab560c
Give some binary operators clearer names
Legotier Jun 2, 2022
0da4e94
Replace not_a_variable and add a warning to the typechecker
Legotier Jun 2, 2022
6158b37
Make it more explicit that iid type checking is unsafe
Legotier Jun 2, 2022
7e8c180
Logger warning for typechecking of iid exprs
Legotier Jun 3, 2022
6247646
Update parameter in syntax module
Legotier Jun 3, 2022
bb071e1
Fix warnings
Legotier Jun 3, 2022
579fdf6
Disallow constants in programs in the syntax module
Legotier Jun 3, 2022
0a598c2
Make some variable names (true, false) illegal
Legotier Jun 3, 2022
12167a5
Eliminate true and false from pgcl grammar
Legotier Jun 3, 2022
e606806
Revert "Eliminate true and false from pgcl grammar"
Legotier Jun 8, 2022
4d4c322
Fix error message in check_is_linear_expr
Legotier Jun 8, 2022
21ae331
Add assertion for illegal keyword to constructor of VarExpr
Legotier Jun 8, 2022
f1d923a
Better error message for usage of true or false in plot instructions
Legotier Jun 8, 2022
79991b9
Allow variables in distribution parameters
Legotier Jun 9, 2022
1777e88
Remove program config
Legotier Jun 9, 2022
3af0bf5
Add typecheck for TickInstr and TickExpr
Legotier Jun 9, 2022
2dd1aa3
Auto format
Legotier Jun 9, 2022
a2adf9f
Add format target to makefile
Legotier Jun 9, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Fix (suppressed) cyclic dependency warnings
  • Loading branch information
Legotier committed Jun 2, 2022
commit 476940ac6d605d9ee1ca423479dbdfe102fa5104
5 changes: 1 addition & 4 deletions probably/pgcl/ast/__init__.py
Original file line number Diff line number Diff line change
@@ -117,10 +117,7 @@
.. autoclass:: Node
"""

Var = str

# pylint: disable=wrong-import-position, cyclic-import
from .declarations import VarDecl, ConstDecl, ParameterDecl, Decl
from .declarations import VarDecl, ConstDecl, ParameterDecl, Decl, Var
from .expressions import VarExpr, BoolLitExpr, NatLitExpr, RealLitExpr, BinopExpr, UnopExpr, \
SubstExpr, CategoricalExpr, TickExpr, DUniformExpr, CUniformExpr, GeometricExpr, PoissonExpr, LogDistExpr, \
BinomialExpr, BernoulliExpr, Binop, Unop, Expr, ExprClass, DistrExpr, IidSampleExpr, expr_str_parens
3 changes: 3 additions & 0 deletions probably/pgcl/ast/ast.py
Original file line number Diff line number Diff line change
@@ -2,6 +2,9 @@
import attr


Var = str


@attr.s
class Node(ABC):
"""Superclass for all node types in the AST."""
4 changes: 2 additions & 2 deletions probably/pgcl/ast/declarations.py
Original file line number Diff line number Diff line change
@@ -4,13 +4,13 @@
from abc import abstractmethod
import attr
from .expressions import Expr
from .ast import Node
from . import Var
from .ast import Node, Var
from .types import Type, BoolType, NatType, RealType


class DeclClass(Node):
"""Superclass for all declarations. See :obj:`Decl`."""

@abstractmethod
def __str__(self) -> str:
"""
5 changes: 2 additions & 3 deletions probably/pgcl/ast/expressions.py
Original file line number Diff line number Diff line change
@@ -9,8 +9,7 @@

from abc import abstractmethod
import attr
from .ast import Node
from . import Var
from .ast import Node, Var

class ExprClass(Node):
"""
@@ -427,7 +426,7 @@ class CategoricalExpr(ExprClass):
validator=_check_categorical_exprs)

def distribution(self) -> List[Tuple[RealLitExpr, Expr]]:
r"""
"""
Return the distribution of possible values as a list along with
probabilities.
"""
3 changes: 1 addition & 2 deletions probably/pgcl/ast/instructions.py
Original file line number Diff line number Diff line change
@@ -7,8 +7,7 @@

import attr
from .expressions import NatLitExpr, VarExpr, RealLitExpr, Expr
from .ast import Node
from . import Var
from .ast import Node, Var

class InstrClass(Node):
"""Superclass for all instructions. See :obj:`Instr`."""
2 changes: 1 addition & 1 deletion probably/pgcl/ast/program.py
Original file line number Diff line number Diff line change
@@ -4,11 +4,11 @@
import copy

import attr
from . import Var
from .types import Type
from .declarations import Decl, ParameterDecl, VarDecl, ConstDecl
from .expressions import Expr
from .instructions import Instr
from .ast import Var

@attr.s(frozen=True)
class ProgramConfig:
3 changes: 2 additions & 1 deletion probably/pgcl/ast/walk.py
Original file line number Diff line number Diff line change
@@ -38,7 +38,8 @@

from probably.util.ref import Mut

from . import Expr, ExprClass, Instr, InstrClass
from .expressions import Expr, ExprClass
from .instructions import Instr, InstrClass

T = TypeVar("T")