Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
python-spectrometer
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
QuTech
python-spectrometer
Commits
f90e2450
Commit
f90e2450
authored
10 months ago
by
Tobias Hangleiter
Browse files
Options
Downloads
Plain Diff
Merge branch 'hotfix/ci' into maint/numpy-2.0
parents
18e02c66
8eab350d
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!43
Fix numpy 2.0 reprs
Pipeline
#1455027
waiting for manual action
Stage: build
Stage: test
Stage: deploy
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/python_spectrometer/core.py
+0
-2
0 additions, 2 deletions
src/python_spectrometer/core.py
tests/test_serialization.py
+21
-6
21 additions, 6 deletions
tests/test_serialization.py
with
21 additions
and
8 deletions
src/python_spectrometer/core.py
+
0
−
2
View file @
f90e2450
...
...
@@ -13,7 +13,6 @@ from typing import (Any, Callable, Dict, Generator, Iterator, List,
from
unittest
import
mock
import
dill
import
matplotlib.pyplot
as
plt
import
numpy
as
np
from
matplotlib
import
colors
from
qutil
import
io
...
...
@@ -981,7 +980,6 @@ class Spectrometer:
--------
:meth:`recall_from_disk`
"""
# shelve writes three files, .dat, .bak, and .dir. Only need to check for one
if
file
is
None
:
file
=
self
.
_objfile
file
=
io
.
check_path_length
(
...
...
This diff is collapsed.
Click to expand it.
tests/test_serialization.py
+
21
−
6
View file @
f90e2450
import
os
import
pathlib
import
random
import
string
import
pytest
...
...
@@ -11,8 +13,9 @@ def spectrometer(monkeypatch, request) -> Spectrometer:
# patch input to answer overwrite queries with "yes"
monkeypatch
.
setattr
(
'
builtins.input
'
,
lambda
:
'
y
'
)
speck
=
Spectrometer
(
daq
.
QoptColoredNoise
(),
savepath
=
os
.
curdir
,
speck
=
Spectrometer
(
daq
.
QoptColoredNoise
(),
savepath
=
pathlib
.
Path
(
os
.
getcwd
(),
'
data
'
)
,
plot_cumulative
=
True
,
relative_paths
=
request
.
param
)
speck
.
savepath
.
mkdir
(
parents
=
True
,
exist_ok
=
True
)
cwd
=
os
.
getcwd
()
os
.
chdir
(
speck
.
savepath
)
...
...
@@ -28,12 +31,18 @@ def spectrometer(monkeypatch, request) -> Spectrometer:
@pytest.fixture
def
serialized
(
spectrometer
:
Spectrometer
)
->
pathlib
.
Path
:
spectrometer
.
serialize_to_disk
(
'
blub
'
)
stem
=
''
.
join
(
random
.
choices
(
string
.
ascii_letters
,
k
=
10
))
spectrometer
.
serialize_to_disk
(
stem
)
yield
spectrometer
.
savepath
/
'
blub
'
yield
spectrometer
.
savepath
/
stem
for
ext
in
[
'
.bak
'
,
'
.dat
'
,
'
.dir
'
,
'
_files.txt
'
]:
os
.
remove
(
spectrometer
.
savepath
/
f
'
blub
{
ext
}
'
)
exts
=
[
'
_files.txt
'
]
if
(
spectrometer
.
savepath
/
stem
).
is_file
():
os
.
remove
(
spectrometer
.
savepath
/
stem
)
else
:
exts
.
extend
([
'
.bak
'
,
'
.dat
'
,
'
.dir
'
])
for
ext
in
exts
:
os
.
remove
(
spectrometer
.
savepath
/
f
'
{
stem
}{
ext
}
'
)
def
test_saving
(
spectrometer
:
Spectrometer
):
...
...
@@ -44,7 +53,13 @@ def test_saving(spectrometer: Spectrometer):
def
test_serialization
(
spectrometer
:
Spectrometer
):
spectrometer
.
serialize_to_disk
(
'
blub
'
)
for
ext
in
[
'
.bak
'
,
'
.dat
'
,
'
.dir
'
,
'
_files.txt
'
]:
exts
=
[
'
_files.txt
'
]
if
(
spectrometer
.
savepath
/
'
blub
'
).
is_file
():
assert
os
.
path
.
exists
(
spectrometer
.
savepath
/
'
blub
'
)
else
:
exts
.
extend
([
'
.bak
'
,
'
.dat
'
,
'
.dir
'
])
for
ext
in
exts
:
assert
os
.
path
.
exists
(
spectrometer
.
savepath
/
f
'
blub
{
ext
}
'
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment