import { expect } from 'chai'; import * as cheerio from 'cheerio'; import sizeOf from 'image-size'; import fs from 'fs/promises'; import { fileURLToPath } from 'url'; import { loadFixture } from './test-utils.js'; describe('SSG images - dev', function () { let fixture; let devServer; let $; before(async () => { fixture = await loadFixture({ root: './fixtures/basic-image/' }); devServer = await fixture.startDevServer(); const html = await fixture.fetch('/').then((res) => res.text()); $ = cheerio.load(html); }); after(async () => { await devServer.stop(); }); [ { title: 'Local images', id: '#social-jpg', url: '/@astroimage/assets/social.jpg', query: { f: 'jpg', w: '506', h: '253' }, }, { title: 'Local image no transforms', id: '#no-transforms', url: '/@astroimage/assets/social.jpg', query: {}, }, { title: 'Filename with spaces', id: '#spaces', url: '/@astroimage/assets/blog/introducing astro.jpg', query: { f: 'webp', w: '768', h: '414' }, }, { title: 'Inline imports', id: '#inline', url: '/@astroimage/assets/social.jpg', query: { f: 'jpg', w: '506', h: '253' }, }, { title: 'Remote images', id: '#google', url: '/_image', query: { f: 'webp', w: '544', h: '184', href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png', }, }, { title: 'Remote without file extension', id: '#ipsum', url: '/_image', query: { w: '200', h: '300', href: 'https://dummyimage.com/200x300', }, }, { title: 'Public images', id: '#hero', url: '/_image', query: { f: 'webp', w: '768', h: '414', href: '/hero.jpg' }, }, { title: 'Background color', id: '#bg-color', url: '/_image', query: { f: 'jpeg', w: '544', h: '184', bg: '#333333', href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png', }, }, ].forEach(({ title, id, url, query }) => { it(title, () => { const image = $(id); const src = image.attr('src'); const [route, params] = src.split('?'); expect(route).to.equal(url); const searchParams = new URLSearchParams(params); for (const [key, value] of Object.entries(query)) { expect(searchParams.get(key)).to.equal(value); } }); }); }); describe('SSG images with subpath - dev', function () { let fixture; let devServer; let $; before(async () => { fixture = await loadFixture({ root: './fixtures/basic-image/', base: '/docs' }); devServer = await fixture.startDevServer(); const html = await fixture.fetch('/docs/').then((res) => res.text()); $ = cheerio.load(html); }); after(async () => { await devServer.stop(); }); [ { title: 'Local images', id: '#social-jpg', url: '/@astroimage/assets/social.jpg', query: { f: 'jpg', w: '506', h: '253' }, }, { title: 'Filename with spaces', id: '#spaces', url: '/@astroimage/assets/blog/introducing astro.jpg', query: { f: 'webp', w: '768', h: '414' }, }, { title: 'Inline imports', id: '#inline', url: '/@astroimage/assets/social.jpg', query: { f: 'jpg', w: '506', h: '253' }, }, { title: 'Remote images', id: '#google', url: '/_image', query: { f: 'webp', w: '544', h: '184', href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png', }, }, { title: 'Remote without file extension', id: '#ipsum', url: '/_image', query: { w: '200', h: '300', href: 'https://dummyimage.com/200x300', }, }, { title: 'Public images', id: '#hero', url: '/_image', query: { f: 'webp', w: '768', h: '414', href: '/docs/hero.jpg' }, }, { title: 'Background color', id: '#bg-color', url: '/_image', query: { f: 'jpeg', w: '544', h: '184', bg: '#333333', href: 'https://www.google.com/images/branding/googlelogo/2x/googlelogo_color_272x92dp.png', }, }, ].forEach(({ title, id, url, query }) => { it(title, () => { const image = $(id); const src = image.attr('src'); const [route, params] = src.split('?'); expect(route).to.equal(url); const searchParams = new URLSearchParams(params); for (const [key, value] of Object.entries(query)) { expect(searchParams.get(key)).to.equal(value); } }); }); }); describe('SSG images - build', function () { let fixture; let $; let html; before(async () => { fixture = await loadFixture({ root: './fixtures/basic-image/' }); await fixture.build(); html = await fixture.readFile('/index.html'); $ = cheerio.load(html); }); function verifyImage(pathname, expected) { const url = new URL('./fixtures/basic-image/dist/' + pathname, import.meta.url); const dist = fileURLToPath(url); const result = sizeOf(dist); expect(result).to.deep.equal(expected); } [ { title: 'Local images', id: '#social-jpg', regex: /^\/_astro\/social.\w{8}_\w{4,10}.jpg/, size: { width: 506, height: 253, type: 'jpg' }, }, { title: 'Filename with spaces', id: '#spaces', regex: /^\/_astro\/introducing astro.\w{8}_\w{4,10}.webp/, size: { width: 768, height: 414, type: 'webp' }, }, { title: 'Inline imports', id: '#inline', regex: /^\/_astro\/social.\w{8}_\w{4,10}.jpg/, size: { width: 506, height: 253, type: 'jpg' }, }, { title: 'Remote images', id: '#google', regex: /^\/_astro\/googlelogo_color_272x92dp_\w{4,10}.webp/, size: { width: 544, height: 184, type: 'webp' }, }, { title: 'Remote without file extension', id: '#ipsum', regex: /^\/_astro\/200x300_\w{4,10}/, size: { width: 200, height: 300, type: 'jpg' }, }, { title: 'Public images', id: '#hero', regex: /^\/_astro\/hero_\w{4,10}.webp/, size: { width: 768, height: 414, type: 'webp' }, }, { title: 'Remote images', id: '#bg-color', regex: /^\/_astro\/googlelogo_color_272x92dp_\w{4,10}.jpeg/, size: { width: 544, height: 184, type: 'jpg' }, }, ].forEach(({ title, id, regex, size }) => { it(title, async () => { const image = $(id); expect(image.attr('src')).to.match(regex); expect(image.attr('width')).to.equal(size.width.toString()); expect(image.attr('height')).to.equal(size.height.toString()); verifyImage(image.attr('src'), size); const url = new URL( './fixtures/basic-image/node_modules/.astro/image' + image.attr('src'), import.meta.url ); expect(await fs.stat(url), 'transformed image was cached').to.not.be.undefined; }); }); }); describe('SSG images with subpath - build', function () { let fixture; let $; let html; before(async () => { fixture = await loadFixture({ root: './fixtures/basic-image/', base: '/docs' }); await fixture.build(); html = await fixture.readFile('/index.html'); $ = cheerio.load(html); }); function verifyImage(pathname, expected) { const url = new URL('./fixtures/basic-image/dist/' + pathname, import.meta.url); const dist = fileURLToPath(url); const result = sizeOf(dist); expect(result).to.deep.equal(expected); } [ { title: 'Local images', id: '#social-jpg', regex: /^\/docs\/_astro\/social.\w{8}_\w{4,10}.jpg/, size: { width: 506, height: 253, type: 'jpg' }, }, { title: 'Filename with spaces', id: '#spaces', regex: /^\/docs\/_astro\/introducing astro.\w{8}_\w{4,10}.webp/, size: { width: 768, height: 414, type: 'webp' }, }, { title: 'Inline imports', id: '#inline', regex: /^\/docs\/_astro\/social.\w{8}_\w{4,10}.jpg/, size: { width: 506, height: 253, type: 'jpg' }, }, { title: 'Remote images', id: '#google', regex: /^\/docs\/_astro\/googlelogo_color_272x92dp_\w{4,10}.webp/, size: { width: 544, height: 184, type: 'webp' }, }, { title: 'Remote without file extension', id: '#ipsum', regex: /^\/docs\/_astro\/200x300_\w{4,10}/, size: { width: 200, height: 300, type: 'jpg' }, }, { title: 'Public images', id: '#hero', regex: /^\/docs\/_astro\/hero_\w{4,10}.webp/, size: { width: 768, height: 414, type: 'webp' }, }, { title: 'Remote images', id: '#bg-color', regex: /^\/docs\/_astro\/googlelogo_color_272x92dp_\w{4,10}.jpeg/, size: { width: 544, height: 184, type: 'jpg' }, }, ].forEach(({ title, id, regex, size }) => { it(title, () => { const image = $(id); expect(image.attr('src')).to.match(regex); expect(image.attr('width')).to.equal(size.width.toString()); expect(image.attr('height')).to.equal(size.height.toString()); verifyImage(image.attr('src').replace('/docs', ''), size); }); }); }); d>-661/+609 * Simplify momentum initialization in example input files * Update benchmarks * Trigger Build * Apply suggestions from code review Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Add more amrex prefix * Remove using namespace amrex in PlasmaInjector.cpp * Fix compilation with OpenPMD Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2021-10-19BinaryCollision: implement particle creation functor (#2315)Gravatar Neïl Zaim 6-103/+313 * BinaryCollision: implement particle creation functor * Apply suggestions from code review (restrict keyword) Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> * Don't restrict the particle pointers * Use atomicSetID * Use more restricts * Don't use auto restrict Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> 2021-10-19Add reduced diag test in single precision (#2398)Gravatar Luca Fedeli 5-305/+392 * fix kinetic energy calculation in single precision * really fix the issue... * add missing _rt * we don't need m2 now * remove unused variable * initial work to add reduced diags test in single precision * updated tests * add back accidentally deleted comment * reduced tolerance in single precision * increase tolerance in single precision * always perform kinetic energy calculation in double precision * put w where it was * fixed bug * fixed bug * add json file for new test * use threshold for kinetic energy * fix bug * increase order of Taylor expansion * increase order of Taylor expansion * reduce classical/relativistic threshold for kinetic energy * reset threshold to 1.005 * improve test Co-authored-by: Tools <warpx@lbl.gov> 2021-10-19Added --detach to the updating scripts (#2447)Gravatar David Grote 3-3/+3 2021-10-19Simplify Esirkepov formula even more (#2374)Gravatar Remi Lehe 2-20/+26 * Simplify formulas for Esirkepov deposition * Simplify Esirkepov formulas even more * Update Source/Particles/Deposition/CurrentDeposition.H 2021-10-18Use os.path.join in picmi.py for portability (#2400)Gravatar Andrew Myers 1-4/+5 * Use os.path.join in picmi.py for portability * Apply suggestions from code review 2021-10-18GH Action CI Builds: Ninja (#2428)Gravatar Axel Huebl 11-26/+87 * GH Action CI Builds: Ninja Use Ninja for most builds to compile faster than using the GNU Makefile generator. * oneAPI: w/o Ninja Seems to be 10% slower for these compilers, so we keep the default. * NVHPC: w/o Ninja Seems to be 10% slower for `nvcc -ccbin=nvc++`, so we keep the default. * macOS: w/o Ninja Seems to be 20% slower, so we keep the default. * Clang pywarpx: w/o Ninja Seems to be 20% slower, so we keep the default. 2021-10-18Docs: Nsight-Systems (#2436)Gravatar Axel Huebl 1-2/+53 * Docs: Nsight-Systems How to use Nsight-Systems. Tested on Cori DGX. * Profiling: Link TinyProfiler Script Co-authored-by: Michael Kieburtz <michaelkieburtz@gmail.com> Co-authored-by: Michael Kieburtz <michaelkieburtz@gmail.com> 2021-10-18Fix typo: code-blockGravatar Axel Huebl 2-2/+2 2021-10-18OLCF/NERSC: Post-Processing (Jupyter) (#2443)Gravatar Axel Huebl 4-0/+80 Doc pages to get started with post-processing using Python and Jupyter at OLCF and NERSC. 2021-10-18Option to do single precision mesh communication. (#2294)Gravatar Andrew Myers 23-138/+581 * option to use single precision guard cell exhanges * add missing files * fix namespace issue * change precision of comms to float * ParmParse the single_precision_comms flag * set back to real * test * make sure dst is filled * nGrow -> nGrowVect * restore float * don't override valid cells * single precision mesh * whitespace * wrap SumBoundary * Wrap additional uses of FillBoundary. * catch missing copies of ParallelCopy * missing OverrideSyncs * add wrapper for iMultifab * fix typo * moar typos * typo * strip single_precision_mesh option * fix original copy * update fusible syntax Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov> * Fix: Single Precision Builds Should not copy around data for `do_single_precision_comms` * Docs: warpx.do_single_precision_comms * initialize this tmp multifab to 0.0 * fix tiny profile label * remove orig copies, they are only correct for FillBoundary * loosen tolerance for space charge tests for single precision * missing some setVal * another missing setVal * missing setVal * add wrapper for new version of sumboundary * add explicit cast to silence compiler warning * add a test for single precision comms * revert change to test precision * add benchmark for single precision comms test * restore tolerance I removed by mistake * tolerance * copyright headers * drop tolerance for single precision tests in default analysis script * missing python module * bump tol again * fix bad merge * Apply suggestions from code review Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> Co-authored-by: Remi Lehe <remi.lehe@normalesup.org> Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> Co-authored-by: Weiqun Zhang <WeiqunZhang@lbl.gov> 2021-10-18AMReX/PICSAR: Weekly Update (#2442)Gravatar Axel Huebl 4-4/+4 Weekly update to latest AMReX. Weekly update to latest PICSAR (no changes). ``` ./Tools/Release/updatePICSAR.py ./Tools/Release/updateAMReX.py ``` 2021-10-18Improve `BeamRelevant` reduced diagnostics using `AMReX_Tuple`. (#2435)Gravatar Yinjian Zhao 1-247/+143 * Modified BeamRelevant.cpp. * Fix. * BeamRelevant: 10x less MPI Collectives Combine MPI collectives to avoid subsequent expensive global calls. * Fix Variable Shadowing * Prefer AllReduce API Same functionality, but more explicit name * Fix: Unusued Variable p_pos1 Co-authored-by: Axel Huebl <axel.huebl@plasma.ninja> 2021-10-18Spack: No More `load -r` (#2439)Gravatar Axel Huebl 2-2/+2 The `-r` argument was removed from `spack load` and is now implied. 2021-10-18move kinetic energy calculation into Particles/Algorithms (#2441)Gravatar Luca Fedeli 6-24/+88 2021-10-18Multi-J Algo: Synchronize Nodal Points of F,G (#2434)Gravatar Edoardo Zoni 4-23/+49 2021-10-16Add Test: openPMD PICMI (#2438)Gravatar Axel Huebl 3-1/+37 * Gaussian Beam PICMI: Add openPMD Argument Add an `--diagformat` option to switch between plotfiles and openPMD for the Gaussian Beam PICMI example. * CI: openPMD + PICMI on Windows * Regression Test: Add openPMD PICMI * format -> warpx_format 2021-10-16Add automated test for repelling particles (#2427)Gravatar Remi Lehe 4-0/+183 * Add test with repelling particles * Add analysis script * Add as automated test * Add benchmark * Update Examples/Tests/RepellingParticles/inputs_2d * Apply suggestions from code review Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> * Update test * Update benchmark * Update Examples/Tests/RepellingParticles/analysis_repelling.py Co-authored-by: Edoardo Zoni <59625522+EZoni@users.noreply.github.com> 2021-10-16Windows: FS Separator (#2424)Gravatar Axel Huebl 1-1/+42 * Windows: FS Separator Fix the openPMD warning: ``` Filepaths on WINDOWS platforms may not contain slashes '/'! Replacing with backslashes '\' unconditionally! ``` * openPMD: Replace just for Series We might also be able to silence the warning in openPMD-api later on. 2021-10-16Gaussian Laser : fix possible NaN in the calculation of theta_stc (#2433)Gravatar Luca Fedeli 1-3/+7 * fix issue with acos(arg) * fix bug * fix bug * fix bug * fix bug * fix GPU compilation issue 2021-10-15CI: Windows with Python (#2412)Gravatar Axel Huebl 3-5/+29 * Python: generalize library search (Win) * CMake: Honor Multi-Config Lib Alias For multi-config build generators (MSVC, Ninja opt-in), we have a deeper build structure based on the build type. Honor this structure for the (Python) library alias/symlink. * CI: Windows with Python Co-authored-by: Dave Grote <dpgrote@lbl.gov> 2021-10-15Made explicit several casts (#2431)Gravatar David Grote 2-7/+7 2021-10-15Synchronize GPU before stopping profile timer (#2415)Gravatar AlexanderSinn 4-13/+32 * synchronize device before ending profile * fix shadowing issue * add comment