Repository: pyfar/pyfar (python)

Issue:
io.write(..., compress=True) increases file size
## General

* pyfar version: 0.6.9
* Python version: 3.11.9
* Operating System: Ubuntu 23.10
* Did you install pyfar via pip: yes

## Description
Hi guys, 

I noticed that instead of compressing the data, `pf.io.write()` produces much bigger files when using `compress=True`. 

I tested this with a sine signal. The behavior is consistent for long and short signals and single-channel as well as multi-channel audio. 

When using noise, the difference decreases but the compressed file is still larger than the uncompressed one.

## What I Did

```
import pyfar as pf

signal = pf.signals.sine(frequency=1000, n_samples=44100, amplitude=1, sampling_rate=44100)

pf.io.write('signal_uncompressed', signal=signal)
pf.io.write('signal_compressed', signal=signal, compress=True)
```
`signal_uncompressed.far` is 383.4 kB, while `signal_compressed.far` is 706.7 kB.

Pull request description:
hot: fix compress flag in pyfar.io.write
### Which issue(s) are closed by this pull request?

Closes #706

### Changes proposed in this pull request:

- fix usage of compress parameter in ``pyfar.io.write``
- add test whether the compressed file is smaller then the uncompressed one.


Patch:
diff --git a/pyfar/io/io.py b/pyfar/io/io.py
index e8fcb944..a52faf1c 100644
--- a/pyfar/io/io.py
+++ b/pyfar/io/io.py
@@ -316,7 +316,7 @@ def write(filename, compress=False, **objs):
     """
     # Check for .far file extension
     filename = pathlib.Path(filename).with_suffix('.far')
-    compression = zipfile.ZIP_STORED if compress else zipfile.ZIP_DEFLATED
+    compression = zipfile.ZIP_DEFLATED if compress else zipfile.ZIP_STORED
     zip_buffer = io.BytesIO()
     builtin_wrapper = codec.BuiltinsWrapper()
     with zipfile.ZipFile(zip_buffer, "a", compression) as zip_file:


Test patch:
diff --git a/tests/test_io.py b/tests/test_io.py
index f57a871f..7eff393e 100644
--- a/tests/test_io.py
+++ b/tests/test_io.py
@@ -451,6 +451,16 @@ def test_write_read_multiplePyfarObjects(
     assert dict_of_builtins.items() <= actual.items()
 
 
+def test_write_read_compression(sine, tmpdir):
+    """Test whether compressed files are larger than uncompressed files."""
+    filename_compressed = os.path.join(tmpdir, 'sine_compressed.far')
+    io.write(filename_compressed, signal=sine, compress=True)
+    filename_uncompressed = os.path.join(tmpdir, 'sine_uncompressed.far')
+    io.write(filename_uncompressed, signal=sine, compress=False)
+    assert os.path.getsize(filename_uncompressed) > os.path.getsize(
+        filename_compressed)
+
+
 def test_write_read_multiplePyfarObjectsWithCompression(
         filter,
         filterFIR,