Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
CyanLight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
fxk8y
CyanLight
Commits
06bee48f
Commit
06bee48f
authored
3 years ago
by
fxk8y
Browse files
Options
Downloads
Patches
Plain Diff
………
parent
6e621c5f
No related branches found
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
SiliconTorch/DecoratorTest.py
+42
-0
42 additions, 0 deletions
SiliconTorch/DecoratorTest.py
SiliconTorch/Device.py
+24
-0
24 additions, 0 deletions
SiliconTorch/Device.py
with
66 additions
and
0 deletions
SiliconTorch/DecoratorTest.py
0 → 100644
+
42
−
0
View file @
06bee48f
class
MyDec
:
def
__init__
(
*
args
,
**
kwargs
):
print
(
f
'
__init__ed with:
{
args
}
aaand:
{
kwargs
}
'
)
def
__call__
(
self
,
*
args
,
**
kwargs
):
print
(
f
'
called with:
{
args
}
aaand:
{
kwargs
}
'
)
if
callable
(
args
[
0
]):
print
(
'
used as decorated with arguments
'
)
return
self
.
execute
else
:
print
(
'
used as decorator WITHOUT arguments (a long time ago ;) )
'
)
self
.
execute
()
def
execute
(
*
args
,
**
kwargs
):
print
(
f
'
executed with:
{
args
}
aaand:
{
kwargs
}
'
)
class
C
:
@MyDec
def
decorated0
(
self
,
*
args
):
print
(
f
'
decorated0 called with:
{
args
}
'
)
return
'
decorated0
'
print
(
'
\n
'
+
'
-
'
*
120
+
'
\n
'
)
class
D
:
@MyDec
(
name
=
'
ctor-test
'
)
def
decorated42
(
self
,
*
args
):
print
(
f
'
decorated42 called with:
{
args
}
'
)
return
'
decorated42
'
c
=
C
()
d
=
D
()
This diff is collapsed.
Click to expand it.
SiliconTorch/Device.py
+
24
−
0
View file @
06bee48f
...
...
@@ -3,6 +3,9 @@ from typing import Any, Callable
# TODO: dev is stalled!
# at first, we'll design easier things to not loose focus on the project
# Just use simple properties and triggers to get the same (write-only) behavior
class
MQTTProperty
:
def
__init__
(
self
,
name
:
str
=
None
,
initialValue
:
Any
=
None
,
getConvert
:
Callable
[[
str
],
Any
]
=
None
,
setConvert
:
Callable
[[
Any
],
str
]
=
None
,
readOnly
=
False
):
...
...
@@ -49,6 +52,27 @@ class MQTTProperty:
class
MQTTTrigger
:
def
__init__
(
self
):
pass
class
Device
:
def
__init__
(
self
,
torch
,
name
,
online
=
True
):
...
...
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