diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b52052fc4..5fef4f37c 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -21,8 +21,8 @@ jobs: name: Build strategy: matrix: - go-version: [1.23.x, 1.22.x] - platform: [ubuntu-20.04, macos-latest, windows-latest] + go-version: [1.24.x, 1.23.x] + platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: - name: Install Go @@ -50,20 +50,19 @@ jobs: fetch-depth: 1 - name: Install Linux packages - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-latest' run: | sudo apt-get update - sudo apt-get install -qq gcc pkg-config libwayland-dev libx11-dev libx11-xcb-dev libxkbcommon-x11-dev libgles2-mesa-dev libegl1-mesa-dev libffi-dev libxcursor-dev libvulkan-dev xvfb xdotool go run ./ci/install-cxx-root.go -root-version=${ROOT_VERSION} -o=${HOME} source $HOME/root-${ROOT_VERSION}/bin/thisroot.sh root.exe --version - name: Build-Linux-32b - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-latest' run: | GOARCH=386 go install -v $TAGS,cross_compile ./... - name: Build-Linux-64b - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-latest' run: | GOARCH=amd64 go install -v $TAGS ./... - name: Build-Windows @@ -75,7 +74,7 @@ jobs: run: | go install -v $TAGS ./... - name: Test Linux - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-latest' run: | go run ./ci/run-tests.go $TAGS -race $COVERAGE go vet $TAGS ./... @@ -94,7 +93,7 @@ jobs: with: install-go: false cache-key: ${{ matrix.platform }} - version: "2024.1.1" + version: "2025.1" - name: Upload-Coverage - if: matrix.platform == 'ubuntu-20.04' + if: matrix.platform == 'ubuntu-latest' uses: codecov/codecov-action@v3 diff --git a/ci/mk-release.go b/ci/mk-release.go index 93c78d6f5..88ea5441d 100644 --- a/ci/mk-release.go +++ b/ci/mk-release.go @@ -321,32 +321,12 @@ func setLatest(version string) { } var excludeList = map[OSArch]map[string]struct{}{ - {"linux", "386"}: { - "go-hep.org/x/hep/hplot/cmd/iplot": struct{}{}, - }, - {"linux", "arm64"}: { - "go-hep.org/x/hep/hplot/cmd/iplot": struct{}{}, - }, - {"darwin", "amd64"}: { - "go-hep.org/x/hep/hplot/cmd/iplot": {}, - }, - {"freebsd", "amd64"}: { - "go-hep.org/x/hep/hplot/cmd/iplot": struct{}{}, - "go-hep.org/x/hep/groot/cmd/root-fuse": struct{}{}, - "go-hep.org/x/hep/xrootd/cmd/xrd-fuse": struct{}{}, - }, - {"windows", "amd64"}: { - "go-hep.org/x/hep/groot/cmd/root-fuse": struct{}{}, - "go-hep.org/x/hep/xrootd/cmd/xrd-fuse": struct{}{}, - }, - {"windows", "386"}: { - "go-hep.org/x/hep/groot/cmd/root-fuse": struct{}{}, - "go-hep.org/x/hep/xrootd/cmd/xrd-fuse": struct{}{}, - }, + {"linux", "386"}: {}, + {"linux", "arm64"}: {}, + {"darwin", "amd64"}: {}, + {"freebsd", "amd64"}: {}, + {"windows", "amd64"}: {}, + {"windows", "386"}: {}, } -var needCgo = map[string]struct{}{ - "pawgo": {}, - "iplot": {}, - "hplot": {}, -} +var needCgo = map[string]struct{}{} diff --git a/go.mod b/go.mod index 235346e9f..1b36e4671 100644 --- a/go.mod +++ b/go.mod @@ -1,22 +1,19 @@ module go-hep.org/x/hep -go 1.22.0 +go 1.23 require ( - gioui.org v0.3.0 git.sr.ht/~sbinet/epok v0.5.0 - git.sr.ht/~sbinet/go-arrow v0.2.0 + git.sr.ht/~sbinet/go-arrow v0.3.0 github.com/astrogo/fitsio v0.3.0 github.com/campoy/embedmd v1.0.0 github.com/go-mmap/mmap v0.7.0 github.com/gonuts/binary v0.2.0 github.com/gonuts/commander v0.4.1 github.com/google/go-cmp v0.6.0 - github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/hashicorp/go-uuid v1.0.3 github.com/jcmturner/gokrb5/v8 v8.4.4 github.com/klauspost/compress v1.17.11 - github.com/peterh/liner v1.2.2 github.com/pierrec/lz4/v4 v4.1.22 github.com/pierrec/xxHash v0.1.5 github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e @@ -36,32 +33,24 @@ require ( ) require ( - gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 // indirect - gioui.org/shader v1.0.6 // indirect - gioui.org/x v0.3.0 // indirect git.sr.ht/~sbinet/gg v0.6.0 // indirect github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b // indirect - github.com/andybalholm/stroke v0.0.0-20230904101225-24ef450bc62c // indirect github.com/edsrzf/mmap-go v1.2.0 // indirect github.com/go-fonts/liberation v0.3.3 // indirect github.com/go-latex/latex v0.0.0-20240709081214-31cef3c7570e // indirect github.com/go-pdf/fpdf v0.9.0 // indirect - github.com/go-text/typesetting v0.0.0-20230905121921-abdbcca6e0eb // indirect github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 // indirect - github.com/google/flatbuffers v23.5.26+incompatible // indirect + github.com/google/flatbuffers v25.2.10+incompatible // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // indirect github.com/jcmturner/aescts/v2 v2.0.0 // indirect github.com/jcmturner/dnsutils/v2 v2.0.0 // indirect github.com/jcmturner/gofork v1.7.6 // indirect github.com/jcmturner/rpc/v2 v2.0.3 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect github.com/pmezard/go-difflib v1.0.0 // indirect github.com/posener/complete v1.2.3 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect - github.com/rivo/uniseg v0.4.7 // indirect github.com/teambition/rrule-go v1.8.2 // indirect - golang.org/x/exp/shiny v0.0.0-20241009180824-f66d83c29e7c // indirect golang.org/x/mod v0.22.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect @@ -72,9 +61,9 @@ require ( modernc.org/golex v1.1.0 // indirect modernc.org/internal v1.1.0 // indirect modernc.org/lldb v1.0.8 // indirect - modernc.org/mathutil v1.6.0 // indirect - modernc.org/sortutil v1.2.0 // indirect - modernc.org/strutil v1.2.0 // indirect + modernc.org/mathutil v1.7.1 // indirect + modernc.org/sortutil v1.2.1 // indirect + modernc.org/strutil v1.2.1 // indirect modernc.org/zappy v1.1.0 // indirect rsc.io/pdf v0.1.1 // indirect ) diff --git a/go.sum b/go.sum index f32874218..d374b6a9e 100644 --- a/go.sum +++ b/go.sum @@ -1,29 +1,16 @@ -eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d h1:ARo7NCVvN2NdhLlJE9xAbKweuI9L6UgfTbYb0YwPacY= -eliasnaur.com/font v0.0.0-20230308162249-dd43949cb42d/go.mod h1:OYVuxibdk9OSLX8vAqydtRPP87PyTFcT9uH3MlEGBQA= -gioui.org v0.3.0 h1:xZty/uLl1+/HNKpumX60JPQd46n8Zy6lc5T3IRMKoR4= -gioui.org v0.3.0/go.mod h1:1H72sKEk/fNFV+l0JNeM2Dt3co3Y4uaQcD+I+/GQ0e4= -gioui.org/cpu v0.0.0-20210808092351-bfe733dd3334/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= -gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7 h1:tNJdnP5CgM39PRc+KWmBRRYX/zJ+rd5XaYxY5d5veqA= -gioui.org/cpu v0.0.0-20220412190645-f1e9e8c3b1f7/go.mod h1:A8M0Cn5o+vY5LTMlnRoK3O5kG+rH0kWfJjeKd9QpBmQ= -gioui.org/shader v1.0.6 h1:cvZmU+eODFR2545X+/8XucgZdTtEjR3QWW6W65b0q5Y= -gioui.org/shader v1.0.6/go.mod h1:mWdiME581d/kV7/iEhLmUgUK5iZ09XR5XpduXzbePVM= -gioui.org/x v0.3.0 h1:XupHLCT2D1G8qvXxN/EoX+IMpDiG5CHokg6j33rSH9I= -gioui.org/x v0.3.0/go.mod h1:Y/VG4cEJuj938VSzbN21oDg/ZgpKa/P9ipwtTSL1vbU= git.sr.ht/~sbinet/cmpimg v0.1.0 h1:E0zPRk2muWuCqSKSVZIWsgtU9pjsw3eKHi8VmQeScxo= git.sr.ht/~sbinet/cmpimg v0.1.0/go.mod h1:FU12psLbF4TfNXkKH2ZZQ29crIqoiqTZmeQ7dkp/pxE= git.sr.ht/~sbinet/epok v0.5.0 h1:eQcocQpGQVYWLiA93dkIgngH0jjjDiTdj7rS3vQLp6w= git.sr.ht/~sbinet/epok v0.5.0/go.mod h1:IO3V831F7MiJ78BrBPcZLImTJSkPYAQeFYXJkdlnU2I= git.sr.ht/~sbinet/gg v0.6.0 h1:RIzgkizAk+9r7uPzf/VfbJHBMKUr0F5hRFxTUGMnt38= git.sr.ht/~sbinet/gg v0.6.0/go.mod h1:uucygbfC9wVPQIfrmwM2et0imr8L7KQWywX0xpFMm94= -git.sr.ht/~sbinet/go-arrow v0.2.0 h1:QIiVPcEtMb2lzOWDgBrIz9Sa+7Xvs2EJ/Icxe6IcUSI= -git.sr.ht/~sbinet/go-arrow v0.2.0/go.mod h1:GIva9P8b7Pom+/pOUMPX5YOrtLOUdGb5tLXBfKuelTY= +git.sr.ht/~sbinet/go-arrow v0.3.0 h1:yH0+AVr3iZtSNcFMpKpNXrZfeoPZPA80fn4FdjOiHAw= +git.sr.ht/~sbinet/go-arrow v0.3.0/go.mod h1:w/rRkiCdHWMNU0EDGrGpTjEwhSQLruknITV8C9pvMAQ= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/ajstarks/deck v0.0.0-20200831202436-30c9fc6549a9/go.mod h1:JynElWSGnm/4RlzPXRlREEwqTHAN3T56Bv2ITsFT3gY= github.com/ajstarks/deck/generate v0.0.0-20210309230005-c3f852c02e19/go.mod h1:T13YZdzov6OU0A1+RfKZiZN9ca6VeKdBdyDV+BY97Tk= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b h1:slYM766cy2nI3BwyRiyQj/Ud48djTMtMebDqepE95rw= github.com/ajstarks/svgo v0.0.0-20211024235047-1546f124cd8b/go.mod h1:1KcenG0jGWcpt8ov532z81sp/kMMUG485J2InIOyADM= -github.com/andybalholm/stroke v0.0.0-20230904101225-24ef450bc62c h1:hHefapU8Zg8roqjYi9V8CNFPD0z6tbDDSqNgBgY1O4U= -github.com/andybalholm/stroke v0.0.0-20230904101225-24ef450bc62c/go.mod h1:ccdDYaY5+gO+cbnQdFxEXqfy0RkoV25H3jLXUDNM3wg= github.com/astrogo/fitsio v0.3.0 h1:iQ/lGCREuct04H1dTzPLndbzGo/4SNgpO0JuAhM+YtE= github.com/astrogo/fitsio v0.3.0/go.mod h1:QRvq9GRh56Pa+TkX3iBHo6Upwd7KKIKgL2KO291Gdu0= github.com/campoy/embedmd v1.0.0 h1:V4kI2qTJJLf4J29RzI/MAt2c3Bl4dQSYPuflzwFH2hY= @@ -46,10 +33,6 @@ github.com/go-mmap/mmap v0.7.0 h1:+h1n06sZw0IWBwL9YDzTomNNXxM4LH/l+HVpGaTC+qk= github.com/go-mmap/mmap v0.7.0/go.mod h1:moN8m00bW6Mpk+Y1xQFeL3xZqycnT4qUAf852ICV/Gc= github.com/go-pdf/fpdf v0.9.0 h1:PPvSaUuo1iMi9KkaAn90NuKi+P4gwMedWPHhj8YlJQw= github.com/go-pdf/fpdf v0.9.0/go.mod h1:oO8N111TkmKb9D7VvWGLvLJlaZUQVPM+6V42pp3iV4Y= -github.com/go-text/typesetting v0.0.0-20230905121921-abdbcca6e0eb h1:4GpJirtA8yY24aqbU3uppiXGYiVpWfLIrqc2NNKKk9s= -github.com/go-text/typesetting v0.0.0-20230905121921-abdbcca6e0eb/go.mod h1:evDBbvNR/KaVFZ2ZlDSOWWXIUKq0wCOEtzLxRM8SG3k= -github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22 h1:LBQTFxP2MfsyEDqSKmUBZaDuDHN1vpqDyOZjcqS7MYI= -github.com/go-text/typesetting-utils v0.0.0-20230616150549-2a7df14b6a22/go.mod h1:DDxDdQEnB70R8owOx3LVpEFvpMK9eeH1o2r0yZhFI9o= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0 h1:DACJavvAHhabrF08vX0COfcOBJRhZ8lUbR+ZWIs0Y5g= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= github.com/golang/snappy v0.0.3 h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA= @@ -58,12 +41,10 @@ github.com/gonuts/binary v0.2.0 h1:caITwMWAoQWlL0RNvv2lTU/AHqAJlVuu6nZmNgfbKW4= github.com/gonuts/binary v0.2.0/go.mod h1:kM+CtBrCGDSKdv8WXTuCUsw+loiy8f/QEI8YCCC0M/E= github.com/gonuts/commander v0.4.1 h1:7lmZMnCuDHA0365niE4V5N0Om/hsl6fXskt4MWaKPvg= github.com/gonuts/commander v0.4.1/go.mod h1:qkKJBkuvjm1FgHrH7PO3pMIOuGpl/CDfy+6qw3VKNQs= -github.com/google/flatbuffers v23.5.26+incompatible h1:M9dgRyhJemaM4Sw8+66GHBu8ioaQmyPLg1b8VwK5WJg= -github.com/google/flatbuffers v23.5.26+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= +github.com/google/flatbuffers v25.2.10+incompatible h1:F3vclr7C3HpB1k9mxCGRMXq6FdUalZ6H/pNX4FP1v0Q= +github.com/google/flatbuffers v25.2.10+incompatible/go.mod h1:1AeVuKshWv4vARoZatz6mlQ0JxURH0Kv5+zNeJKJCa8= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= -github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4= github.com/gorilla/sessions v1.2.1/go.mod h1:dk2InVEVJ0sfLlnXv9EAgkf6ecYs/i80K/zI+bUmuGM= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= @@ -90,11 +71,6 @@ github.com/jcmturner/rpc/v2 v2.0.3/go.mod h1:VUJYCIDm3PVOEHw8sgt091/20OJjskO/YJk github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/klauspost/compress v1.17.11 h1:In6xLpyWOi1+C7tXUUWv2ot1QvBjxevKAaI6IXrJmUc= github.com/klauspost/compress v1.17.11/go.mod h1:pMDklpSncoRMuLFrf1W9Ss9KT+0rH90U12bZKk7uwG0= -github.com/mattn/go-runewidth v0.0.3/go.mod h1:LwmH8dsx7+W8Uxz3IHJYH5QSwggIsqBzpuz5H//U1FU= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/peterh/liner v1.2.2 h1:aJ4AOodmL+JxOZZEL2u9iJf8omNRpqHc/EbrK+3mAXw= -github.com/peterh/liner v1.2.2/go.mod h1:xFwJyiKIXJZUKItq5dGHZSTBRAuG/CpeNpWLyiNRNwI= github.com/pierrec/lz4/v4 v4.1.22 h1:cKFw6uJDK+/gfw5BcDL0JL5aBsAFdsIT18eRtLj7VIU= github.com/pierrec/lz4/v4 v4.1.22/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pierrec/xxHash v0.1.5 h1:n/jBpwTHiER4xYvK3/CdPVnLDPchj8eTJFFLUb4QHBo= @@ -108,9 +84,6 @@ github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSg github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec h1:W09IVJc94icq4NjY3clb7Lk8O1qJ8BdBEF8z0ibU0rE= github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/sbinet/npyio v0.8.0 h1:n+jtLFIjcJNENOI44lG7BUwWFqtgdQAerqyXDtC956A= github.com/sbinet/npyio v0.8.0/go.mod h1:26fj1nEFY78AYqkANkcSw4dYwLHXFWFehgOSu5HKwgw= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= @@ -120,8 +93,9 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/teambition/rrule-go v1.8.2 h1:lIjpjvWTj9fFUZCmuoVDrKVOtdiyzbzc93qTmRVe/J8= github.com/teambition/rrule-go v1.8.2/go.mod h1:Ieq5AbrKGciP1V//Wq8ktsTXwSwJHDD5mD/wLBGl3p4= github.com/ulikunitz/xz v0.5.12 h1:37Nm15o69RwBkXM0J6A5OlE67RZTfzUxTj8fB3dfcsc= @@ -139,8 +113,6 @@ golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67 h1:1UoZQm6f0P/ZO0w1Ri+f+ifG/gXhegadRdwBIXEFWDo= golang.org/x/exp v0.0.0-20241217172543-b2144cdd0a67/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= -golang.org/x/exp/shiny v0.0.0-20241009180824-f66d83c29e7c h1:jTMrjjZRcSH/BDxWhXCP6OWsfVgmnwI7J+F4/nyVXaU= -golang.org/x/exp/shiny v0.0.0-20241009180824-f66d83c29e7c/go.mod h1:3F+MieQB7dRYLTmnncoFbb1crS5lfQoTfDgQy6K4N0o= golang.org/x/image v0.23.0 h1:HseQ7c2OpPKTPVzNjG5fwJsOTCiiwS4QdsYi5XU6H68= golang.org/x/image v0.23.0/go.mod h1:wJJBTdLfCCf3tiHa1fNxpZmUI4mmoZvwMCPP0ddoNKY= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= @@ -168,7 +140,6 @@ golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211117180635-dee7805ff2e1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -222,15 +193,15 @@ modernc.org/internal v1.1.0/go.mod h1:IFhfxUE81NbN8Riy+oHylA3PIYgAvIQ5eMufNzg7/Q modernc.org/lldb v1.0.8 h1:gM0Lpmgtw0h/ylWQSxABvzJ++TZKhf1Q/uPAGBAM6aU= modernc.org/lldb v1.0.8/go.mod h1:ybOcsZ/RNZo3q8fiGadQFRnD+1Jc+RWGcTPdeilCnUk= modernc.org/mathutil v1.5.0/go.mod h1:mZW8CKdRPY1v87qxC/wUdX5O1qDzXMP5TH3wjfpga6E= -modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4= -modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo= +modernc.org/mathutil v1.7.1 h1:GCZVGXdaN8gTqB1Mf/usp1Y/hSqgI2vAGGP4jZMCxOU= +modernc.org/mathutil v1.7.1/go.mod h1:4p5IwJITfppl0G4sUEDtCr4DthTaT47/N3aT6MhfgJg= modernc.org/ql v1.4.7 h1:dnGGGL5tHmPwVhMAylnLlwrnIrtk8PPb5KRfMvfgJzE= modernc.org/ql v1.4.7/go.mod h1:I900l6z8ckpPy1y9VR0gu4pZ9hl9AhmQla4F8KERzdc= modernc.org/sortutil v1.1.1/go.mod h1:DTj/8BqjEBLZFVPYvEGDfFFg94SsfPxQ70R+SQJ98qA= -modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc= -modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss= -modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA= -modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0= +modernc.org/sortutil v1.2.1 h1:+xyoGf15mM3NMlPDnFqrteY07klSFxLElE2PVuWIJ7w= +modernc.org/sortutil v1.2.1/go.mod h1:7ZI3a3REbai7gzCLcotuw9AC4VZVpYMjDzETGsSMqJE= +modernc.org/strutil v1.2.1 h1:UneZBkQA+DX2Rp35KcM69cSsNES9ly8mQWD71HKlOA0= +modernc.org/strutil v1.2.1/go.mod h1:EHkiggD70koQxjVdSBM3JKM7k6L0FbGE5eymy9i3B9A= modernc.org/zappy v1.0.9/go.mod h1:y2c4Hv5jzyBP179SxNmx5H/BM6cVgNIXPQv2bCeR6IM= modernc.org/zappy v1.1.0 h1:cAf9HrymATNo2hYMc9c37y0tiZJYuKM2xa1ZAP8THUw= modernc.org/zappy v1.1.0/go.mod h1:cxC0dWAgZuyMsJ+KL3ZBgo3twyKGBB/0By/umSZE2bQ= diff --git a/hplot/cmd/iplot/main.go b/hplot/cmd/iplot/main.go deleted file mode 100644 index 396aec44b..000000000 --- a/hplot/cmd/iplot/main.go +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright ©2017 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cross_compile - -package main - -import ( - "image/color" - "math/rand" - "os" - "strings" - - "gioui.org/app" - "gioui.org/io/key" - "gioui.org/io/system" - "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/clip" - "gioui.org/unit" - "go-hep.org/x/hep/hbook" - "go-hep.org/x/hep/hplot" - "gonum.org/v1/plot/plotter" - "gonum.org/v1/plot/vg/draw" - "gonum.org/v1/plot/vg/vggio" -) - -const ( - NPOINTS = 100000 - dpi = 96 -) - -func main() { - go run() - app.Main() -} - -func run() { - w, h := hplot.Dims(-1, -1) - win := app.NewWindow( - app.Title("iplot"), - app.Size( - unit.Dp(float32(w.Dots(dpi))), - unit.Dp(float32(h.Dots(dpi))), - ), - ) - defer os.Exit(0) - - keys := key.Set(strings.Join( - []string{key.NameEscape, "Q", " ", key.NameReturn, key.NameEnter}, - "|", - )) - - for e := range win.Events() { - switch e := e.(type) { - case system.FrameEvent: - var ( - ops op.Ops - gtx = layout.NewContext(&ops, e) - ) - // register a global key listener for the escape key wrapping our entire UI. - area := clip.Rect{Max: gtx.Constraints.Max}.Push(gtx.Ops) - key.InputOp{ - Tag: win, - Keys: keys, - }.Add(gtx.Ops) - - for _, e := range gtx.Events(win) { - switch e := e.(type) { - case key.Event: - switch e.Name { - case "Q", key.NameEscape: - return - case " ", key.NameReturn, key.NameEnter: - if e.State == key.Press { - win.Invalidate() - } - } - } - } - area.Pop() - - c := vggio.New(gtx, w, h) - p := newPlot() - p.Draw(draw.New(c)) - e.Frame(c.Paint()) - - case system.DestroyEvent: - return - } - } -} - -func newPlot() *hplot.Plot { - // Draw some random values from the standard - // normal distribution. - hist1 := hbook.NewH1D(100, -5, +5) - hist2 := hbook.NewH1D(100, -5, +5) - for i := 0; i < NPOINTS; i++ { - v1 := rand.NormFloat64() - 1 - v2 := rand.NormFloat64() + 1 - hist1.Fill(v1, 1) - hist2.Fill(v2, 1) - } - - // Make a plot and set its title. - p := hplot.New() - p.Title.Text = "Histogram" - p.X.Label.Text = "X" - p.Y.Label.Text = "Y" - - // Create a histogram of our values drawn - // from the standard normal. - h1 := hplot.NewH1D(hist1) - h1.Infos.Style = hplot.HInfoSummary - h1.Color = color.Black - h1.FillColor = nil - - h2 := hplot.NewH1D(hist2) - h2.Infos.Style = hplot.HInfoNone - h2.Color = color.RGBA{255, 0, 0, 255} - h2.FillColor = nil - - p.Add(h1, h2) - - p.Add(plotter.NewGrid()) - return p -} diff --git a/pawgo/README.md b/pawgo/README.md deleted file mode 100644 index 256f5877c..000000000 --- a/pawgo/README.md +++ /dev/null @@ -1,47 +0,0 @@ -pawgo -===== - -`pawgo` is a nod to the old `PAW` physics analysis workstation. - -## Installation - -```sh -$ go get -u go-hep.org/x/hep/pawgo -``` - -## Example - -``` -$ pawgo - -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -paw> /? -/! -- run a shell command -/? -- print help -/file/close -- close a file -/file/create -- create file for write access -/file/list -- list a file's content -/file/open -- open file for read access -/hist/open -- open a histogram -/hist/plot -- plot a histogram -/quit -- quit PAW-Go - -paw> /file/open f testdata/hsimple.rio -paw> /file/ls f -/file/id/f name=testdata/hsimple.rio - - h1 (type="*go-hep.org/x/hep/hbook.H1D") - - h2 (type="*go-hep.org/x/hep/hbook.H1D") - -paw> /hist/open h /file/id/f/h1 -paw> /hist/plot h -== h1d: name="h1" -entries=1000 -mean= -0.059 -RMS= +1.009 -``` diff --git a/pawgo/app.go b/pawgo/app.go deleted file mode 100644 index 21178d1b2..000000000 --- a/pawgo/app.go +++ /dev/null @@ -1,15 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cross_compile - -package main - -import ( - "gioui.org/app" -) - -func appMain() { - app.Main() -} diff --git a/pawgo/app_xcomp.go b/pawgo/app_xcomp.go deleted file mode 100644 index 0e7e9a341..000000000 --- a/pawgo/app_xcomp.go +++ /dev/null @@ -1,11 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build cross_compile - -package main - -func appMain() { - select {} -} diff --git a/pawgo/cmd.go b/pawgo/cmd.go deleted file mode 100644 index a6f9b9224..000000000 --- a/pawgo/cmd.go +++ /dev/null @@ -1,185 +0,0 @@ -// Copyright ©2015 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "bufio" - "fmt" - "io" - "log" - "os" - "strings" - - "github.com/google/shlex" - "github.com/peterh/liner" -) - -type Cmdr interface { - Name() string - Run(args []string) error - Help(w io.Writer) - Complete(line string) []string -} - -type Cmd struct { - msg *log.Logger - rl *liner.State - cmds map[string]Cmdr - wmgr *winMgr - fmgr *fileMgr - hmgr *histMgr -} - -func newCmd(stdout io.Writer) *Cmd { - msg := log.New(stdout, "paw: ", 0) - c := Cmd{ - msg: msg, - rl: liner.NewLiner(), - wmgr: newWinMgr(msg), - fmgr: newFileMgr(msg), - hmgr: newHistMgr(msg), - } - c.cmds = map[string]Cmdr{ - "/?": &cmdHelp{&c}, - "/!": &cmdShell{&c}, - - "/file/open": &cmdFileOpen{&c}, - "/file/close": &cmdFileClose{&c}, - "/file/create": &cmdFileCreate{&c}, - "/file/ls": &cmdFileList{&c}, - - "/hist/open": &cmdHistOpen{&c}, - "/hist/plot": &cmdHistPlot{&c}, - - "/quit": &cmdQuit{&c}, - } - - c.rl.SetTabCompletionStyle(liner.TabPrints) - c.rl.SetCompleter(func(line string) []string { - var o []string - for k := range c.cmds { - if strings.HasPrefix(k, line) { - o = append(o, k+" ") - } - } - if len(o) > 0 { - return o - } - - for k, cmd := range c.cmds { - if strings.HasPrefix(line, k) { - o = append(o, cmd.Complete(line)...) - } - } - return o - }) - - f, err := os.Open(".pawgo.history") - if err == nil { - defer f.Close() - _, _ = c.rl.ReadHistory(f) - } - - return &c -} - -func (c *Cmd) Close() error { - var err error - - err = c.fmgr.Close() - if err != nil { - return fmt.Errorf("could not close file manager: %w", err) - } - - err = c.wmgr.Close() - if err != nil { - return fmt.Errorf("could not close window manager: %w", err) - } - - f, err := os.Create(".pawgo.history") - if err == nil { - defer f.Close() - _, _ = c.rl.WriteHistory(f) - } - - e := c.rl.Close() - if e != nil { - if err != nil { - err = e - } - } - if err != nil { - return fmt.Errorf("could not close REPL: %w", err) - } - - return nil -} - -func (c *Cmd) Run() error { - for { - o, err := c.rl.Prompt("paw> ") - if err != nil { - if err == io.EOF { - _, _ = c.msg.Writer().Write([]byte("\n")) - err = nil - } - return err - } - //fmt.Printf("<@ %q\n", o) - if o == "" { - continue - } - err = c.exec(o) - if err != nil { - if err == io.EOF { - return err - } - c.msg.Printf("error: %v\n", err) - } - c.rl.AppendHistory(o) - } -} - -func (c *Cmd) RunScript(r io.Reader) error { - scan := bufio.NewScanner(r) - for scan.Scan() { - err := scan.Err() - if err != nil { - break - } - line := scan.Text() - if line == "" || line[0] == '#' { - continue - } - fmt.Fprintf(c.msg.Writer(), "# %s\n", line) - err = c.exec(line) - if err == io.EOF { - return err - } - if err != nil { - c.msg.Printf("error executing %q: %v\n", line, err) - return err - } - } - - err := scan.Err() - if err == io.EOF { - err = nil - } - return err -} - -func (c *Cmd) exec(line string) error { - args, err := shlex.Split(line) - if err != nil { - return fmt.Errorf("paw: splitting line failed: %w", err) - } - cmd, ok := c.cmds[args[0]] - if !ok { - return fmt.Errorf("unknown command %q", args[0]) - } - err = cmd.Run(args[1:]) - return err -} diff --git a/pawgo/cmd_file.go b/pawgo/cmd_file.go deleted file mode 100644 index 72ae7ee95..000000000 --- a/pawgo/cmd_file.go +++ /dev/null @@ -1,150 +0,0 @@ -// Copyright ©2015 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" - "path/filepath" - "strings" - - "github.com/google/shlex" -) - -// cmdFileOpen opens a file for read access -type cmdFileOpen struct { - ctx *Cmd -} - -func (cmd *cmdFileOpen) Name() string { - return "/file/open" -} - -func (cmd *cmdFileOpen) Run(args []string) error { - var err error - id := args[0] - fname := args[1] - err = cmd.ctx.fmgr.open(id, fname) - return err -} - -func (cmd *cmdFileOpen) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- open file for read access\n", cmd.Name()) -} - -func (cmd *cmdFileOpen) Complete(line string) []string { - var o []string - args, err := shlex.Split(line) - if err != nil { - cmd.ctx.msg.Printf("error splitting line: %v\n", err) - return o - } - switch len(args) { - case 0: - return o - case 1: - // fmt.Printf(">>> %q\n", args[0]) - case 2: - // fmt.Printf("### %q %q\n", args[0], args[1]) - case 3: - // fmt.Printf("+++ %q %q %q\n", args[0], args[1], args[2]) - if args[2] != "" { - matches, err := filepath.Glob(args[2] + "*") - //fmt.Printf(">>> matches: %v\nerr=%v\n", matches, err) - if err != nil { - return o - } - for _, m := range matches { - mm := strings.Trim(m, "\t\n\r ") - if mm != "" { - args[2] = mm - o = append(o, strings.Join(args, " ")) - } - } - } - } - - return o -} - -// cmdFileCreate creates a file for write access -type cmdFileCreate struct { - ctx *Cmd -} - -func (cmd *cmdFileCreate) Name() string { - return "/file/create" -} - -func (cmd *cmdFileCreate) Run(args []string) error { - var err error - id := args[0] - fname := args[1] - err = cmd.ctx.fmgr.create(id, fname) - return err -} - -func (cmd *cmdFileCreate) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- create file for write access\n", cmd.Name()) -} - -func (cmd *cmdFileCreate) Complete(line string) []string { - var o []string - return o -} - -// cmdFileClose closes a file -type cmdFileClose struct { - ctx *Cmd -} - -func (cmd *cmdFileClose) Name() string { - return "/file/close" -} - -func (cmd *cmdFileClose) Run(args []string) error { - var err error - id := args[0] - err = cmd.ctx.fmgr.close(id) - return err -} - -func (cmd *cmdFileClose) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- close a file\n", cmd.Name()) -} - -func (cmd *cmdFileClose) Complete(line string) []string { - var o []string - return o -} - -// cmdFileList closes a file -type cmdFileList struct { - ctx *Cmd -} - -func (cmd *cmdFileList) Name() string { - return "/file/ls" -} - -func (cmd *cmdFileList) Run(args []string) error { - switch len(args) { - case 0: - return cmd.ctx.fmgr.ls("") - case 1: - return cmd.ctx.fmgr.ls(args[0]) - default: - return fmt.Errorf("%s: need at most 1 file id", cmd.Name()) - } -} - -func (cmd *cmdFileList) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- list a file's content\n", cmd.Name()) -} - -func (cmd *cmdFileList) Complete(line string) []string { - var o []string - return o -} diff --git a/pawgo/cmd_help.go b/pawgo/cmd_help.go deleted file mode 100644 index da07b9632..000000000 --- a/pawgo/cmd_help.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright ©2015 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" - "sort" - "strings" - "text/tabwriter" -) - -// cmdHelp prints the help -type cmdHelp struct { - ctx *Cmd -} - -func (cmd *cmdHelp) Name() string { - return "/?" -} - -func (cmd *cmdHelp) Run(args []string) error { - var err error - switch len(args) { - case 0: - var cmds []string - for k := range cmd.ctx.cmds { - cmds = append(cmds, k) - } - sort.Strings(cmds) - w := tabwriter.NewWriter(cmd.ctx.msg.Writer(), 0, 8, 0, '\t', 0) - for _, k := range cmds { - c := cmd.ctx.cmds[k] - c.Help(w) - } - w.Flush() - case 1: - c, ok := cmd.ctx.cmds[args[0]] - if !ok { - return fmt.Errorf("unknown command %q", args[0]) - } - w := tabwriter.NewWriter(cmd.ctx.msg.Writer(), 0, 8, 0, '\t', 0) - c.Help(w) - w.Flush() - } - return err -} - -func (cmd *cmdHelp) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- print help\n", cmd.Name()) -} - -func (cmd *cmdHelp) Complete(line string) []string { - var o []string - args := strings.Split(line, " ") - switch len(args) { - case 0, 1: - return o - case 2: - if args[1] == "" { - args[1] = "/" - } - for k := range cmd.ctx.cmds { - if strings.HasPrefix(k, args[1]) { - o = append(o, strings.Join(args[:1], " ")+" "+k) - } - } - } - return o -} diff --git a/pawgo/cmd_hist.go b/pawgo/cmd_hist.go deleted file mode 100644 index 8a3c041c1..000000000 --- a/pawgo/cmd_hist.go +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright ©2015 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" - "strings" -) - -// cmdHistOpen opens a histogram -type cmdHistOpen struct { - ctx *Cmd -} - -func (cmd *cmdHistOpen) Name() string { - return "/hist/open" -} - -func (cmd *cmdHistOpen) Run(args []string) error { - if len(args) < 2 { - return fmt.Errorf("%s: need histo-id and histo-name (got=%v)", cmd.Name(), args) - } - - hid := args[0] - - // e.g: /file/id/1/my-histo - hname := args[1] - - return cmd.ctx.hmgr.open(cmd.ctx.fmgr, hid, hname) -} - -func (cmd *cmdHistOpen) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- open a histogram\n", cmd.Name()) -} - -func (cmd *cmdHistOpen) Complete(line string) []string { - var o []string - args := strings.Split(line, " ") - switch len(args) { - case 0, 1: - return o - case 2: - return o - case 3: - if args[2] == "" { - args[2] = "/file/id/" - } - for id := range cmd.ctx.fmgr.rfds { - switch { - case strings.HasPrefix("/file/id/"+id+"/", args[2]): - r := cmd.ctx.fmgr.rfds[id] - v := "/file/id/" + id + "/" - for _, k := range r.rio.Keys() { - if strings.HasPrefix(v+k.Name, args[2]) { - o = append(o, strings.Join(args[:2], " ")+" "+v+k.Name) - } - } - case strings.HasPrefix("/file/id/"+id, args[2]): - o = append(o, strings.Join(args[:2], " ")+" /file/id/"+id) - } - } - } - return o -} - -// cmdHistPlot plots a histogram -type cmdHistPlot struct { - ctx *Cmd -} - -func (cmd *cmdHistPlot) Name() string { - return "/hist/plot" -} - -func (cmd *cmdHistPlot) Run(args []string) error { - if len(args) < 1 { - return fmt.Errorf("%s: need a histo-id to plot", cmd.Name()) - } - - hid := args[0] - _, err := cmd.ctx.hmgr.plot(cmd.ctx.fmgr, cmd.ctx.wmgr, hid) - if err != nil { - return fmt.Errorf("could not plot histo %s: %w", hid, err) - } - return nil -} - -func (cmd *cmdHistPlot) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- plot a histogram\n", cmd.Name()) -} - -func (cmd *cmdHistPlot) Complete(line string) []string { - var o []string - args := strings.Split(line, " ") - switch len(args) { - case 0, 1: - return o - case 2: - if strings.HasPrefix(args[1], "/") { - for id, r := range cmd.ctx.fmgr.rfds { - for _, k := range r.rio.Keys() { - name := "/file/id/" + id + "/" + k.Name - if strings.HasPrefix(name, args[1]) { - o = append(o, args[0]+" "+name) - } - } - } - return o - } - for k := range cmd.ctx.hmgr.hmap { - if strings.HasPrefix(k, args[1]) { - o = append(o, args[0]+" "+k) - } - } - return o - } - return o -} diff --git a/pawgo/cmd_quit.go b/pawgo/cmd_quit.go deleted file mode 100644 index 5e8f90e93..000000000 --- a/pawgo/cmd_quit.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright ©2016 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" -) - -// cmdQuit exits the application. -type cmdQuit struct { - ctx *Cmd -} - -func (cmd *cmdQuit) Name() string { - return "/quit" -} - -func (cmd *cmdQuit) Run(args []string) error { - return io.EOF -} - -func (cmd *cmdQuit) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- quit PAW-Go\n", cmd.Name()) -} - -func (cmd *cmdQuit) Complete(line string) []string { - var o []string - return o -} diff --git a/pawgo/cmd_shell.go b/pawgo/cmd_shell.go deleted file mode 100644 index 64f187df6..000000000 --- a/pawgo/cmd_shell.go +++ /dev/null @@ -1,66 +0,0 @@ -// Copyright ©2016 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" - "os" - "os/exec" - "path/filepath" - "strings" - - "github.com/google/shlex" -) - -// cmdShell runs a shell command. -type cmdShell struct { - ctx *Cmd -} - -func (cmd *cmdShell) Name() string { - return "/!" -} - -func (cmd *cmdShell) Run(args []string) error { - sh := exec.Command(args[0], args[1:]...) - sh.Stdin = os.Stdin - sh.Stdout = cmd.ctx.msg.Writer() - sh.Stderr = cmd.ctx.msg.Writer() - return sh.Run() -} - -func (cmd *cmdShell) Help(w io.Writer) { - fmt.Fprintf(w, "%s \t-- run a shell command\n", cmd.Name()) -} - -func (cmd *cmdShell) Complete(line string) []string { - var o []string - args, err := shlex.Split(line) - if err != nil { - cmd.ctx.msg.Printf("error splitting line: %v\n", err) - return o - } - if len(args) < 2 { - return o - } - i := len(args) - 1 - if args[i] != "" { - matches, err := filepath.Glob(args[i] + "*") - //fmt.Printf(">>> matches: %v\nerr=%v\n", matches, err) - if err != nil { - return o - } - for _, m := range matches { - mm := strings.Trim(m, "\t\n\r ") - if mm != "" { - args[i] = mm - o = append(o, strings.Join(args, " ")) - } - } - } - - return o -} diff --git a/pawgo/fmgr.go b/pawgo/fmgr.go deleted file mode 100644 index a48e6ee9d..000000000 --- a/pawgo/fmgr.go +++ /dev/null @@ -1,242 +0,0 @@ -// Copyright ©2017 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "io" - "log" - "os" - "text/tabwriter" - - "go-hep.org/x/hep/rio" -) - -type fileType interface { - io.Reader - io.Seeker - io.Closer -} - -type rfile struct { - id string - n string - r fileType - rio *rio.File -} - -func (r *rfile) open(fname string) error { - var err error - - r.n = fname - r.r, err = os.Open(fname) - if err != nil { - return err - } - - r.rio, err = rio.Open(r.r) - if err != nil { - return err - } - - return err -} - -func (r *rfile) ls(o io.Writer) error { - var err error - - fmt.Fprintf(o, "/file/id/%s name=%s\n", r.id, r.n) - w := tabwriter.NewWriter(o, 0, 8, 0, '\t', 0) - for _, k := range r.rio.Keys() { - fmt.Fprintf(w, " \t- %s\t(type=%q)\n", k.Name, k.Blocks[0].Type) - } - w.Flush() - fmt.Fprintf(o, "\n") - - return err -} - -func (r *rfile) typ(name string) string { - for _, k := range r.rio.Keys() { - if k.Name == name { - return k.Blocks[0].Type - } - } - - return "" -} - -func (r *rfile) read(name string, ptr interface{}) error { - var err error - - // FIXME(sbinet): when/if "rio" gets the concept of directories, - // handle this there. - if !r.rio.Has(name) { - return fmt.Errorf("no record [%s] in file [id=%s name=%s]", name, r.id, r.n) - } - - err = r.rio.Get(name, ptr) - if err != nil { - return err - } - - return err -} - -func (r *rfile) close() error { - defer r.r.Close() - err := r.rio.Close() - if err != nil { - return err - } - return r.r.Close() -} - -type wfile struct { - id string - n string - w io.WriteCloser - rio *rio.Writer -} - -func (w *wfile) create(fname string) error { - var err error - - w.n = fname - w.w, err = os.Create(fname) - if err != nil { - return err - } - - w.rio, err = rio.NewWriter(w.w) - if err != nil { - return err - } - - return err -} - -func (w *wfile) close() error { - defer w.w.Close() - err := w.rio.Close() - if err != nil { - return err - } - return w.w.Close() -} - -type fileMgr struct { - msg *log.Logger - rfds map[string]rfile - wfds map[string]wfile -} - -func newFileMgr(msg *log.Logger) *fileMgr { - return &fileMgr{ - msg: msg, - rfds: make(map[string]rfile), - wfds: make(map[string]wfile), - } -} - -func (mgr *fileMgr) open(id string, fname string) error { - var err error - r, dup := mgr.rfds[id] - if dup { - return fmt.Errorf("paw: file [id=%s name=%s] already open", id, r.n) - } - - r.id = id - err = r.open(fname) - if err != nil { - return err - } - - mgr.rfds[id] = r - return nil -} - -func (mgr *fileMgr) close(id string) error { - r, ok := mgr.rfds[id] - if ok { - delete(mgr.rfds, id) - return r.close() - } - - w, ok := mgr.wfds[id] - if ok { - delete(mgr.wfds, id) - return w.close() - } - - return fmt.Errorf("paw: unknown file [id=%s]", id) -} - -func (mgr *fileMgr) ls(id string) error { - if id == "" { - // list all - for id := range mgr.rfds { - err := mgr.ls(id) - if err != nil { - return err - } - } - return nil - } - - r, ok := mgr.rfds[id] - if !ok { - return fmt.Errorf("paw: unknown file [id=%s]", id) - } - - err := r.ls(mgr.msg.Writer()) - if err != nil { - return err - } - - return err -} - -func (mgr *fileMgr) create(id string, fname string) error { - var err error - w, dup := mgr.wfds[id] - if dup { - return fmt.Errorf("paw: file [id=%s name=%s] already open", id, w.n) - } - - w.id = id - err = w.create(fname) - if err != nil { - return err - } - - mgr.wfds[id] = w - return nil -} - -func (mgr *fileMgr) Close() error { - var err error - for k, r := range mgr.rfds { - e := r.close() - if e != nil { - mgr.msg.Printf("error closing file [%s]: %v\n", k, e) - if err != nil { - err = e - } - } - } - - for k, w := range mgr.wfds { - e := w.close() - if e != nil { - mgr.msg.Printf("error closing file [%s]: %v\n", k, e) - if err != nil { - err = e - } - } - } - - return err -} diff --git a/pawgo/gen.hsimple.rio.go b/pawgo/gen.hsimple.rio.go deleted file mode 100644 index 6d09be13c..000000000 --- a/pawgo/gen.hsimple.rio.go +++ /dev/null @@ -1,143 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build ignore - -package main - -import ( - "log" - "os" - - "go-hep.org/x/hep/hbook" - "go-hep.org/x/hep/rio" - "golang.org/x/exp/rand" - "gonum.org/v1/gonum/mat" - "gonum.org/v1/gonum/stat/distmv" - "gonum.org/v1/gonum/stat/distuv" -) - -func main() { - h1 := genH1() - h2 := genH2() - s2 := genS2() - p1 := genP1() - - f, err := os.Create("testdata/hsimple.rio") - if err != nil { - log.Fatalf("could not create file: %+v", err) - } - defer f.Close() - - w, err := rio.NewWriter(f) - if err != nil { - log.Fatalf("could not create rio writer: %+v", err) - } - - for _, v := range []struct { - name string - value interface{} - }{ - {"h1", h1}, - {"h2", h2}, - {"s2", s2}, - {"p1", p1}, - } { - err = w.WriteValue(v.name, v.value) - if err != nil { - log.Fatalf("could not write %q: %+v", v.name, err) - } - } - - err = w.Close() - if err != nil { - log.Fatalf("could not close rio writer: %+v", err) - } - - err = f.Close() - if err != nil { - log.Fatalf("could not close file: %+v", err) - } -} - -func genH1() *hbook.H1D { - const npoints = 10000 - - // Create a normal distribution. - dist := distuv.Normal{ - Mu: 0, - Sigma: 1, - Src: rand.New(rand.NewSource(0)), - } - - // Draw some random values from the standard - // normal distribution. - h := hbook.NewH1D(20, -4, +4) - for i := 0; i < npoints; i++ { - v := dist.Rand() - h.Fill(v, 1) - } - - return h -} - -func genH2() *hbook.H2D { - h := hbook.NewH2D(100, -10, 10, 100, -10, 10) - - const npoints = 10000 - - dist, ok := distmv.NewNormal( - []float64{0, 1}, - mat.NewSymDense(2, []float64{4, 0, 0, 2}), - rand.New(rand.NewSource(1234)), - ) - if !ok { - log.Fatalf("error creating distmv.Normal") - } - - v := make([]float64, 2) - // Draw some random values from the standard - // normal distribution. - for i := 0; i < npoints; i++ { - v = dist.Rand(v) - h.Fill(v[0], v[1], 1) - } - - return h -} - -func genS2() *hbook.S2D { - s := hbook.NewS2D(hbook.Point2D{X: 1, Y: 1}, hbook.Point2D{X: 2, Y: 1.5}, hbook.Point2D{X: -1, Y: +2}) - if s == nil { - log.Fatal("nil pointer to S2D") - } - - s.Fill(hbook.Point2D{X: 10, Y: -10, ErrX: hbook.Range{Min: 5, Max: 5}, ErrY: hbook.Range{Min: 6, Max: 6}}) - - return s -} - -func genP1() *hbook.P1D { - const npoints = 1000 - - p := hbook.NewP1D(100, -10, 10) - dist, ok := distmv.NewNormal( - []float64{0, 1}, - mat.NewSymDense(2, []float64{4, 0, 0, 2}), - rand.New(rand.NewSource(1234)), - ) - if !ok { - log.Fatalf("error creating distmv.Normal") - } - - v := make([]float64, 2) - // Draw some random values from the standard - // normal distribution. - for i := 0; i < npoints; i++ { - v = dist.Rand(v) - p.Fill(v[0], v[1], 1) - } - - return p -} diff --git a/pawgo/hmgr.go b/pawgo/hmgr.go deleted file mode 100644 index 36d7dca15..000000000 --- a/pawgo/hmgr.go +++ /dev/null @@ -1,161 +0,0 @@ -// Copyright ©2017 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "fmt" - "log" - "strings" - - "go-hep.org/x/hep/hbook" - "go-hep.org/x/hep/hplot" -) - -type histMgr struct { - msg *log.Logger - hmap map[string]hbook.Histogram -} - -func newHistMgr(msg *log.Logger) *histMgr { - return &histMgr{ - msg: msg, - hmap: make(map[string]hbook.Histogram), - } -} - -func (mgr *histMgr) find(fmgr *fileMgr, path string) (hbook.Histogram, error) { - var err error - const prefix = "/file/id/" - if !strings.HasPrefix(path, prefix) { - return nil, fmt.Errorf("invalid path [%s] (missing prefix [%s])", path, prefix) - } - - var toks []string - for _, tok := range strings.Split(path[len(prefix):], "/") { - tok = strings.TrimSpace(tok) - if tok == "" { - continue - } - toks = append(toks, tok) - } - - if len(toks) < 2 { - return nil, fmt.Errorf("invalid path [%s] (missing file-id and histo-name)", path) - } - - fid := toks[0] - - r, ok := fmgr.rfds[fid] - if !ok { - return nil, fmt.Errorf("unknown file-id [%s]", fid) - } - - hname := strings.Join(toks[1:], "/") - - switch r.typ(hname) { - case "*go-hep.org/x/hep/hbook.H1D": - var h1 hbook.H1D - err = r.read(hname, &h1) - if err != nil { - return nil, err - } - return &h1, nil - - case "*go-hep.org/x/hep/hbook.H2D": - var h2 hbook.H2D - err = r.read(hname, &h2) - if err != nil { - return nil, err - } - return &h2, nil - - default: - return nil, fmt.Errorf("%q not an histogram (%s)", path, r.typ(hname)) - } -} - -func (mgr *histMgr) open(fmgr *fileMgr, hid, path string) error { - h, err := mgr.find(fmgr, path) - if err != nil { - return err - } - mgr.hmap[hid] = h - return nil -} - -func (mgr *histMgr) plot(fmgr *fileMgr, wmgr *winMgr, hid string) (*window, error) { - var ( - h hbook.Histogram - err error - ) - if strings.HasPrefix(hid, "/file/id/") { - // directly plot from file - h, err = mgr.find(fmgr, hid) - if err != nil { - return nil, err - } - } else { - var ok bool - h, ok = mgr.hmap[hid] - if !ok { - return nil, fmt.Errorf("unknown histogram [id=%s]", hid) - } - } - - switch h := h.(type) { - case *hbook.H1D: - return mgr.plotH1D(wmgr, h) - case *hbook.H2D: - return mgr.plotH2D(wmgr, h) - } - - return nil, fmt.Errorf("unknown histogram type %T [id=%s]", h, hid) -} - -func (mgr *histMgr) plotH1D(wmgr *winMgr, h *hbook.H1D) (*window, error) { - fmt.Fprintf( - mgr.msg.Writer(), - "== h1d: name=%q\nentries=%d\nmean=%+8.3f\nRMS= %+8.3f\n", - h.Name(), h.Entries(), h.XMean(), h.XRMS(), - ) - - p := hplot.New() - p.Title.Text = h.Name() - p.X.Label.Text = "x" - p.Y.Label.Text = "y" - - hh := hplot.NewH1D(h) - hh.Infos.Style = hplot.HInfoSummary - - p.Add(hh) - p.Add(hplot.NewGrid()) - - win := wmgr.newPlot(p) - return win, nil -} - -func (mgr *histMgr) plotH2D(wmgr *winMgr, h *hbook.H2D) (*window, error) { - fmt.Fprintf( - mgr.msg.Writer(), - "== h2d: name=%q\nentries=%d\nxmean=%+8.3f\nxRMS= %+8.3f\nymean=%+8.3f\nyRMS= %+8.3f\n", - h.Name(), h.Entries(), - h.XMean(), h.XRMS(), - h.YMean(), h.YRMS(), - ) - - p := hplot.New() - p.Title.Text = h.Name() - p.X.Label.Text = "x" - p.Y.Label.Text = "y" - - hh := hplot.NewH2D(h, nil) - hh.Infos.Style = hplot.HInfoNone - - p.Add(hh) - p.Add(hplot.NewGrid()) - - win := wmgr.newPlot(p) - return win, nil -} diff --git a/pawgo/main.go b/pawgo/main.go deleted file mode 100644 index df001d949..000000000 --- a/pawgo/main.go +++ /dev/null @@ -1,116 +0,0 @@ -// Copyright ©2015 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -// pawgo is a simple interactive shell to quickly plot hbook histograms from -// rio files. -// -// Example: -// -// $> pawgo -// paw> /file/open f testdata/issue-120.rio -// paw> /file/ls f -// /file/id/f name=testdata/issue-120.rio -// - MonoH_Truth/jets (type="*go-hep.org/x/hep/hbook.H1D") -// -// paw> /hist/open h /file/id/f/MonoH_Truth/jets -// paw> /hist/plot h -// == h1d: name="MonoH_Truth/jets" -// entries=20000 -// mean= +2.554 -// RMS= +2.891 -// paw> /? -// /! -- run a shell command -// /? -- print help -// /file/close -- close a file -// /file/create -- create file for write access -// /file/list -- list a file's content -// /file/open -- open file for read access -// /hist/open -- open a histogram -// /hist/plot -- plot a histogram -// /quit -- quit PAW-Go -package main // import "go-hep.org/x/hep/pawgo" - -//go:generate go run ./gen.hsimple.go - -import ( - "flag" - "fmt" - "io" - "os" -) - -func main() { - interactive := flag.Bool( - "i", false, - "enable interactive mode: drop into PAW-Go prompt after processing script files", - ) - - flag.Parse() - - go func() { - rc := xmain(os.Stdout, *interactive, flag.Args()) - os.Exit(rc) - }() - - appMain() -} - -func xmain(stdout io.Writer, interactive bool, args []string) int { - - fmt.Fprintf(stdout, ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -`) - - icmd := newCmd(stdout) - defer icmd.Close() - defer fmt.Fprintf(stdout, "bye.\n") - - if len(args) > 0 { - for _, fname := range args { - rc := func(fname string) int { - f, err := os.Open(fname) - if err != nil { - icmd.msg.Printf("error: %+v\n", err) - return 1 - } - defer f.Close() - - err = icmd.RunScript(f) - if err == io.EOF { - return 0 - } - if err != nil { - icmd.msg.Printf("error running script [%s]: %+v\n", f.Name(), err) - return 1 - } - - return 0 - }(fname) - - if rc != 0 { - return rc - } - } - if !interactive { - return 0 - } - } - - err := icmd.Run() - if err == io.EOF { - err = nil - } - if err != nil { - icmd.msg.Printf("error running interpreter: %v\n", err) - return 1 - } - - return 0 -} diff --git a/pawgo/main_test.go b/pawgo/main_test.go deleted file mode 100644 index 92263ecc8..000000000 --- a/pawgo/main_test.go +++ /dev/null @@ -1,295 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "bytes" - "os" - "path" - "runtime" - "testing" - - "github.com/google/go-cmp/cmp" -) - -func TestPawgo(t *testing.T) { - var ( - stdout = new(bytes.Buffer) - interactive bool - args []string - ) - - rc := xmain(stdout, interactive, args) - if rc != 0 { - t.Fatalf("invalid exit-code: %d", rc) - } -} - -func TestPawgoScript(t *testing.T) { - tmp, err := os.MkdirTemp("", "pawgo-") - if err != nil { - t.Fatalf("could not create tmpdir: %+v", err) - } - defer os.RemoveAll(tmp) - - for _, tc := range []struct { - name string - script string - want string - interactive bool - }{ - { - name: "basic", - script: `## comment - -## open the rio file hsimple.rio, assign it the variable name 'f' -/file/open f ./testdata/hsimple.rio - -## list the content of the rio file 'f' -/file/ls f - -## open the hbook.H1D histogram 'h1' from file 'f', assign it the variable name 'h' -/hist/open h /file/id/f/h1 - -/file/close f -`, - want: ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /file/open f ./testdata/hsimple.rio -# /file/ls f -/file/id/f name=./testdata/hsimple.rio - - h1 (type="*go-hep.org/x/hep/hbook.H1D") - - h2 (type="*go-hep.org/x/hep/hbook.H2D") - - p1 (type="*go-hep.org/x/hep/hbook.P1D") - - s2 (type="*go-hep.org/x/hep/hbook.S2D") - -# /hist/open h /file/id/f/h1 -# /file/close f -bye. -`, - interactive: false, - }, - { - name: "help", - script: "/?\n/? /file/open", - want: ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /? -/! -- run a shell command -/? -- print help -/file/close -- close a file -/file/create -- create file for write access -/file/ls -- list a file's content -/file/open -- open file for read access -/hist/open -- open a histogram -/hist/plot -- plot a histogram -/quit -- quit PAW-Go -# /? /file/open -/file/open -- open file for read access -bye. -`, - interactive: false, - }, - { - name: "quit", - script: "/quit\n", - want: ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /quit -bye. -`, - interactive: false, - }, - { - name: "hplot-cmd", - script: `## comment - -/file/open f ./testdata/hsimple.rio -/hist/open h1 /file/id/f/h1 -/hist/plot h1 -/hist/open h2 /file/id/f/h2 -/hist/plot h2 -/quit -`, - want: ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /file/open f ./testdata/hsimple.rio -# /hist/open h1 /file/id/f/h1 -# /hist/plot h1 -== h1d: name="" -entries=10000 -mean= +0.004 -RMS= +1.005 -# /hist/open h2 /file/id/f/h2 -# /hist/plot h2 -== h2d: name="" -entries=10000 -xmean= +0.027 -xRMS= +2.003 -ymean= +0.992 -yRMS= +1.723 -# /quit -bye. -`, - interactive: false, - }, - } { - t.Run(tc.name, func(t *testing.T) { - var ( - stdout = new(bytes.Buffer) - fname = path.Join(tmp, tc.name+".paw") - args = []string{fname} - ) - - err = os.WriteFile(fname, []byte(tc.script), 0644) - - rc := xmain(stdout, tc.interactive, args) - if rc != 0 { - t.Fatalf("invalid exit-code: %d", rc) - } - - if got, want := stdout.String(), tc.want; got != want { - t.Fatalf("stdout differ:\n%s\n", - cmp.Diff( - string(want), - string(got), - ), - ) - } - }) - } -} - -func TestPawgoShellCommand(t *testing.T) { - tmp, err := os.MkdirTemp("", "pawgo-") - if err != nil { - t.Fatalf("could not create tmpdir: %+v", err) - } - defer os.RemoveAll(tmp) - - var ( - stdout = new(bytes.Buffer) - interactive bool - fname = path.Join(tmp, "script.paw") - args = []string{fname} - ) - - script := "/! ls testdata\n" - if runtime.GOOS == "windows" { - script = "/! dir testdata\n" - } - - err = os.WriteFile(fname, []byte(script), 0644) - if err != nil { - t.Fatal(err) - } - - rc := xmain(stdout, interactive, args) - if rc != 0 { - t.Fatalf("invalid exit-code: %d", rc) - } - - want := "" - switch runtime.GOOS { - case "windows": - want = ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /! dir testdata -hsimple.rio issue-120.paw issue-120.rio script.paw -bye. -` - - default: - want = ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /! ls testdata -hsimple.rio -issue-120.paw -issue-120.rio -script.paw -bye. -` - } - - if got, want := stdout.String(), want; got != want { - t.Fatalf("stdout differ:\n%s\n", - cmp.Diff( - string(want), - string(got), - ), - ) - } -} - -func TestIssue120(t *testing.T) { - var ( - stdout = new(bytes.Buffer) - interactive bool - args = []string{"./testdata/issue-120.paw"} - ) - - rc := xmain(stdout, interactive, args) - if rc != 0 { - t.Fatalf("invalid exit-code: %d", rc) - } - - want := ` -::::::::::::::::::::::::::::: -::: Welcome to PAW-Go ::: -::::::::::::::::::::::::::::: - -Type /? for help. -^D or /quit to quit. - -# /file/open f ./testdata/issue-120.rio -# /hist/open h /file/id/f/MonoH_Truth/jets -bye. -` - - if got, want := stdout.String(), want; got != want { - t.Fatalf("stdout differ:\n%s\n", - cmp.Diff( - string(want), - string(got), - ), - ) - } -} diff --git a/pawgo/testdata/hsimple.rio b/pawgo/testdata/hsimple.rio deleted file mode 100644 index 29690b514..000000000 Binary files a/pawgo/testdata/hsimple.rio and /dev/null differ diff --git a/pawgo/testdata/issue-120.paw b/pawgo/testdata/issue-120.paw deleted file mode 100644 index 78dc1be9d..000000000 --- a/pawgo/testdata/issue-120.paw +++ /dev/null @@ -1,3 +0,0 @@ -/file/open f ./testdata/issue-120.rio -/hist/open h /file/id/f/MonoH_Truth/jets - diff --git a/pawgo/testdata/issue-120.rio b/pawgo/testdata/issue-120.rio deleted file mode 100644 index 9ef05f97a..000000000 Binary files a/pawgo/testdata/issue-120.rio and /dev/null differ diff --git a/pawgo/testdata/script.paw b/pawgo/testdata/script.paw deleted file mode 100644 index f3291cfd4..000000000 --- a/pawgo/testdata/script.paw +++ /dev/null @@ -1,21 +0,0 @@ -## a simple PAW-Go test script - -## /! runs a shell command -/! ls ./testdata - -## open the rio file hsimple.rio, assign it the variable name 'f' -/file/open f ./testdata/hsimple.rio - -## list the content of the rio file 'f' -/file/ls f - -## open the hbook.H1D histogram 'h1' from file 'f', assign it the variable name 'h' -/hist/open h /file/id/f/h1 - -## plot the hbook.H1D histogram 'h' -/hist/plot h - -## leaving /quit uncommented will make PAW-Go exit -# /quit - -## EOF diff --git a/pawgo/wmgr.go b/pawgo/wmgr.go deleted file mode 100644 index 647feaa5f..000000000 --- a/pawgo/wmgr.go +++ /dev/null @@ -1,156 +0,0 @@ -// Copyright ©2017 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build !cross_compile - -package main - -import ( - "log" - "math" - "sync" - - "gioui.org/app" - "gioui.org/io/event" - "gioui.org/io/key" - "gioui.org/io/system" - "gioui.org/layout" - "gioui.org/op" - "gioui.org/op/clip" - "gioui.org/unit" - "go-hep.org/x/hep/hplot" - "gonum.org/v1/plot/vg" - "gonum.org/v1/plot/vg/draw" - "gonum.org/v1/plot/vg/vggio" -) - -const ( - xmax = vg.Length(400) - ymax = vg.Length(400 / math.Phi) - dpi = vggio.DefaultDPI // FIXME(sbinet): remove? -) - -type winMgr struct { - msg *log.Logger - quit chan int - once sync.Once - wg sync.WaitGroup -} - -func newWinMgr(msg *log.Logger) *winMgr { - return &winMgr{ - msg: msg, - quit: make(chan int), - } -} - -func (wmgr *winMgr) Close() error { - wmgr.once.Do(wmgr.doClose) - return nil -} - -func (wmgr *winMgr) doClose() { - close(wmgr.quit) -} - -func (wmgr *winMgr) newPlot(p *hplot.Plot) *window { - wmgr.wg.Add(1) - win := newWindow(p) - go win.run(wmgr) - return win -} - -type window struct { - w *app.Window - keys key.Set - ready chan int - - mu sync.Mutex - plt *hplot.Plot -} - -func newWindow(p *hplot.Plot) *window { - title := p.Plot.Title.Text - switch title { - case "": - title = "PAW-Go" - default: - title = "PAW-Go [" + title + "]" - } - - x := unit.Dp(float32(xmax.Dots(dpi))) - y := unit.Dp(float32(ymax.Dots(dpi))) - - win := &window{ - w: app.NewWindow(app.Title(title), app.Size(x, y)), - keys: key.NameEscape + "|Q", - plt: p, - ready: make(chan int), - } - return win -} - -func (w *window) run(wmgr *winMgr) { - defer wmgr.wg.Done() - close(w.ready) - - for { - select { - case e := <-w.w.Events(): - o := w.handle(e) - if o == winStop { - return - } - case <-wmgr.quit: - return - } - } -} - -type winState byte - -const ( - winContinue winState = iota - winStop -) - -func (w *window) handle(e event.Event) winState { - switch e := e.(type) { - case system.DestroyEvent: - return winStop - case system.FrameEvent: - var ( - ops op.Ops - gtx = layout.NewContext(&ops, e) - ) - // register a global key listener for the escape key wrapping our entire UI. - area := clip.Rect{Max: gtx.Constraints.Max}.Push(gtx.Ops) - key.InputOp{ - Tag: w.w, - Keys: w.keys, - }.Add(gtx.Ops) - - for _, e := range gtx.Events(w.w) { - switch e := e.(type) { - case key.Event: - switch e.Name { - case "Q", key.NameEscape: - return winStop - } - } - } - area.Pop() - - cnv := vggio.New( - gtx, - xmax, ymax, - vggio.UseDPI(dpi), - ) - w.mu.Lock() - w.plt.Draw(draw.New(cnv)) - w.mu.Unlock() - e.Frame(cnv.Paint()) - } - return winContinue -} diff --git a/pawgo/wmgr_test.go b/pawgo/wmgr_test.go deleted file mode 100644 index 81d5172b3..000000000 --- a/pawgo/wmgr_test.go +++ /dev/null @@ -1,53 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -package main - -import ( - "testing" - - "gioui.org/io/key" - "gioui.org/io/router" - "gioui.org/io/system" - "gioui.org/op" - "go-hep.org/x/hep/hplot" -) - -func TestPlot(t *testing.T) { - wmgr := newWinMgr(nil) - defer wmgr.Close() - - p := hplot.New() - p.Title.Text = "my plot" - p.X.Label.Text = "x" - p.Y.Label.Text = "y" - - win := wmgr.newPlot(p) - <-win.ready - - rc := win.handle(system.FrameEvent{ - Frame: func(frame *op.Ops) {}, - Queue: new(router.Router), - }) - if got, want := rc, winContinue; got != want { - t.Fatalf("invalid window state: got=%v, want=%v", got, want) - } - - rc = win.handle(key.Event{Name: "Q"}) - if got, want := rc, winContinue; got != want { - t.Fatalf("invalid window state: got=%v, want=%v", got, want) - } - - rc = win.handle(system.DestroyEvent{Err: nil}) - if got, want := rc, winStop; got != want { - t.Fatalf("invalid window state: got=%v, want=%v", got, want) - } - - err := wmgr.Close() - if err != nil { - t.Fatalf("could not close wmgr: %+v", err) - } - - wmgr.wg.Wait() -} diff --git a/pawgo/wmgr_xcomp.go b/pawgo/wmgr_xcomp.go deleted file mode 100644 index 6d7b2a50a..000000000 --- a/pawgo/wmgr_xcomp.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright ©2020 The go-hep Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build cross_compile - -package main - -import ( - "log" - - "go-hep.org/x/hep/hplot" -) - -type winMgr struct { - msg *log.Logger -} - -func newWinMgr(msg *log.Logger) *winMgr { - return &winMgr{ - msg: msg, - } -} - -func (wmgr *winMgr) newPlot(p *hplot.Plot) *window { - return nil -} - -func (wmgr *winMgr) Close() error { - return nil -} - -type window struct { -}