Skip to content

Commit

Permalink
Require Gleam v0.33+
Browse files Browse the repository at this point in the history
  • Loading branch information
tynanbe committed Dec 22, 2023
1 parent 934e066 commit 33d715d
Show file tree
Hide file tree
Showing 12 changed files with 146 additions and 167 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- uses: erlef/setup-beam@v1
with:
otp-version: "25"
rebar3-version: "3"
elixir-version: "1.14"
gleam-version: "0.30"
elixir-version: "1.16"
gleam-version: "0.33"

- id: cache-gleam
uses: actions/cache@v3
Expand All @@ -40,7 +40,7 @@ jobs:

- uses: actions/setup-node@v3
with:
node-version: "18"
node-version: "20"

- id: cache-node
uses: actions/cache@v3
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased

- Argamak now requires Gleam v0.33 or later.
- The `tensor` module's `concat` function now returns an `AxisNotFound` error
when the given find function is `False` for every `Axis`.

Expand Down
12 changes: 7 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,20 +52,21 @@ end
The `@tensorflow/tfjs` package is a runtime requirement for `argamak`; however,
its import path in the `argamak_ffi.mjs` module might need adjustment, depending
on your use case. It can be used as is in your Node.js project after running
`npm install @tensorflow/tfjs-node` or an equivalent command.
`npm install @tensorflow/tfjs-node` or an equivalent command for your package
manager of choice.

## Usage

```gleam
// derby.gleam
import argamak/axis.{Axis, Infer}
import argamak/space
import argamak/tensor.{InvalidData, TensorError}
import gleam/function
import gleam/io
import gleam/list
import gleam/result
import gleam/string
import argamak/axis.{Axis, Infer}
import argamak/space
import argamak/tensor.{type TensorError, InvalidData}
pub fn announce_winner(
from horses: List(String),
Expand Down Expand Up @@ -148,7 +149,8 @@ pub fn announce_winner(
// Finally, we make our announcement!
//
announce(horse <> " wins the day with a mean time of " <> time <> " minutes!")
{ horse <> " wins the day with a mean time of " <> time <> " minutes!" }
|> announce
|> Ok
}
```
Expand Down
10 changes: 5 additions & 5 deletions gleam.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name = "argamak"
version = "0.5.0-dev"
version = "1.0.0-dev"
description = "A tensor library for the Gleam programming language"
licences = ["Apache-2.0"]
gleam = "~> 0.30"
gleam = ">= 0.33.0"

[repository]
repo = "argamak"
Expand All @@ -14,12 +14,12 @@ href = "https://gleam.run/"
title = "Website"

[dependencies]
gleam_stdlib = "~> 0.30"
gleam_stdlib = "~> 0.34"
nx = "~> 0.5"

[dev-dependencies]
gleeunit = "~> 0.11"
rad = "~> 0.4"
gleeunit = "~> 1.0"
rad = "~> 1.0"

[rad]
targets = ["erlang", "javascript"]
Expand Down
29 changes: 14 additions & 15 deletions manifest.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,25 +3,24 @@

packages = [
{ name = "complex", version = "0.5.0", build_tools = ["mix"], requirements = [], otp_app = "complex", source = "hex", outer_checksum = "2683BD3C184466CFB94FAD74CBFDDFAA94B860E27AD4CA1BFFE3BFF169D91EF1" },
{ name = "gleam_bitwise", version = "1.3.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_bitwise", source = "hex", outer_checksum = "E2A46EE42E5E9110DAD67E0F71E7358CBE54D5EC22C526DD48CBBA3223025792" },
{ name = "gleam_community_ansi", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_community_colour", "gleam_stdlib", "gleam_bitwise"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "6E4E0CF2B207C1A7FCD3C21AA43514D67BC7004F21F82045CDCCE6C727A14862" },
{ name = "gleam_community_colour", version = "1.1.0", build_tools = ["gleam"], requirements = ["gleam_bitwise", "gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "D27CE357ECB343929A8CEC3FBA0B499943A47F0EE1F589EE16AFC2DC21C61E5B" },
{ name = "gleam_http", version = "3.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "FAE9AE3EB1CA90C2194615D20FFFD1E28B630E84DACA670B28D959B37BCBB02C" },
{ name = "gleam_json", version = "0.6.0", build_tools = ["gleam"], requirements = ["thoas", "gleam_stdlib"], otp_app = "gleam_json", source = "hex", outer_checksum = "C6CC5BEECA525117E97D0905013AB3F8836537455645DDDD10FE31A511B195EF" },
{ name = "gleam_stdlib", version = "0.30.2", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "8D8BF3790AA31176B1E1C0B517DD74C86DA8235CF3389EA02043EE4FD82AE3DC" },
{ name = "gleeunit", version = "0.11.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "1397E5C4AC4108769EE979939AC39BF7870659C5AFB714630DEEEE16B8272AD5" },
{ name = "glint", version = "0.11.4", build_tools = ["gleam"], requirements = ["gleam_stdlib", "snag", "gleam_community_ansi", "gleam_community_colour"], otp_app = "glint", source = "hex", outer_checksum = "9508BF037E35F549C51F9F1D2CC4736CEA7F7A49E21CCA9B4540452C7D6CC4C5" },
{ name = "nx", version = "0.6.0", build_tools = ["mix"], requirements = ["telemetry", "complex"], otp_app = "nx", source = "hex", outer_checksum = "E1AD3CC70A5828A1AEDB156B71E90863D9623A2DC9B35A5588F8627A07EE6CB4" },
{ name = "rad", version = "0.4.1", build_tools = ["gleam"], requirements = ["gleam_http", "gleam_stdlib", "thoas", "glint", "shellout", "snag", "gleam_json", "tomerl"], otp_app = "rad", source = "hex", outer_checksum = "1C993A1BF89F46B174ECFBE8A34CB135751517B2F9846D5D9D9A87CF823BFFE0" },
{ name = "shellout", version = "1.4.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "995564B69D40146B7A424CA21D32A68D668A882F88BDAD0EFA2C18C7EC412564" },
{ name = "snag", version = "0.2.1", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "8FD70D8FB3728E08AC425283BB509BB0F012BE1AE218424A597CDE001B0EE589" },
{ name = "gleam_community_ansi", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_colour"], otp_app = "gleam_community_ansi", source = "hex", outer_checksum = "AB7C3CCC894653637E02DC455D5890C8CF3064E83E78CFE61145A4C458D02DE6" },
{ name = "gleam_community_colour", version = "1.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_community_colour", source = "hex", outer_checksum = "A49A5E3AE8B637A5ACBA80ECB9B1AFE89FD3D5351FF6410A42B84F666D40D7D5" },
{ name = "gleam_http", version = "3.5.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleam_http", source = "hex", outer_checksum = "AECDA43AFD523D07A8F09068598A6E271C505278A0CB6F9C7A2E4365EAE8D11E" },
{ name = "gleam_json", version = "0.7.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas"], otp_app = "gleam_json", source = "hex", outer_checksum = "CB405BD93A8828BCD870463DE29375E7B2D252D9D124C109E5B618AAC00B86FC" },
{ name = "gleam_stdlib", version = "0.34.0", build_tools = ["gleam"], requirements = [], otp_app = "gleam_stdlib", source = "hex", outer_checksum = "1FB8454D2991E9B4C0C804544D8A9AD0F6184725E20D63C3155F0AEB4230B016" },
{ name = "gleeunit", version = "1.0.2", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "gleeunit", source = "hex", outer_checksum = "D364C87AFEB26BDB4FB8A5ABDE67D635DC9FA52D6AB68416044C35B096C6882D" },
{ name = "glint", version = "0.13.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "gleam_community_ansi", "snag", "gleam_community_colour"], otp_app = "glint", source = "hex", outer_checksum = "46E56049CD370D61F720D319D0AB970408C9336EEB918F08B5DCB1DCE9845FA3" },
{ name = "nx", version = "0.6.4", build_tools = ["mix"], requirements = ["complex", "telemetry"], otp_app = "nx", source = "hex", outer_checksum = "BB9C2E2E3545B5EB4739D69046A988DAAA212D127DBA7D97801C291616AFF6D6" },
{ name = "rad", version = "1.0.0", build_tools = ["gleam"], requirements = ["gleam_stdlib", "thoas", "gleam_json", "glint", "snag", "tomerl", "gleam_http", "shellout"], otp_app = "rad", source = "hex", outer_checksum = "E9EAE1DC9E3F75FFDBB2C8685885646EBE7352D6B2669A993B3F4DAFDF14FF81" },
{ name = "shellout", version = "1.5.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "shellout", source = "hex", outer_checksum = "7B5DE499DBB3DDC25051FC1BB3770DD5466938B6A2AFA91A6FB4A4D49F4CB0D4" },
{ name = "snag", version = "0.3.0", build_tools = ["gleam"], requirements = ["gleam_stdlib"], otp_app = "snag", source = "hex", outer_checksum = "54D32E16E33655346AA3E66CBA7E191DE0A8793D2C05284E3EFB90AD2CE92BCC" },
{ name = "telemetry", version = "1.2.1", build_tools = ["rebar3"], requirements = [], otp_app = "telemetry", source = "hex", outer_checksum = "DAD9CE9D8EFFC621708F99EAC538EF1CBE05D6A874DD741DE2E689C47FEAFED5" },
{ name = "thoas", version = "0.4.1", build_tools = ["rebar3"], requirements = [], otp_app = "thoas", source = "hex", outer_checksum = "4918D50026C073C4AB1388437132C77A6F6F7C8AC43C60C13758CC0ADCE2134E" },
{ name = "tomerl", version = "0.5.0", build_tools = ["rebar3"], requirements = [], otp_app = "tomerl", source = "hex", outer_checksum = "2A7FB62F9EBF0E75561B39255638BC2B805B437C86FEC538657E7C3B576979FA" },
]

[requirements]
gleam_stdlib = { version = "~> 0.30" }
gleeunit = { version = "~> 0.11" }
gleam_stdlib = { version = "~> 0.34" }
gleeunit = { version = "~> 1.0" }
nx = { version = "~> 0.5" }
rad = { version = "~> 0.4" }
rad = { version = "~> 1.0" }
23 changes: 12 additions & 11 deletions src/argamak/space.gleam
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import argamak/axis.{Axes, Axis, Infer}
import gleam/dict
import gleam/int
import gleam/list
import gleam/map
import gleam/result
import gleam/string
import argamak/axis.{type Axes, type Axis, Axis, Infer}

/// An n-dimensional `Space` containing `Axes` of various sizes.
///
Expand Down Expand Up @@ -315,27 +315,27 @@ pub fn merge(a: Space, b: Space) -> SpaceResult {
let index = fn(x: Space) {
x
|> axes
|> list.index_map(with: fn(index, axis) { #(index, axis) })
|> map.from_list
|> list.index_map(with: fn(axis, index) { #(index, axis) })
|> dict.from_list
}
let a_index = index(a)
let b_index = index(b)

let a_size = map.size(a_index)
let b_size = map.size(b_index)
let a_size = dict.size(a_index)
let b_size = dict.size(b_index)

let #(x, map) = case a_size < b_size {
let #(x, dict) = case a_size < b_size {
True -> #(axes(b), a_index)
False -> #(axes(a), b_index)
}
let offset = int.absolute_value(a_size - b_size)

let #(x, errors) =
x
|> list.index_map(with: fn(index, a_axis) {
|> list.index_map(with: fn(a_axis, index) {
let b_axis =
map
|> map.get(index - offset)
dict
|> dict.get(index - offset)
|> result.unwrap(or: a_axis)
let a_name = axis.name(a_axis)
let b_name = axis.name(b_axis)
Expand Down Expand Up @@ -478,7 +478,8 @@ fn validate(space: Space) -> SpaceResult {
}
ValidateAcc(
names: [name, ..acc.names],
inferred: acc.inferred || axis == Infer(name),
inferred: acc.inferred
|| axis == Infer(name),
results: [result, ..acc.results],
)
}
Expand Down
Loading

0 comments on commit 33d715d

Please sign in to comment.