forked from lcompilers/lpython
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from virendrakabra14/list_reverse_tmp
merge `main` into `list_reverse`
- Loading branch information
Showing
577 changed files
with
12,204 additions
and
2,949 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from lpython import i32, f64, c32, c64 | ||
from numpy import empty | ||
|
||
def main0(): | ||
x: i32[4, 5, 2] = empty([4, 5, 2]) | ||
y: f64[24, 100, 2, 5] = empty([24, 100, 2, 5]) | ||
print(x.size) | ||
print(y.size) | ||
|
||
assert x.size == 40 | ||
assert y.size == 24000 | ||
|
||
def main1(): | ||
a: c32[12] = empty([12]) | ||
b: c64[15, 15, 10] = empty([15, 15, 10]) | ||
print(a.size) | ||
print(b.size) | ||
|
||
assert a.size == 12 | ||
assert b.size == 2250 | ||
|
||
main0() | ||
main1() |
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,90 @@ | ||
from lpython import i32, f64, c32, c64, u32 | ||
from numpy import empty, size | ||
|
||
def main0(): | ||
x: i32[4, 5, 2] = empty([4, 5, 2]) | ||
y: f64[24, 100, 2, 5] = empty([24, 100, 2, 5]) | ||
z: i32 | ||
w: i32 | ||
z = 2 | ||
w = 3 | ||
print(size(x)) | ||
print(size(x, 0)) | ||
print(size(x, 1)) | ||
print(size(x, 2)) | ||
print(size(y)) | ||
print(size(y, 0)) | ||
print(size(y, 1)) | ||
print(size(y, z)) | ||
print(size(y, w)) | ||
|
||
assert size(x) == 40 | ||
assert size(x, 0) == 4 | ||
assert size(x, 1) == 5 | ||
assert size(x, 2) == 2 | ||
assert size(y) == 24000 | ||
assert size(y, 0) == 24 | ||
assert size(y, 1) == 100 | ||
assert size(y, z) == 2 | ||
assert size(y, w) == 5 | ||
|
||
def main1(): | ||
a: c32[12] = empty([12]) | ||
b: c64[15, 15, 10] = empty([15, 15, 10]) | ||
c: i32 | ||
d: i32 | ||
c = 1 | ||
d = 2 | ||
print(size(a)) | ||
print(size(a, 0)) | ||
print(size(b)) | ||
print(size(b, 0)) | ||
print(size(b, c)) | ||
print(size(b, d)) | ||
|
||
assert size(a) == 12 | ||
assert size(a, 0) == 12 | ||
assert size(b) == 2250 | ||
assert size(b, 0) == 15 | ||
assert size(b, c) == 15 | ||
assert size(b, d) == 10 | ||
|
||
def main2(): | ||
a: i32[2, 3] = empty([2, 3]) | ||
print(size(a)) | ||
print(size(a, 0)) | ||
print(size(a, 1)) | ||
|
||
assert size(a) == 2*3 | ||
assert size(a, 0) == 2 | ||
assert size(a, 1) == 3 | ||
|
||
def main3(): | ||
a: u32[2, 3, 4] = empty([2, 3, 4]) | ||
b: u64[10, 5] = empty([10, 5]) | ||
c: i32 | ||
d: i32 | ||
c = 1 | ||
d = 2 | ||
print(size(a)) | ||
print(size(a, 0)) | ||
print(size(a, c)) | ||
print(size(a, d)) | ||
|
||
print(size(b)) | ||
print(size(b, 0)) | ||
print(size(b, c)) | ||
|
||
assert size(a) == 2*3*4 | ||
assert size(a, 0) == 2 | ||
assert size(a, c) == 3 | ||
assert size(a, d) == 4 | ||
|
||
assert size(b) == 50 | ||
assert size(b, 0) == 10 | ||
assert size(b, c) == 5 | ||
|
||
main0() | ||
main1() | ||
main2() | ||
main3() |
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,7 @@ | ||
from enum_07_module import Constants | ||
|
||
def check(): | ||
assert Constants.NUM_ELEMS.value == 4 | ||
assert Constants.NUM_CHECK.value == 51 | ||
|
||
check() |
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,6 @@ | ||
from enum import Enum | ||
from lpython import i32 | ||
|
||
class Constants(Enum): | ||
NUM_ELEMS: i32 = 4 | ||
NUM_CHECK: i32 = 51 |
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,28 @@ | ||
from lpython import inline, u32 | ||
|
||
@inline | ||
def uadd(x: u32, y: u32) -> u32: | ||
return x + y | ||
|
||
@inline | ||
def uand_op(x: u32, y: u32) -> u32: | ||
return x & y | ||
|
||
def main1(): | ||
x: u32 | ||
y: u32 | ||
z: u32 | ||
x = (u32(2)+u32(3))*u32(5) | ||
y = uadd(x, u32(2))*u32(2) | ||
assert x == u32(25) | ||
assert y == u32(54) | ||
|
||
z = uand_op(x, y) | ||
assert z == u32(16) | ||
|
||
|
||
main1() | ||
|
||
# Not implemented yet in LPython: | ||
#if __name__ == "__main__": | ||
# main() |
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,78 @@ | ||
from lpython import u8, u16, u32, u64 | ||
|
||
def add_u8(x: u8, y: u8) -> u8: | ||
return x + y | ||
|
||
def add_u16(x: u16, y: u16) -> u16: | ||
return x + y | ||
|
||
def add_u32(x: u32, y: u32) -> u32: | ||
return x + y | ||
|
||
def add_u64(x: u64, y: u64) -> u64: | ||
return x + y | ||
|
||
def and_u8(x: u8, y: u8) -> u8: | ||
return x & y | ||
|
||
def and_u16(x: u16, y: u16) -> u16: | ||
return x & y | ||
|
||
def and_u32(x: u32, y: u32) -> u32: | ||
return x & y | ||
|
||
def and_u64(x: u64, y: u64) -> u64: | ||
return x & y | ||
|
||
def main_u8(): | ||
x: u8 | ||
y: u8 | ||
z: u8 | ||
x = (u8(2)+u8(3))*u8(5) | ||
y = add_u8(x, u8(2))*u8(2) | ||
z = and_u8(x, y) | ||
assert x == u8(25) | ||
assert y == u8(54) | ||
assert z == u8(16) | ||
|
||
def main_u16(): | ||
x: u16 | ||
y: u16 | ||
z: u16 | ||
x = (u16(2)+u16(3))*u16(5) | ||
y = add_u16(x, u16(2))*u16(2) | ||
z = and_u16(x, y) | ||
assert x == u16(25) | ||
assert y == u16(54) | ||
assert z == u16(16) | ||
|
||
def main_u32(): | ||
x: u32 | ||
y: u32 | ||
z: u32 | ||
x = (u32(2)+u32(3))*u32(5) | ||
y = add_u32(x, u32(2))*u32(2) | ||
z = and_u32(x, y) | ||
assert x == u32(25) | ||
assert y == u32(54) | ||
assert z == u32(16) | ||
|
||
def main_u64(): | ||
x: u64 | ||
y: u64 | ||
z: u64 | ||
x = (u64(2)+u64(3))*u64(5) | ||
y = add_u64(x, u64(2))*u64(2) | ||
z = and_u64(x, y) | ||
assert x == u64(25) | ||
assert y == u64(54) | ||
assert z == u64(16) | ||
|
||
main_u8() | ||
main_u16() | ||
main_u32() | ||
main_u64() | ||
|
||
# Not implemented yet in LPython: | ||
#if __name__ == "__main__": | ||
# main() |
Oops, something went wrong.