Skip to content

Commit

Permalink
#6022 - added test_srw_resize_3d
Browse files Browse the repository at this point in the history
  • Loading branch information
mkeilman committed Aug 10, 2023
1 parent 7501dd2 commit 0039fa2
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions tests/template/srw_resize_3d_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,26 +4,28 @@
:copyright: Copyright (c) 2023 RadiaSoft LLC. All Rights Reserved.
:license: http://www.apache.org/licenses/LICENSE-2.0.html
"""
import pytest
from pykern.pkcollections import PKDict
from pykern.pkunit import pkeq, pkok

_N_BINS = 100

def test_srw_resize_3d(fc):
from sirepo.template import srw
from pykern.pkdebug import pkdlog
import numpy
def setup_module(module):
import os

env = PKDict(os.environ)
cfg = PKDict(
SIREPO_JOB_MAX_MESSAGE_BYTES="1e4",
# Set max to something reasonable for testing
os.environ.update(
SIREPO_JOB_MAX_MESSAGE_BYTES=str(_N_BINS * _N_BINS),
)
env.pkupdate(**cfg)
pkdlog("MaX B {}", srw._MAX_MESSAGE_BYTES)
assert 0

#a = numpy.random.rand(srw._MAX_MESSAGE_BYTES)
#r = PKDict()
#srw._reshape_3d(a, [], r)

def test_srw_resize_3d(fc):
from sirepo.template import srw
import numpy

a, xr, yr = srw._reshape_3d(
numpy.random.rand(srw._MAX_MESSAGE_BYTES),
[0, 0, 0, 0.0, 1.0, _N_BINS, 0.0, 1.0, _N_BINS],
PKDict()
)
pkok(xr[2] < _N_BINS and yr[2] < _N_BINS, "did not reduce bins nx={} ny={}", xr[2], yr[2])

0 comments on commit 0039fa2

Please sign in to comment.