Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests and clean up package #20

Merged
merged 4 commits into from
Oct 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: CI
on:
pull_request:
branches:
- master
push:
branches:
- master
tags: '*'
jobs:
test:
name: Julia ${{ matrix.version }} - ${{ matrix.os }} - ${{ matrix.arch }} - ${{ github.event_name }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version:
- '1.10'
- '1' # This automatically expands to the latest stable 1.x release.
os:
- ubuntu-latest
- macos-latest
- windows-latest
arch:
- x64
steps:
- uses: actions/checkout@v4
- uses: julia-actions/setup-julia@v2
with:
version: ${{ matrix.version }}
arch: ${{ matrix.arch }}
- uses: julia-actions/cache@v2
- uses: julia-actions/julia-buildpkg@v1
- uses: julia-actions/julia-runtest@v1
with:
prefix: DISPLAY=:0 xvfb-run -s '-screen 0 1024x768x24' #"headless", i.e., without display, as CI server doesn't have a monitor
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this command broke the CI

Copy link
Contributor

@theogf theogf Oct 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also xvfb-run does not seem to exist on MacOS

(or Windows)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trying fixes in #21

22 changes: 16 additions & 6 deletions Project.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,30 @@ version = "0.1.2"
ColorSchemes = "35d6a980-a343-548e-a6ea-1d62b119f2f4"
DocStringExtensions = "ffbed154-4ef7-542d-bbb7-c09d3a79fcae"
GeometricalPredicates = "fd0ad045-b25c-564e-8f9c-8ef5c5f21267"
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
Makie = "ee78f7c6-11fb-53f2-987a-cfe4a2b5a57a"
VoronoiDelaunay = "72f80fcb-8c52-57d9-aff0-40c1a3526986"

[compat]
julia = "1"
Aqua = "0.8"
ColorSchemes = "3"
DocStringExtensions = "0.9"
GeometricalPredicates = "0.4"
GLMakie = "0.9, 0.10"
JLD2 = "0.5"
Makie = "0.20, 0.21"
ReferenceTests = "0.10"
SafeTestsets = "0.1"
Test = "1"
VoronoiDelaunay = "0.4"
DocStringExtensions = "0.9"
ColorSchemes = "3"
Makie = "0.2"
julia = "1"

[extras]
Aqua = "4c88cf16-eb10-579e-8560-4a9242c79595"
GLMakie = "e9467ef8-e4e7-5192-8a1a-b1aee30e663a"
JLD2 = "033835bb-8acc-5ee8-8aae-3f567f8a3819"
ReferenceTests = "324d217c-45ce-50fc-942e-d289b448e8cf"
SafeTestsets = "1bc83da4-3b8d-516f-aca4-4fe02f6d838f"
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]
test = ["Aqua", "GLMakie", "JLD2", "ReferenceTests", "SafeTestsets", "Test"]
81 changes: 55 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# TernaryDiagrams
[repostatus-url]: https://www.repostatus.org/#active
[repostatus-img]: https://www.repostatus.org/badges/latest/active.svg
[![Aqua QA](https://raw.githubusercontent.com/JuliaTesting/Aqua.jl/master/badge.svg)](https://github.com/JuliaTesting/Aqua.jl)

[![repostatus-img]][repostatus-url] [![TernaryDiagrams Downloads](https://shields.io/endpoint?url=https://pkgs.genieframework.com/api/v1/badge/TernaryDiagrams)](https://pkgs.genieframework.com?packages=TernaryDiagrams)

Expand All @@ -9,15 +10,11 @@ that can be used to construct a (relatively quick and dirty) [ternary
plot](https://en.wikipedia.org/wiki/Ternary_plot).

In all the examples that follow, it is assumed that `a1[i] + a2[i] + a3[i] = 1`.
If applicable, `w[i]` corresponds to the weight associated with the point
`(a1[i], a2[i], a3[i])` for each index `i` in the dataset. If you would like to
load a test dataset, use `test/data.jld2`, which can be opened with
[JLD2.jl](https://github.com/JuliaIO/JLD2.jl). The file contains `a1`, `a2`,
`a3` and `mus`, with the latter being weights associated with the data points.
See the file `temp.jl` for an example of its usage.

## The ternary axis
```julia
using GLMakie
using TernaryDiagrams
fig = Figure();
ax = Axis(fig[1, 1]);

Expand All @@ -42,16 +39,24 @@ fig
```
<br>
<div align="center">
<img src="figs/axis.svg?maxAge=0" width="80%">
<img src="figs/axis.png?maxAge=0" width="60%">
</div>
</br>

## Ternary lines
```julia
fig = Figure();
ax = Axis(fig[1, 1]);

ternaryaxis!(ax);
using GLMakie
using TernaryDiagrams
using JLD2
@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
a1 = a1[1:20]
a2 = a2[1:20]
a3 = a3[1:20]

fig = Figure()
ax = Axis(fig[1, 1])

ternaryaxis!(ax)
ternarylines!(ax, a1, a2, a3; color = :blue)

xlims!(ax, -0.2, 1.2)
Expand All @@ -61,23 +66,31 @@ fig
```
<br>
<div align="center">
<img src="figs/lines.svg?maxAge=0" width="80%">
<img src="figs/lines.png?maxAge=0" width="60%">
</div>
</br>

## Ternary scatter
```julia

fig = Figure();
ax = Axis(fig[1, 1]);

ternaryaxis!(ax);
using GLMakie
using TernaryDiagrams
using JLD2
@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
a1 = a1[1:20]
a2 = a2[1:20]
a3 = a3[1:20]
mus = mus[1:20]

fig = Figure()
ax = Axis(fig[1, 1])

ternaryaxis!(ax)
ternaryscatter!(
ax,
a1,
a2,
a3;
color = [get(ColorSchemes.Spectral, w, extrema(ws)) for w in ws],
color = [get(Makie.ColorSchemes.Spectral, w, extrema(mus)) for w in mus],
marker = :circle,
markersize = 20,
)
Expand All @@ -89,12 +102,20 @@ fig
```
<br>
<div align="center">
<img src="figs/scatter.svg?maxAge=0" width="80%">
<img src="figs/scatter.png?maxAge=0" width="60%">
</div>
</br>

## Ternary contours
```julia
using GLMakie
using TernaryDiagrams
using JLD2
@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
a1 = a1[1:20]
a2 = a2[1:20]
a3 = a3[1:20]
mus = mus[1:20]
fig = Figure();
ax = Axis(fig[1, 1]);

Expand All @@ -103,15 +124,15 @@ ternarycontour!(
a1,
a2,
a3,
ws;
mus;
levels = 5,
linewidth = 4,
color = nothing,
colormap = reverse(ColorSchemes.Spectral),
colormap = reverse(Makie.ColorSchemes.Spectral),
pad_data = true,
)

ternaryaxis!(ax);
ternaryaxis!(ax)

xlims!(ax, -0.2, 1.2)
ylims!(ax, -0.3, 1.1)
Expand All @@ -120,19 +141,27 @@ fig
```
<br>
<div align="center">
<img src="figs/contour.svg?maxAge=0" width="80%">
<img src="figs/contour.png?maxAge=0" width="60%">
</div>
</br>

## Ternary filled contours
Note: `ternarycontour` uses a different Delaunay triangulation scheme to
`ternarycontourf` (the former is made by me, while the latter essentially calls
`tricontourf` from Makie.
from Makie internally).

```julia
using GLMakie
using TernaryDiagrams
using JLD2
@load pkgdir(TernaryDiagrams)*"\\test\\data.jld2" a1 a2 a3 mus
a1 = a1[1:20]
a2 = a2[1:20]
a3 = a3[1:20]
mus = mus[1:20]
fig = Figure();
ax = Axis(fig[1, 1]);
ternarycontourf!(ax, a1, a2, a3, ws; levels = 10)
ternarycontourf!(ax, a1, a2, a3, mus; levels = 10)
ternaryaxis!(ax);
xlims!(ax, -0.2, 1.2)
ylims!(ax, -0.3, 1.1)
Expand All @@ -141,7 +170,7 @@ fig
```
<br>
<div align="center">
<img src="figs/contourfill.svg?maxAge=0" width="80%">
<img src="figs/contourfill.png?maxAge=0" width="60%">
</div>
</br>

Expand Down
Binary file added figs/axis.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Loading