Skip to content

Commit

Permalink
depend on MLCore.jl (#201)
Browse files Browse the repository at this point in the history
* use MLCore

* use MLCore

* use MLCore
  • Loading branch information
CarloLucibello authored Feb 8, 2025
1 parent 342631a commit 7c29e64
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 244 deletions.
2 changes: 2 additions & 0 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ Compat = "34da2185-b29b-5c13-b0c7-acf172513d20"
DataAPI = "9a962f9c-6df0-11e9-0e5d-c546b8b5ee8a"
DelimitedFiles = "8bb1440f-4735-579b-a4ab-409b98df4dab"
FLoops = "cc61a311-1640-44b5-9fba-1b764f453329"
MLCore = "c2834f40-e789-41da-a90e-33b280584a8c"
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
Random = "9a3f8284-a2c9-5f02-9a11-845980a1fd5c"
ShowCases = "605ecd9f-84a6-4c9e-81e2-4798472b76a3"
Expand All @@ -24,6 +25,7 @@ Compat = "4.2"
DataAPI = "1.0"
DelimitedFiles = "1.0"
FLoops = "0.2"
MLCore = "1.0.0"
NNlib = "0.8, 0.9"
ShowCases = "0.1"
SimpleTraits = "0.9"
Expand Down
1 change: 1 addition & 0 deletions docs/Project.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[deps]
DataFrames = "a93c6f00-e57d-5684-b7b6-d8193f3e46c0"
Documenter = "e30172f5-a6a5-5a46-863b-614d45cd2de4"
MLCore = "c2834f40-e789-41da-a90e-33b280584a8c"
MLUtils = "f1d291b0-491e-4a28-83b9-f70985020b54"
4 changes: 3 additions & 1 deletion docs/make.jl
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using MLUtils
using MLCore
using Documenter

# Copy the README to the home page in docs, to avoid duplication.
Expand All @@ -11,9 +12,10 @@ open(joinpath(@__DIR__, "src/index.md"), "w") do f
end

DocMeta.setdocmeta!(MLUtils, :DocTestSetup, :(using MLUtils); recursive=true)
DocMeta.setdocmeta!(MLCore, :DocTestSetup, :(using MLCore); recursive=true)

makedocs(;
modules=[MLUtils],
modules=[MLUtils, MLCore],
sitename = "MLUtils.jl",
pages = ["Home" => "index.md",
"Guides" => "guides.md",
Expand Down
8 changes: 5 additions & 3 deletions docs/src/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@ CollapsedDocStrings = true

## Core API

These functions are defined in [MLCore.jl](https://github.com/JuliaML/MLCore.jl).

```@docs
getobs
getobs!
numobs
MLCore.getobs
MLCore.getobs!
MLCore.numobs
```

## Lazy Transforms
Expand Down
8 changes: 6 additions & 2 deletions src/MLUtils.jl
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,23 @@ import ChainRulesCore: rrule
using ChainRulesCore: @non_differentiable, unthunk, AbstractZero,
NoTangent, ZeroTangent, ProjectTo

import MLCore: numobs, getobs, getobs!
using SimpleTraits
import NNlib

@traitdef IsTable{X}
@traitimpl IsTable{X} <- Tables.istable(X)

using Compat: stack

include("observation.jl")
# reexport from MLCore
export numobs,
getobs,
getobs!

include("datacontainer.jl")
# export AbstractDataContainer # not documented, but could be part of the API in the future

include("obstransform.jl")
export mapobs,
filterobs,
Expand Down
17 changes: 17 additions & 0 deletions src/datacontainer.jl
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@

# AbstractDataContainer

# Having an AbstractDataContainer allows to define sensible defaults
# for Base (or other) interfaces based on our interface.
# Now mainly provides the iteration interface.
# This makes it easier for developers by reducing boilerplate.

abstract type AbstractDataContainer end

Base.size(x::AbstractDataContainer) = (numobs(x),)
Base.iterate(x::AbstractDataContainer, state = 1) =
(state > numobs(x)) ? nothing : (getobs(x, state), state + 1)
Base.lastindex(x::AbstractDataContainer) = numobs(x)
Base.firstindex(::AbstractDataContainer) = 1

# TODO: add generic show method. See DataLoader's show for inspiration.
238 changes: 0 additions & 238 deletions src/observation.jl

This file was deleted.

0 comments on commit 7c29e64

Please sign in to comment.