Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
4295b04
Add CLI utilities to run purge and gudrun
rhinoella Mar 20, 2024
f058c72
Remove comments
rhinoella Mar 20, 2024
7eb98a3
Change naming in gudpy.spec to include version
rhinoella Mar 21, 2024
6aab0ec
Fix exe naming
rhinoella Mar 21, 2024
1fb0b75
Make purge and gudrun a command
rhinoella Mar 22, 2024
3052e86
Refactor: move data loading/dataset construction out of gui
rhinoella Mar 20, 2024
951175c
Create calcError function in core.data
rhinoella Mar 21, 2024
f6709be
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
9bf3d6c
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
caf3d2a
Feat: allow limits on the dataset
rhinoella Mar 22, 2024
01ee744
Add bayesian optimisation to cli, add exponential optimisation
rhinoella Mar 26, 2024
d11bf20
Change to using numpy arrays, interpolate
rhinoella Mar 26, 2024
e725a61
Add suppress/save options to gudrun
rhinoella Mar 26, 2024
5ad84a0
Allow output to be set
rhinoella Mar 26, 2024
ffdaeec
Run in temporary directory
rhinoella Mar 26, 2024
e078d49
Feat: add simplex optimisation
rhinoella Apr 2, 2024
d0f822c
Feat: always pass purge
rhinoella Apr 2, 2024
9906d35
Fix check
rhinoella Apr 18, 2024
3300423
Change all pages to scrollarea (#498)
rhinoella Apr 19, 2024
bcb0085
Set correct rootdir (#497)
rhinoella Apr 19, 2024
83dbbe3
fix: 499 Error in Purge Freezes GUI (#501)
rhinoella May 1, 2024
cd71aac
Fix IDAaaS Version (#502)
trisyoungs May 1, 2024
101d465
Update workflows to get prebuilt Gudrun (#506)
rhinoella May 3, 2024
a010da5
Fix Output Tree (#505)
rhinoella May 8, 2024
855720e
503 Fix Sample Tree Issues (#504)
rhinoella May 10, 2024
cfc824e
feat: Update from v3 to v4 for uploading artifacts (#510)
rhinoella May 22, 2024
ae9d462
fix: Test result uploading (#511)
rhinoella May 28, 2024
b305f39
Change name to pattern (#512)
rhinoella May 28, 2024
9b591b0
feat: Import from project - Improved IO Management (#508)
rhinoella May 29, 2024
531d1f2
Remove references to gudrunOutput
rhinoella May 29, 2024
5ee07d8
Remove last traces
rhinoella May 29, 2024
8a1c3d4
Update tests
rhinoella May 30, 2024
60a9ace
Specify self in function definition
rhinoella May 30, 2024
70c0412
Return empty list
rhinoella May 30, 2024
4494c3b
Remove prev output references
rhinoella May 30, 2024
798fd81
fix: CI Publishing step (#514)
rhinoella Jun 10, 2024
cd435a9
Fix: method calling
rhinoella Jun 10, 2024
e33031c
Debugging
rhinoella Jun 10, 2024
0a1791d
Fix plot bugs
rhinoella Jun 10, 2024
b7d8955
fix deps
rhinoella Jun 11, 2024
393f4f9
Add CLI utilities to run purge and gudrun
rhinoella Mar 20, 2024
2c495cb
Remove comments
rhinoella Mar 20, 2024
8652e64
Make purge and gudrun a command
rhinoella Mar 22, 2024
86952c7
Refactor: move data loading/dataset construction out of gui
rhinoella Mar 20, 2024
2f9edc5
Create calcError function in core.data
rhinoella Mar 21, 2024
fcdb2e0
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
9e5b9ad
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
932d79a
Feat: allow limits on the dataset
rhinoella Mar 22, 2024
149725d
Add bayesian optimisation to cli, add exponential optimisation
rhinoella Mar 26, 2024
3500b5d
Change to using numpy arrays, interpolate
rhinoella Mar 26, 2024
3b1524e
Add suppress/save options to gudrun
rhinoella Mar 26, 2024
819fb61
Allow output to be set
rhinoella Mar 26, 2024
7203865
Run in temporary directory
rhinoella Mar 26, 2024
0d0f9ad
Feat: add simplex optimisation
rhinoella Apr 2, 2024
8d2faae
Feat: always pass purge
rhinoella Apr 2, 2024
4750db1
Fix check
rhinoella Apr 18, 2024
5c0f43a
Merge branch 'parameter-optimisation' of https://github.com/disordere…
rhinoella Jun 12, 2024
339bf9f
Fix merge
rhinoella Jun 12, 2024
67be8b6
Split out group boc
rhinoella Jun 12, 2024
36c385b
Apply new tab to main window
rhinoella Jun 12, 2024
639068c
Change gudfile path checking
rhinoella Jun 12, 2024
1e5a2a6
Fix nesting output directory issue
rhinoella Jun 14, 2024
e03b8d2
Fix head path joining
rhinoella Jun 14, 2024
53d1e08
Try using os path sep
rhinoella Jun 14, 2024
3df6d63
Fix test path
rhinoella Jun 14, 2024
b602dd6
Give head a default
rhinoella Jun 17, 2024
0807979
Cler outputs, select correct file
rhinoella Jun 17, 2024
2191772
Merge branch 'inelasticity-iterator-2' into parameter-optimisation
rhinoella Jun 17, 2024
4953fcd
Add gudpy inelasticity optimiser
rhinoella Jun 17, 2024
0700c94
Add scikit-optimize to requirements
rhinoella Jun 17, 2024
d91e60a
Fix plot, save and yaml parsing
rhinoella Jun 20, 2024
22a3f5e
Fix segfault
rhinoella Jun 24, 2024
93e5e3d
Correctly update samples in ref list
rhinoella Jun 26, 2024
a244a91
Create inelasticity worker
rhinoella Jun 27, 2024
94da235
Better exitcode handling
rhinoella Jun 27, 2024
c3748d9
Utility func
rhinoella Jun 27, 2024
bc2ce53
Error handling
rhinoella Jun 27, 2024
eff4811
Create inelasticity optimisation ui elements
rhinoella Jun 27, 2024
59c93f6
feat: Include Gudrun dependencies in the run (#513)
rhinoella Jun 28, 2024
fc1467a
Add CLI utilities to run purge and gudrun
rhinoella Mar 20, 2024
50ae7da
Remove comments
rhinoella Mar 20, 2024
ad2ae63
Make purge and gudrun a command
rhinoella Mar 22, 2024
a578935
Refactor: move data loading/dataset construction out of gui
rhinoella Mar 20, 2024
332a80c
Create calcError function in core.data
rhinoella Mar 21, 2024
cb826f7
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
e8e4bfe
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
8f5d85c
Feat: allow limits on the dataset
rhinoella Mar 22, 2024
af5a0a3
Add bayesian optimisation to cli, add exponential optimisation
rhinoella Mar 26, 2024
4d664d6
Change to using numpy arrays, interpolate
rhinoella Mar 26, 2024
bd3576b
Add suppress/save options to gudrun
rhinoella Mar 26, 2024
c5f10d9
Allow output to be set
rhinoella Mar 26, 2024
14cf3d0
Run in temporary directory
rhinoella Mar 26, 2024
0233c56
Feat: add simplex optimisation
rhinoella Apr 2, 2024
b3ef0dc
Feat: always pass purge
rhinoella Apr 2, 2024
d13118e
Fix check
rhinoella Apr 18, 2024
9bf912a
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
de2cdc8
Implement Bayesian Optimisation
rhinoella Mar 22, 2024
c4b4e05
Add bayesian optimisation to cli, add exponential optimisation
rhinoella Mar 26, 2024
1095658
Change to using numpy arrays, interpolate
rhinoella Mar 26, 2024
e4a3735
Add suppress/save options to gudrun
rhinoella Mar 26, 2024
4065c4c
Run in temporary directory
rhinoella Mar 26, 2024
ff65796
Feat: add simplex optimisation
rhinoella Apr 2, 2024
c4235ef
Fix merge
rhinoella Jun 12, 2024
33a04ac
Split out group boc
rhinoella Jun 12, 2024
d215db6
Apply new tab to main window
rhinoella Jun 12, 2024
70b1960
Remove references to gudrunOutput
rhinoella May 29, 2024
a53dc1e
Debugging
rhinoella Jun 10, 2024
dc2da36
Fix plot bugs
rhinoella Jun 10, 2024
11a1902
fix deps
rhinoella Jun 11, 2024
7407058
Fix nesting output directory issue
rhinoella Jun 14, 2024
9bc4701
Fix head path joining
rhinoella Jun 14, 2024
47c44e3
Try using os path sep
rhinoella Jun 14, 2024
bf15191
Fix test path
rhinoella Jun 14, 2024
27edec9
Give head a default
rhinoella Jun 17, 2024
99128b5
Cler outputs, select correct file
rhinoella Jun 17, 2024
d2b0c3e
Add gudpy inelasticity optimiser
rhinoella Jun 17, 2024
feaeae1
Add scikit-optimize to requirements
rhinoella Jun 17, 2024
1c117d3
Fix plot, save and yaml parsing
rhinoella Jun 20, 2024
6b5e524
Fix segfault
rhinoella Jun 24, 2024
6795f81
Correctly update samples in ref list
rhinoella Jun 26, 2024
cb44457
Create inelasticity worker
rhinoella Jun 27, 2024
7ce9753
Better exitcode handling
rhinoella Jun 27, 2024
c21bc0b
Utility func
rhinoella Jun 27, 2024
28f2b37
Error handling
rhinoella Jun 27, 2024
a4d399e
Create inelasticity optimisation ui elements
rhinoella Jun 27, 2024
6dd9fe7
Merge branch 'parameter-optimisation' of https://github.com/disordere…
rhinoella Jun 28, 2024
4839629
Finalise optimisation
rhinoella Jun 28, 2024
32a9f2a
Disable run containers as samples
rhinoella Jun 28, 2024
a0ef664
Fix test file
rhinoella Jun 28, 2024
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
38 changes: 6 additions & 32 deletions .github/workflows/get-externals/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,43 +12,21 @@ runs:
if: runner.os == 'Linux'
run: |
curl -L https://github.com/disorderedmaterials/Gudrun/releases/download/${{ env.gudrunTag }}/binaries-${{ env.gudrunTag }}-linux.zip > gudrun-binaries.zip
curl -L https://github.com/disorderedmaterials/ModEx/releases/download/${{ env.modexTag }}/binaries-${{ env.modexTag }}-linux.zip > modex-binaries.zip
- name: Build Externals (OSX)
shell: bash
if: runner.os == 'MacOS'
run: |
# Install Ninja
brew update-reset
brew install ninja
# Retrieve Gudrun source
curl -L https://github.com/disorderedmaterials/Gudrun/archive/refs/tags/${{ env.gudrunTag }}.tar.gz > gudrun-source.tar.gz
tar -zxvf gudrun-source.tar.gz
cd Gudrun-${{ env.gudrunTag }}
# Retrieve pre-built HDF5 libs
curl -L https://github.com/disorderedmaterials/HDF5/releases/download/${{ env.hdf5tag }}/${{ env.hdf5tag }}-osx.zip > hdf5-osx.zip
unzip hdf5-osx.zip
# Build Gudrun binaries
mkdir build
cd build
cmake ../ -G Ninja -DCMAKE_Fortran_COMPILER:string="gfortran-11" -DLOCAL_STATIC_HDF5:bool=True -DHDF5_DIR:path=$(pwd)/../${{ env.hdf5tag }} -DCMAKE_Fortran_FLAGS:string="-cpp" -DGUDPY_COMPATIBILITY=1
ninja
ninja install
cd ../
# Create binaries zip
mkdir binaries-${{ env.gudrunTag }}-linux
mv bin/* binaries-${{ env.gudrunTag }}-linux
zip -9rv ../gudrun-binaries.zip binaries-${{ env.gudrunTag }}-linux/
unzip gudrun-binaries
- name: Retrieve Externals (OSX)
shell: bash
if: runner.os == 'MacOS'
run: |
curl -L https://github.com/disorderedmaterials/ModEx/releases/download/${{ env.modexTag }}/binaries-${{ env.modexTag }}-osx.zip > modex-binaries.zip
brew install zlib hdf5 gcc@11
curl -L https://github.com/disorderedmaterials/Gudrun/releases/download/${{ env.gudrunTag }}/binaries-${{ env.gudrunTag }}-osx-fat.zip > gudrun-binaries.zip
unzip gudrun-binaries
chmod +x binaries-${{ env.gudrunTag }}-osx-fat/*
- name: Retrieve Externals (Windows)
shell: bash
if: runner.os == 'Windows'
run: |
curl -L https://github.com/disorderedmaterials/Gudrun/releases/download/${{ env.gudrunTag }}/binaries-${{ env.gudrunTag }}-windows.zip > gudrun-binaries.zip
curl -L https://github.com/disorderedmaterials/ModEx/releases/download/${{ env.modexTag }}/binaries-${{ env.modexTag }}-windows.zip > modex-binaries.zip
unzip gudrun-binaries
- name: Retrieve StartupFiles
shell: bash
run: |
Expand All @@ -57,11 +35,7 @@ runs:
shell: bash
run: |
if [ ! -e ${{ inputs.targetDir }} ]; then mkdir ${{ inputs.targetDir }}; fi
unzip gudrun-binaries.zip
mv binaries-${{ env.gudrunTag }}-*/* ${{ inputs.targetDir }}

unzip modex-binaries.zip
mv binaries-${{ env.modexTag }}-*/* ${{ inputs.targetDir }}

unzip startupFiles.zip
mv StartupFiles ${{ inputs.targetDir }}
13 changes: 7 additions & 6 deletions .github/workflows/package/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ runs:

- name: Upload Artifacts (OSX)
if: runner.os == 'MacOS'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Packages
name: GudPy-OSX
path: |
dist/GudPy-*.dmg
dist/GudPy-*-OSX


- name: Create Zip (Windows)
if: runner.os == 'Windows'
shell: bash
Expand All @@ -30,9 +31,9 @@ runs:

- name: Upload Artifacts (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Packages
name: GudPy-Windows
path: |
dist/GudPy-*-Windows.zip

Expand All @@ -50,9 +51,9 @@ runs:

- name: Upload Artifacts (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: Packages
name: GudPy-Linux
path: |
dist/GudPy-*.sif
dist/GudPy-*-Linux
1 change: 0 additions & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ jobs:
uses: "./.github/workflows/lint"

Test:
needs: Lint
strategy:
fail-fast: false
matrix:
Expand Down
16 changes: 10 additions & 6 deletions .github/workflows/publish/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@ runs:
singularity-version: 3.8.3

- name: Download Artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: Packages
pattern: GudPy-*
path: ${{ github.workspace }}/packages

- name: Download Prerequisites
Expand All @@ -36,7 +36,9 @@ runs:
echo "Release tag will be: ${{ env.gudPyVersion }}"
echo "Release name will be: ${{ env.gudPyVersion }}"
export GITHUB_TOKEN=${{ github.token }}
./update-release -r disorderedmaterials/gudpy -t ${{ env.gudPyVersion }} -e -n "${{ env.gudPyVersion }}" -f ReleaseNotes.md packages/*
FILES=( $(find ./packages -mindepth 2 -maxdepth 2 -type f -name "GudPy-${{ env.gudPyVersion }}*") )
echo ${FILES[@]}
./update-release -r disorderedmaterials/gudpy -t ${{ env.gudPyVersion }} -e -n "${{ env.gudPyVersion }}" -f ReleaseNotes.md ${FILES[@]}

- name: Publish on GitHub (Continuous)
if: ${{ inputs.publish == 'true' && inputs.isRelease == 'false' }}
Expand All @@ -45,20 +47,22 @@ runs:
echo "Release tag will be: continuous"
echo "Release name will be: 'Continuous (${{ env.gudPyVersion }})'"
export GITHUB_TOKEN=${{ github.token }}
./update-release -r disorderedmaterials/gudpy -t continuous -p -e -u -n "Continuous (${{ env.gudPyVersion }})" -b "Continuous release from \`main\` branch. Built $(date)." packages/*
FILES=( $(find ./packages -mindepth 2 -maxdepth 2 -type f -name "GudPy-${{ env.gudPyVersion }}*") )
echo ${FILES[@]}
./update-release -r disorderedmaterials/gudpy -t continuous -p -e -u -n "Continuous (${{ env.gudPyVersion }})" -b "Continuous release from \`main\` branch. Built $(date)." ${FILES[@]}

- name: Publish on Harbor (Release)
if: ${{ inputs.publish == 'true' && inputs.isRelease == 'true' }}
shell: bash
run: |
echo "Release tag will be: latest"
singularity remote login --username ${HARBOR_USER} --password ${HARBOR_SECRET} docker://harbor.stfc.ac.uk
${SINGULARITY_ROOT}/bin/singularity push packages/GudPy-${{ env.gudPyVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/gudpy:latest
${SINGULARITY_ROOT}/bin/singularity push packages/GudPy-Linux/GudPy-${{ env.gudPyVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/gudpy:latest

- name: Publish on Harbor (Continuous)
if: ${{ inputs.publish == 'true' && inputs.isRelease == 'false' }}
shell: bash
run: |
echo "Release tag will be: continuous"
singularity remote login --username ${HARBOR_USER} --password ${HARBOR_SECRET} docker://harbor.stfc.ac.uk
${SINGULARITY_ROOT}/bin/singularity push packages/GudPy-${{ env.gudPyVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/gudpy:continuous
${SINGULARITY_ROOT}/bin/singularity push packages/GudPy-Linux/GudPy-${{ env.gudPyVersion }}.sif oras://harbor.stfc.ac.uk/isis_disordered_materials/gudpy:continuous
2 changes: 1 addition & 1 deletion .github/workflows/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inputs:
default: 3.9
gudrunTag:
type: string
default: 2023.1
default: 2024.1
modexTag:
type: string
default: 0.1.5
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@ runs:

- name: Upload Test Results
if: always()
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: testResults
name: testResults-${{ runner.os }}
path: results

- name: Publish Code Coverage
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/testresults/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ runs:
steps:

- name: Download Test Results
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: testResults
pattern: testResults-*
merge-multiple: true
path: results

- name: Publish Test Results
Expand Down
6 changes: 3 additions & 3 deletions ci/singularity/ubuntu22.04.def
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ From: ubuntu:22.04
%post
export DEBIAN_FRONTEND=noninteractive
apt-get update
apt-get install python3.10 python3-distutils curl build-essential libx11-xcb-dev libglu1-mesa-dev libxkbcommon0 libglx0 libfontconfig libglib2.0-0 libdbus-1-3 libxcb-xinerama0 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-randr0 libxcb-shape0 libgfortran5 libegl-dev libegl-mesa0 -y && rm -rf /var/lib/apt/lists/*
apt-get install python3.10 python3-distutils curl build-essential libx11-xcb-dev libglu1-mesa-dev libxkbcommon0 libglx0 libfontconfig libglib2.0-0 libdbus-1-3 libxcb-xinerama0 libxkbcommon-x11-0 libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-render-util0 libxcb-randr0 libxcb-shape0 libxcb-cursor0 libgfortran5 libegl-dev libegl-mesa0 -y && rm -rf /var/lib/apt/lists/*
curl https://bootstrap.pypa.io/get-pip.py | python3
python3 -m pip install -r requirements.txt
rm requirements.txt
Expand Down Expand Up @@ -39,10 +39,10 @@ From: ubuntu:22.04

%runscript
# If the container is executed, this line will be run.
python3.10 /opt/GudPy/gudpy
python3.10 /opt/GudPy/gudpy/gudpy_gui.py

%apphelp GudPy
GudPy GUI version.

%apprun GudPy
python3 /opt/GudPy/gudpy
python3.10 /opt/GudPy/gudpy/gudpy_gui.py
2 changes: 1 addition & 1 deletion gudpy/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
USE_USER_DEFINED_COMPONENTS = False
NORMALISE_COMPOSITIONS = False

__rootdir__ = os.path.dirname(os.path.abspath(sys.argv[0]))
__rootdir__ = os.path.dirname(os.path.dirname(os.path.abspath(sys.argv[0])))

__root__ = (
os.path.join(sys._MEIPASS, "bin", "configs", "containers")
Expand Down
7 changes: 6 additions & 1 deletion gudpy/core/container.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(self, config=None):
"""
self.name = ""
self.periodNumber = 1
self.dataFiles = DataFiles([], "CONTAINER")
self.dataFiles = DataFiles([], "CONTAINER", True)
self.composition = Composition("CONTAINER")
self.geometry = Geometry.SameAsBeam
self.upstreamThickness = 0.1
Expand All @@ -97,6 +97,7 @@ def __init__(self, config=None):
self.grBroadening = 0.
self.powerForBroadening = 0.0
self.stepSize = 0.0
self.outputFolder = ""

self.yamlignore = {
"runAsSample",
Expand All @@ -113,6 +114,10 @@ def __init__(self, config=None):
if config:
self.parseFromConfig(config)

@property
def gudFile(self):
return None

def __str__(self):
"""
Returns the string representation of the Container object.
Expand Down
82 changes: 82 additions & 0 deletions gudpy/core/data.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import numpy


class Point():
def __init__(self, x, y, err=0.0):
self.x = x
self.y = y
self.err = err


class DataSet():
# mint01 / mdcs01 / mdor01 / mgor01 / dcs
def __init__(self, path, exists, lim=None):
if not exists:
self.dataSet = None
else:
self.dataSet = self.constructDataSet(path, lim)

def constructDataSet(self, path, lim=None):
dataSet = []
with open(path, "r", encoding="utf-8") as fp:
for dataLine in fp.readlines():

# Ignore commented lines.
if dataLine[0] == "#":
continue

splitLine = [float(n) for n in dataLine.split()]
if len(splitLine) > 2:
x, y, err, *__ = splitLine
if lim and x > lim:
return dataSet
dataSet.append(Point(x, y, err))
else:
x, y = splitLine
if lim and x > lim:
return dataSet
dataSet.append(Point(x, y))

return dataSet


class NpDataSet():
# mint01 / mdcs01 / mdor01 / mgor01 / dcs
def __init__(self, path, lim=None):
self.LIMIT = lim
self.x = []
self.y = []

with open(path, "r", encoding="utf-8") as fp:
for dataLine in fp.readlines():

# Ignore commented lines.
if dataLine[0] == "#":
continue

splitLine = [float(n) for n in dataLine.split()]
x, y, *__ = splitLine
if lim and x > lim:
break
self.x.append(x)
self.y.append(y)

if not self.LIMIT:
self.LIMIT = self.x[-1]

self.x = numpy.array(self.x)
self.y = numpy.array(self.y)

self.interpolate()

def interpolate(self):
xnew = numpy.round(numpy.arange(0, self.LIMIT, 0.015), 4)
ynew = numpy.interp(xnew, self.x, self.y)
self.x = xnew
self.y = ynew


def meanSquaredError(d1: NpDataSet, d2: NpDataSet) -> float:
return sum((y1 - y2)**2
for y1, y2 in zip(d1.y, d2.y)
) / len(d1.y)
Loading