Skip to content

Commit

Permalink
Updates for mojo v24.6 (#20)
Browse files Browse the repository at this point in the history
- update conda env to use mojo 24.6

Side-car change
- use implicitly declared variables, just for simplicity
  • Loading branch information
guidorice authored Dec 26, 2024
1 parent 3de2df3 commit 8f3f79b
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ channels:
dependencies:
- python>=3.10
# modular MAX installs mojo as well
- max=24.5
- max=24.6
- pytest>=7.4
# python-xdist is optional: https://github.com/guidorice/mojo-pytest/wiki#2024-07-17-here-is-a-performance-tip
- pytest-xdist
Expand Down
4 changes: 2 additions & 2 deletions example_src/my_package/fibonacci.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ fn fibonacci(n: Int) -> Int:
if n <= 1:
return n

var a = 0
var b = 1
a = 0
b = 1
for _ in range(2, n + 1):
a, b = b, a + b
return b
2 changes: 1 addition & 1 deletion example_src/my_package/random_tensor.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,5 @@ fn random_tensor[T: DType]() raises -> Tensor[T]:
"""
Wraps Tensor.rand() and multiplies a few tensors.
"""
var Shape = TensorShape(100, 1)
Shape = TensorShape(100, 1)
return Tensor[T].rand(Shape) * Tensor[T].rand(Shape) * Tensor[T].rand(Shape)
10 changes: 5 additions & 5 deletions example_tests/my_package/test_fibonacci.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@ def test_fibonacci():
"""
Test fibonacci 10th number.
"""
var expect = 55
var got = fibonacci(10)
expect = 55
got = fibonacci(10)
assert_equal(got, expect)


def test_fibonacci_reference():
"""
Test mojo fibonacci versus python "reference" implementation.
"""
var py = Python.import_module("my_package.fibonacci")
py = Python.import_module("my_package.fibonacci")
for n in range(0, 10):
var expect = py.fibonacci(n)
var got = fibonacci(n)
expect = py.fibonacci(n)
got = fibonacci(n)
assert_equal(got, expect)
4 changes: 2 additions & 2 deletions example_tests/my_package/test_random_tensor.mojo
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ def test_random_tensor():
Validate the random_tensor module in my_package.
"""
alias T = DType.float64
var t = random_tensor[T]()
var sample_value = t[0]
t = random_tensor[T]()
sample_value = t[0]
assert_false(isnan(sample_value))
assert_true(isfinite(sample_value))
3 changes: 2 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
[project]
name = "pytest-mojo"
version = "v24.5"
version = "v24.6"
description = "Mojo🔥 language test runner plugin for pytest. (aka pytest-mojo)"
authors = [{name = "Alex G Rice", email = "alex@ricegeo.dev"}]
license = {file = "LICENSE"}
requires-python = ">=3.10"

[build-system]
requires = ["setuptools>=45", "wheel"]
build-backend = "setuptools.build_meta"
Expand Down

0 comments on commit 8f3f79b

Please sign in to comment.