Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
Pytorch Without Pytorch
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
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Falguni Ghosh
Pytorch Without Pytorch
Commits
255bdd6d
Commit
255bdd6d
authored
Oct 15, 2023
by
Falguni Ghosh
Browse files
Options
Downloads
Patches
Plain Diff
Upload New File
parent
121b18c8
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
0_Python_playground/pattern.py
+75
-0
75 additions, 0 deletions
0_Python_playground/pattern.py
with
75 additions
and
0 deletions
0_Python_playground/pattern.py
0 → 100644
+
75
−
0
View file @
255bdd6d
import
numpy
as
np
import
matplotlib.pyplot
as
plt
class
Checker
:
res
=
None
ts
=
None
output
=
None
def
__init__
(
self
,
res
,
tile_size
):
self
.
res
=
res
self
.
ts
=
tile_size
def
draw
(
self
):
if
(
self
.
res
%
(
2
*
self
.
ts
))
==
0
:
base_pat
=
np
.
zeros
((
2
*
self
.
ts
,
(
2
*
self
.
ts
)))
base_pat
[
0
:
self
.
ts
,
self
.
ts
:(
2
*
self
.
ts
)]
=
1
base_pat
[
self
.
ts
:
(
2
*
self
.
ts
),
0
:
self
.
ts
]
=
1
self
.
output
=
np
.
tile
(
base_pat
,
((
self
.
res
//
(
2
*
self
.
ts
),
self
.
res
//
(
2
*
self
.
ts
))))
return
self
.
output
.
copy
()
def
show
(
self
):
plt
.
imshow
(
self
.
output
,
cmap
=
'
gray
'
)
plt
.
axis
(
'
off
'
)
plt
.
show
()
return
class
Circle
:
res
=
None
radius
=
None
(
x
,
y
)
=
(
None
,
None
)
img
=
None
def
__init__
(
self
,
resolution
,
radius
,
position
):
self
.
res
=
resolution
self
.
radius
=
radius
self
.
x
=
position
[
0
]
self
.
y
=
position
[
1
]
self
.
output
=
np
.
ones
((
self
.
res
,
self
.
res
))
def
draw
(
self
):
w
=
np
.
arange
(
0
,
self
.
res
)
X
,
Y
=
np
.
meshgrid
(
w
,
w
)
Z
=
((
X
-
self
.
x
)
**
2
+
(
Y
-
self
.
y
)
**
2
)
>
self
.
radius
**
2
# Z = ((X - self.x) ** 2 + (Y - (self.res - 1 - self.y)) ** 2) > self.radius ** 2
self
.
output
[
Z
]
=
0
return
np
.
copy
(
self
.
output
)
def
show
(
self
):
plt
.
imshow
(
self
.
output
,
cmap
=
'
gray
'
)
plt
.
axis
(
'
off
'
)
plt
.
show
()
return
class
Spectrum
:
res
=
None
output
=
None
def
__init__
(
self
,
resolution
):
self
.
res
=
resolution
def
draw
(
self
):
gs
=
np
.
arange
(
0
,
self
.
res
,
1
)
/
(
self
.
res
-
1
)
#meshgrid
r
=
np
.
tile
(
gs
,
(
self
.
res
,
1
))
b
=
np
.
tile
((
np
.
arange
(
self
.
res
-
1
,
-
1
,
-
1
)
/
(
self
.
res
-
1
)),
(
self
.
res
,
1
))
g
=
np
.
array
(
r
).
T
self
.
output
=
np
.
dstack
((
r
,
g
,
b
))
return
self
.
output
.
copy
()
def
show
(
self
):
plt
.
imshow
(
self
.
output
)
plt
.
axis
(
'
off
'
)
plt
.
show
()
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