Skip to content

Commit

Permalink
Merge pull request #88 from kif/test_DNN
Browse files Browse the repository at this point in the history
template for a test
  • Loading branch information
kif authored Jul 3, 2024
2 parents ab41d04 + b3c8bb2 commit f0d27ca
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/freesas/test/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ py.install_sources([
'test_average.py',
'test_bift.py',
'test_cormap.py',
'test_dnn.py',
'test_distance.py',
'test_fitting.py',
'test_model.py',
Expand Down
4 changes: 3 additions & 1 deletion src/freesas/test/test_all.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
__author__ = "Guillaume"
__license__ = "MIT"
__copyright__ = "2015, ESRF"
__date__ = "25/04/2020"
__date__ = "03/07/2024"

import unittest
from . import test_model
Expand All @@ -18,6 +18,7 @@
from . import test_sas_argparser
from . import test_fitting
from . import test_resources
from . import test_dnn


def suite():
Expand All @@ -32,6 +33,7 @@ def suite():
testSuite.addTest(test_sas_argparser.suite())
testSuite.addTest(test_fitting.suite())
testSuite.addTest(test_resources.suite())
testSuite.addTest(test_dnn.suite())
return testSuite


Expand Down
61 changes: 61 additions & 0 deletions src/freesas/test/test_dnn.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# -*- coding: utf-8 -*-
#
# Project: freesas
# https://github.com/kif/freesas
#
# Copyright (C) 2024-2024 European Synchrotron Radiation Facility, Grenoble, France
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

__authors__ = ["Jérôme Kieffer"]
__license__ = "MIT"
__date__ = "03/07/2024"

import unittest
import logging
import os
from .utilstest import get_datafile
from ..resources import resource_filename
from ..sasio import load_scattering_data
# from ..dnn import preprocess
logger = logging.getLogger(__name__)

class TestDNN(unittest.TestCase):

def test_preprocess(self):
"""
Test for the preprocessing function
"""
datfile = get_datafile("bsa_005_sub.dat")
data = load_scattering_data(datfile)
q, I, sigma = data.T
# Iprep = preprocess(q, I)
# self.assertEqual(Iprep.max(), 1, msg="range 0-1")
# self.assertEqual(Iprep.shape, 1024, msg="size 1024")


def suite():
test_suite = unittest.TestSuite()
test_suite.addTest(TestDNN("test_preprocess"))
return test_suite


if __name__ == '__main__':
runner = unittest.TextTestRunner()
runner.run(suite())

0 comments on commit f0d27ca

Please sign in to comment.