Skip to content

Commit

Permalink
Merge branch 'main' into numojo-v0.6-update-for-Mojo-25.1.1
Browse files Browse the repository at this point in the history
  • Loading branch information
carolinefrasca authored Mar 3, 2025
2 parents 008deeb + 05fec3e commit b29bb8d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
19 changes: 15 additions & 4 deletions recipes/bridge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,28 @@ from python import Python
from bridge.numpy import ndarray_to_tensor
var np = Python.import_module("numpy")
np_array = np.array([[1, 2], [3, 4]], dtype=float)
np_array = np.arange(6.0).reshape(2,3)
mojo_tensor = ndarray_to_tensor[DType.float64](np_array)
```
Or to achieve the reverse:
```mojo
from tensor import Tensor
from bridge.numpy import tensor_to_ndarray
values = List[Float64](0.0, 1.0, 2.0, 3.0, 4.0, 5.0)
mojo_tensor = Tensor[DType.float64](shape=(2, 3), list=values)
np_array = tensor_to_ndarray(mojo_tensor)
```

# Installation
Add `https://repo.prefix.dev/modular-community` to the channels section of your of your
`mojoproject.toml` file.
Then run:
Add the `modular-community` channel to your `mojoproject.toml` file and `bridge` to
your dependencies, by running:
```bash
magic project channel add "https://repo.prefix.dev/modular-community"
magic add bridge
```
That's it, success! 🎉

# Dependencies
Requires numpy and mojo.
Expand Down
6 changes: 3 additions & 3 deletions recipes/bridge/recipe.yaml
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
context:
version: "0.0.1"
version: "0.1.0"

package:
name: "bridge"
version: ${{ version }}

source:
- git: https://gitlab.com/hylkedonker/bridge.git
rev: bcbd2e6fd51c6187351d2e2f69c136c3c50253a6
rev: dc89432cb79b6eeef42e1755593ea3837c48d7dd

build:
number: 0
script:
- mojo package src/bridge -o ${{ PREFIX }}/lib/mojo/bridge.mojopkg
requirements:
host:
- max=24.6
- max=25.1
run:
- ${{ pin_compatible('max') }}

Expand Down

0 comments on commit b29bb8d

Please sign in to comment.