Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Movie storage #545

Merged
merged 12 commits into from
Mar 19, 2024
8 changes: 8 additions & 0 deletions .github/workflows/tests_all.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,19 @@ jobs:

steps:
- uses: actions/checkout@v3

- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.12'

- uses: FedericoCarboni/setup-ffmpeg@v3
# install ffmpeg as special requirement
id: setup-ffmpeg
with:
ffmpeg-version: release
github-token: ${{ github.server_url == 'https://github.com' && github.token || '' }}

- name: Install dependencies
# install all requirements
run: |
Expand Down
1 change: 1 addition & 0 deletions docs/source/_static/requirements_optional.csv
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
Package,Minimal version,Usage
ffmpeg-python,0.2,Reading and writing videos
h5py,2.10,Storing data in the hierarchical file format
ipywidgets,8,Jupyter notebook support
mpi4py,3,Parallel processing using MPI
Expand Down
2 changes: 2 additions & 0 deletions pde/storage/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@
~memory.get_memory_storage
~memory.MemoryStorage
~file.FileStorage
~movie.MovieStorage

.. codeauthor:: David Zwicker <david.zwicker@ds.mpg.de>
"""

from .file import FileStorage
from .memory import MemoryStorage, get_memory_storage
from .movie import MovieStorage
6 changes: 3 additions & 3 deletions pde/storage/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,9 +599,9 @@ def initialize(self, field: FieldBase, info: InfoDict | None = None) -> float:
Returns:
float: The first time the tracker needs to handle data
"""
result = super().initialize(field, info)
self.storage.start_writing(self._transform(field, 0), info)
return result
t_first = super().initialize(field, info)
self.storage.start_writing(self._transform(field, t_first), info)
return t_first

def handle(self, field: FieldBase, t: float) -> None:
"""handle data supplied to this tracker
Expand Down
4 changes: 1 addition & 3 deletions pde/storage/file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
from __future__ import annotations

import json
import logging
from pathlib import Path
from typing import Any, Literal

Expand All @@ -25,7 +24,7 @@ class FileStorage(StorageBase):

def __init__(
self,
filename: str,
filename: str | Path,
*,
info: InfoDict | None = None,
write_mode: WriteModeType = "truncate_once",
Expand Down Expand Up @@ -69,7 +68,6 @@ def __init__(
self.keep_opened = keep_opened
self.check_mpi = check_mpi

self._logger = logging.getLogger(self.__class__.__name__)
self._file: Any = None
self._is_writing = False
self._data_length: int = None # type: ignore
Expand Down
Loading
Loading