Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
prodigy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Winkler
prodigy
Commits
ceb9ea46
Commit
ceb9ea46
authored
2 years ago
by
Tobias Winkler
Browse files
Options
Downloads
Patches
Plain Diff
extended python demo file and minor cleanup
parent
ab5ecd20
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
python/test.py
+23
-4
23 additions, 4 deletions
python/test.py
src/Dist.h
+5
-1
5 additions, 1 deletion
src/Dist.h
with
28 additions
and
5 deletions
python/test.py
+
23
−
4
View file @
ceb9ea46
import
pygin
# pygin python bindings demo
import
pygin
as
pg
FALSE
=
pg
.
troolean
(
0
)
TRUE
=
pg
.
troolean
(
1
)
UNKNOWN
=
pg
.
troolean
(
2
)
def
check_if_zero
(
dist
):
if
dist
.
is_zero
()
==
FALSE
:
print
(
"
given distribution does not have zero mass
"
)
elif
dist
.
is_zero
()
==
TRUE
:
print
(
"
given distribution has zero mass
"
)
elif
dist
.
is_zero
()
==
UNKNOWN
:
print
(
"
it is unknown if given distribution has zero mass
"
)
if
__name__
==
"
__main__
"
:
dist
=
pygin
.
geometric
(
"
x
"
,
"
1/2
"
)
print
(
dist
.
E
(
"
x
"
))
geom_param
=
"
p
"
var
=
"
x
"
dist
=
pygin
.
Dist
(
"
1
"
);
dist
=
pg
.
geometric
(
var
,
geom_param
)
print
(
f
"
expected value of a
{
geom_param
}
-geometric distribution is
{
dist
.
E
(
var
)
}
"
)
check_if_zero
(
dist
)
check_if_zero
(
pg
.
Dist
(
"
0
"
))
This diff is collapsed.
Click to expand it.
src/Dist.h
+
5
−
1
View file @
ceb9ea46
...
...
@@ -63,16 +63,19 @@ namespace prodigy {
_params
.
clear
();
_vars
.
clear
();
}
private
:
static
str2sym
paramsAndVars
();
public
:
static
bool
isSymbKnown
(
const
std
::
string
&
s
);
static
bool
isKnownAsVar
(
const
std
::
string
&
s
);
static
bool
isKnownAsParam
(
const
std
::
string
&
s
);
static
bool
test
()
{
return
true
;
}
private
:
static
bool
isSymbKnown
(
const
symbol
&
s
);
static
bool
isKnownAsVar
(
const
symbol
&
s
);
static
bool
isKnownAsParam
(
const
symbol
&
s
);
...
...
@@ -83,6 +86,7 @@ namespace prodigy {
* new symbols are created for unknown names, but they are not registered
*/
static
ex
parseWithKnownSymbs
(
const
std
::
string
&
s
);
static
void
registerAllUnknownSymbsAsVars
(
const
ex
&
e
);
static
void
registerAllUnknownSymbsAsParams
(
const
ex
&
e
);
static
void
registerAsVar
(
const
symbol
&
p
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment