ramp-coreoperator 0.0.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. ramp_coreoperator-0.0.2/.github/ISSUE_TEMPLATE/bug_report.md +30 -0
  2. ramp_coreoperator-0.0.2/.github/ISSUE_TEMPLATE/documentation-improvement.md +20 -0
  3. ramp_coreoperator-0.0.2/.github/ISSUE_TEMPLATE/feature_request.md +21 -0
  4. ramp_coreoperator-0.0.2/.github/pull_request_template.md +26 -0
  5. ramp_coreoperator-0.0.2/.github/workflows/test.yml +47 -0
  6. ramp_coreoperator-0.0.2/.gitignore +8 -0
  7. ramp_coreoperator-0.0.2/CODE_OF_CONDUCT.md +109 -0
  8. ramp_coreoperator-0.0.2/CONTRIBUTING.md +47 -0
  9. ramp_coreoperator-0.0.2/LICENSE +21 -0
  10. ramp_coreoperator-0.0.2/PKG-INFO +53 -0
  11. ramp_coreoperator-0.0.2/README.md +1 -0
  12. ramp_coreoperator-0.0.2/coreoperator/__init__.py +14 -0
  13. ramp_coreoperator-0.0.2/coreoperator/example.py +11 -0
  14. ramp_coreoperator-0.0.2/coreoperator/featherstate.py +89 -0
  15. ramp_coreoperator-0.0.2/coreoperator/history.py +228 -0
  16. ramp_coreoperator-0.0.2/coreoperator/mobilization/__init__.py +8 -0
  17. ramp_coreoperator-0.0.2/coreoperator/mobilization/apply.py +47 -0
  18. ramp_coreoperator-0.0.2/coreoperator/mobilization/cyclic_shuffle.py +47 -0
  19. ramp_coreoperator-0.0.2/coreoperator/mobilization/grid_action.py +201 -0
  20. ramp_coreoperator-0.0.2/coreoperator/mobilization/load.py +120 -0
  21. ramp_coreoperator-0.0.2/coreoperator/mobilization/remove.py +39 -0
  22. ramp_coreoperator-0.0.2/coreoperator/mobilization/scheme.py +48 -0
  23. ramp_coreoperator-0.0.2/coreoperator/mobilization/transform_inplace.py +48 -0
  24. ramp_coreoperator-0.0.2/coreoperator/operational_state.py +416 -0
  25. ramp_coreoperator-0.0.2/docs/Makefile +27 -0
  26. ramp_coreoperator-0.0.2/docs/requirements.yml +9 -0
  27. ramp_coreoperator-0.0.2/docs/source/conf.py +91 -0
  28. ramp_coreoperator-0.0.2/docs/source/index.rst +22 -0
  29. ramp_coreoperator-0.0.2/docs/source/operationalstate.rst +16 -0
  30. ramp_coreoperator-0.0.2/docs/source/tests.rst +18 -0
  31. ramp_coreoperator-0.0.2/pyproject.toml +47 -0
  32. ramp_coreoperator-0.0.2/ramp_coreoperator.egg-info/PKG-INFO +53 -0
  33. ramp_coreoperator-0.0.2/ramp_coreoperator.egg-info/SOURCES.txt +44 -0
  34. ramp_coreoperator-0.0.2/ramp_coreoperator.egg-info/dependency_links.txt +1 -0
  35. ramp_coreoperator-0.0.2/ramp_coreoperator.egg-info/requires.txt +10 -0
  36. ramp_coreoperator-0.0.2/ramp_coreoperator.egg-info/top_level.txt +1 -0
  37. ramp_coreoperator-0.0.2/requirements.yml +6 -0
  38. ramp_coreoperator-0.0.2/ruff.toml +6 -0
  39. ramp_coreoperator-0.0.2/setup.cfg +4 -0
  40. ramp_coreoperator-0.0.2/tests/test_action.py +138 -0
  41. ramp_coreoperator-0.0.2/tests/test_featherstate.py +31 -0
  42. ramp_coreoperator-0.0.2/tests/test_heights.py +115 -0
  43. ramp_coreoperator-0.0.2/tests/test_history.py +34 -0
  44. ramp_coreoperator-0.0.2/tests/test_operational_state_methods.py +42 -0
  45. ramp_coreoperator-0.0.2/tests/test_serialization.py +127 -0
  46. ramp_coreoperator-0.0.2/tests_requirements.yml +4 -0
@@ -0,0 +1,30 @@
1
+ ---
2
+ name: Bug report
3
+ about: Create a report to help us improve
4
+ title: "[Bug]"
5
+ labels: bug
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Describe the bug**
11
+ A clear and concise description of what the bug is.
12
+
13
+ **To Reproduce**
14
+ Steps to reproduce the behavior:
15
+ 1. Go to '...'
16
+ 2. Run '...'
17
+ 3. See error
18
+
19
+ **Expected behavior**
20
+ A clear and concise description of what you expected to happen.
21
+
22
+ **Screenshots**
23
+ If applicable, add screenshots to help explain your problem.
24
+
25
+ **System configuration (please complete the following information):**
26
+ - OS: [e.g. Ubuntu]
27
+ - Package Version [e.g. 0.0.0]
28
+
29
+ **Additional context**
30
+ Add any other context about the problem here.
@@ -0,0 +1,20 @@
1
+ ---
2
+ name: Documentation Improvement
3
+ about: Proposed changes to the documentation
4
+ title: "[Doc]"
5
+ labels: documentation
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ # Is anything incorrect?
11
+ Usually, when a change is proposed to the documentation it is because we forgot to update it, and documentation rot took hold.
12
+ Please let us know what you found to be incorrect, if applicable.
13
+
14
+ # Is anything missing?
15
+ Sometimes, you want an explanation for a particular piece of code, or an example for how to use something, that is simply not there.
16
+ Please let us know what you'd like to see, and we can try to write it!
17
+
18
+ # Can something be improved?
19
+ It isn't very often that someone takes the time to help us improve our documentation when something is there and presented correctly, but could be better.
20
+ Thank you for taking the time to let us know! Please give us a suggestion for what we could improve next, or even better, open a pull request with your changes! We'd love for you to help out with either of these methods.
@@ -0,0 +1,21 @@
1
+ ---
2
+ name: Feature request
3
+ about: Suggest an idea for this project
4
+ title: "[Feature]"
5
+ labels: enhancement
6
+ assignees: ''
7
+
8
+ ---
9
+
10
+ **Is your feature request related to a problem? Please describe.**
11
+ A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
12
+
13
+ **Describe the solution you'd like**
14
+ A clear and concise description of what you want things to look like.
15
+
16
+ **Describe proposed solutions you've considered**
17
+ A clear and concise description of proposed solutions you considered.
18
+ If you can argue for and against them so we can pick the best one, please do.
19
+
20
+ **Additional context**
21
+ Add any other context or screenshots about the feature request here.
@@ -0,0 +1,26 @@
1
+ # Description
2
+ Describe the purpose of this pull request.
3
+ What is the problem that we're trying to fix, and what is the solution about.
4
+
5
+ For example:
6
+ > There is a bug where deserializing an Isotope creates a new entity separate from the original serialized object. This pull request fixes that, so the singleton behavior is maintained in this case.
7
+
8
+ If this discussion already appears on an issue that this pull request is meant to solve, that's even better! In that case, a short sentence such as the following suffices:
9
+ > This pull request solves issue #5 as decided in that discussion. See the discussion therein.
10
+
11
+ # Tests
12
+ Please describe tests that you added or changed to ensure that things behave correctly. This will ensure that we don't regress on this issue in the future.
13
+
14
+ For example:
15
+ > I added a test called `test_serialize_deserialize` that takes a specific Isotope, serializes and deserializes it with `pickle`, and ensures the result is the same object with an `is` assertion.
16
+
17
+ # Additional information
18
+ If there is some important detail about your changes that you think the reviewer should know about, please list it here.
19
+
20
+ # Checklist before your pull request is ready
21
+ - [ ] I tested the code locally, and it passes without new warnings that weren't there before
22
+ - [ ] I reviewed my own code
23
+ - [ ] My new code is documented and the documentation to code that I changed code is still applicable
24
+ - [ ] Any changes I made to public API that may break downstream packages was accepted by the community in the discussion in the Issue Tracker
25
+
26
+ Please do these things yourself before you post this pull request to save you and others some time.
@@ -0,0 +1,47 @@
1
+ # This workflow will install Python dependencies, run tests and lint with a variety of Python versions
2
+ # For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python
3
+
4
+ name: Python package
5
+
6
+ on:
7
+ push:
8
+ branches: [ "main" ]
9
+ pull_request:
10
+ branches: [ "dev" ]
11
+
12
+ jobs:
13
+ lint:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - name: Ruff check
18
+ uses: astral-sh/ruff-action@v3
19
+
20
+ build:
21
+ runs-on: ubuntu-latest
22
+ steps:
23
+ - uses: actions/checkout@v4
24
+ - uses: actions/setup-python@v6
25
+ with:
26
+ python-version: '3.14'
27
+ - name: Install this package
28
+ run: |
29
+ pip install .
30
+ - name: Run and import
31
+ run: |
32
+ python3 -c "from coreoperator import OperationalState"
33
+
34
+ test:
35
+ runs-on: ubuntu-latest
36
+ steps:
37
+ - uses: actions/checkout@v4
38
+ - uses: actions/setup-python@v6
39
+ with:
40
+ python-version: '3.14'
41
+ - name: Install this package
42
+ run: |
43
+ pip install .[test]
44
+ - name: Test in test directory
45
+ run: |
46
+ cd tests
47
+ pytest -v
@@ -0,0 +1,8 @@
1
+ .hypothesis
2
+ .idea
3
+ build
4
+ docs/build
5
+ docs/source/_static
6
+ *.egg-info
7
+ __pycache__
8
+ .pytest_cache
@@ -0,0 +1,109 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ We as members, contributors, and leaders pledge to make participation in our
6
+ community a harassment-free experience for everyone, regardless of any personal characteristics or identity.
7
+ We pledge to treat everyone with civility, to act and interact in ways that contribute to an open,
8
+ welcoming and healthy community.
9
+
10
+ ## Our Standards
11
+
12
+ Examples of behavior that contributes to a positive environment for our
13
+ community include:
14
+
15
+ * Demonstrating empathy and kindness toward other people
16
+ * Being respectful of differing opinions, viewpoints, and experiences
17
+ * Giving and gracefully accepting constructive feedback
18
+ * Accepting responsibility and apologizing to those affected by our mistakes,
19
+ and learning from the experience
20
+ * Focusing on what is best not just for us as individuals, but for the
21
+ overall community
22
+
23
+ Examples of unacceptable behavior include:
24
+
25
+ * The use of sexualized language or imagery, and sexual attention or
26
+ advances of any kind
27
+ * Trolling, insulting or derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or email
30
+ address, without their explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Enforcement Responsibilities
35
+
36
+ Community leaders are responsible for clarifying and enforcing our standards of
37
+ acceptable behavior and will take appropriate and fair corrective action in
38
+ response to any behavior that they deem inappropriate, threatening, offensive,
39
+ or harmful.
40
+
41
+ Community leaders have the right and responsibility to remove, edit, or reject
42
+ comments, commits, code, wiki edits, issues, and other contributions that are
43
+ not aligned to this Code of Conduct, and will communicate reasons for moderation
44
+ decisions when appropriate.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies within all community spaces, and also applies when
49
+ an individual is officially representing the community in public spaces.
50
+ Examples of representing our community include using an official e-mail address,
51
+ or acting as an appointed representative at an online or offline event.
52
+
53
+ ## Enforcement
54
+
55
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
56
+ reported to the community leaders responsible for enforcement at
57
+ nuclear.ramp.dev@gmail.com.
58
+ All complaints will be reviewed and investigated promptly and fairly.
59
+
60
+ All community leaders are obligated to respect the privacy and security of the
61
+ reporter of any incident.
62
+
63
+ ## Enforcement Guidelines
64
+
65
+ Community leaders should consult these enforcement methods for any action they
66
+ deem in violation of this Code of Conduct:
67
+
68
+ ### 1. Correction
69
+ A private, written warning from community leaders, providing
70
+ clarity around the nature of the violation and an explanation of why the
71
+ behavior was inappropriate. A public apology may be requested.
72
+
73
+ ### 2. Warning
74
+ A privately written warning with explicit consequences for continued behavior.
75
+ The warning should include the information as in a Correction, but also include
76
+ a demand that the offending party will avoid interaction with the affected party
77
+ for a specified period of time. This includes interaction in community events,
78
+ on this project or outside these spaces such as on social media.
79
+ Violating these terms may lead to a temporary or permanent ban.
80
+
81
+ ### 3. Temporary Ban
82
+ A temporary ban from any sort of interaction or public
83
+ communication with the community for a specified period of time. No public or
84
+ private interaction with the people involved, including unsolicited interaction
85
+ with those enforcing the Code of Conduct, is allowed during this period.
86
+ Violating these terms may lead to a permanent ban.
87
+ This step should only be taken if a warning was previously given to the
88
+ offending party or for more serious violations that require a public and immediate
89
+ action.
90
+
91
+ ### 4. Permanent Ban
92
+ A permanent ban from any sort of public interaction within the community.
93
+ A permanent ban should only result from continued violations or a pattern
94
+ of behavior that is incompatible with this Code of Conduct.
95
+
96
+ ## Attribution
97
+
98
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage],
99
+ version 2.0, available at
100
+ https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
101
+
102
+ Community Impact Guidelines were inspired by [Mozilla's code of conduct
103
+ enforcement ladder](https://github.com/mozilla/diversity).
104
+
105
+ [homepage]: https://www.contributor-covenant.org
106
+
107
+ For answers to common questions about this code of conduct, see the FAQ at
108
+ https://www.contributor-covenant.org/faq. Translations are available at
109
+ https://www.contributor-covenant.org/translations.
@@ -0,0 +1,47 @@
1
+ # Contributing
2
+
3
+ Thank you for considering a contribution to our project.
4
+ We welcome new members to the community and this guide is meant to help you make your
5
+ first steps with our community.
6
+
7
+ ## Code of Conduct
8
+
9
+ Participants in the this project are expected to follow and uphold the [Code
10
+ of Conduct](CODE_OF_CONDUCT.md).
11
+ Please report any unacceptable behavior to the email described therein.
12
+
13
+ ## How to report bugs
14
+ We have a template for bugs in our issue tracker.
15
+ All bugs are tracked through the issue tracker, so please use that!
16
+
17
+ ## How to ask for improvements or new features
18
+
19
+ We welcome constant improvement, and we have a template for new features in our issues tracker.
20
+ You should notice that our team is small, and it may take some time for us to deal with any
21
+ specific request, or we may find that the request creates too heavy a burden for us to maintain.
22
+ If you are interested in contributing yourself, please say so in your issue. It is much easier
23
+ for us to accept new features when the community is willing to work alongside the core team on them.
24
+
25
+ ## How to submit changes
26
+
27
+ All changes to the `dev` and `main` branches happen through pull requests.
28
+ Feature branches should target the `dev` branch for their pull request, where the code will be reviewed
29
+ and any appropriate checks will run.
30
+ The code will be reviewed by the community, and such a review should ensure that the committed code is
31
+ correct as well as that its quality meets our standards.
32
+ The reviewers may ask you for some changes before they are willing to merge your changes in, or they
33
+ may change some things themselves in a collaborative effort. Please remember that while your contribution
34
+ is welcome, it is always part of a group effort, and the group has the right to edit or even reject parts
35
+ of your contribution to meet the community's needs.
36
+ Such changes, suggestions and requests should always follow the Code of Conduct, as well as your own
37
+ contribution. Please report any unacceptable behavior during the review process if you encounter it.
38
+
39
+ ## Code Style
40
+
41
+ We currently don't have a written-down style guide, and we should get around to it.
42
+ This may cause some friction, since style is a matter of preference, but if both you and your reviewers
43
+ apply a positive mindset that we're all trying to get the project to be at its best, we will likely
44
+ find a suitable solution.
45
+
46
+ If you find that much of your time is taken on discussions about a style guide that isn't there,
47
+ please let us know and we'll make this a higher priority.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Eshed Magali
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,53 @@
1
+ Metadata-Version: 2.4
2
+ Name: ramp-coreoperator
3
+ Version: 0.0.2
4
+ Summary: Package for applying operations on cores from coremaker
5
+ Author-email: Nuclear RAMP team <nuclear.ramp.dev@gmail.com>
6
+ License: MIT License
7
+
8
+ Copyright (c) 2026 Eshed Magali
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Classifier: Development Status :: 4 - Beta
29
+ Classifier: Intended Audience :: Developers
30
+ Classifier: Intended Audience :: End Users/Desktop
31
+ Classifier: Intended Audience :: Science/Research
32
+ Classifier: License :: OSI Approved :: MIT License
33
+ Classifier: Natural Language :: English
34
+ Classifier: Topic :: Scientific/Engineering
35
+ Classifier: Programming Language :: Python :: 3
36
+ Classifier: Programming Language :: Python :: 3.11
37
+ Classifier: Programming Language :: Python :: 3.12
38
+ Classifier: Programming Language :: Python :: 3.13
39
+ Requires-Python: >=3.11
40
+ Description-Content-Type: text/markdown
41
+ License-File: LICENSE
42
+ Requires-Dist: more-itertools
43
+ Requires-Dist: numpy
44
+ Requires-Dist: ramp-coremaker
45
+ Requires-Dist: ramp-core
46
+ Requires-Dist: ramp-isotopes
47
+ Provides-Extra: test
48
+ Requires-Dist: hypothesis; extra == "test"
49
+ Requires-Dist: pandas; extra == "test"
50
+ Requires-Dist: pytest; extra == "test"
51
+ Dynamic: license-file
52
+
53
+ Package for changing core states, used for things like mobilizations and density updates.
@@ -0,0 +1 @@
1
+ Package for changing core states, used for things like mobilizations and density updates.
@@ -0,0 +1,14 @@
1
+ """
2
+ Package for defining operations on core states and for maintaining an
3
+ operational history for it.
4
+ """
5
+
6
+ from .featherstate import FeatherState
7
+ from .history import History, OperationalPeriod, StateParams
8
+ from .mobilization import jsonable as mob_jsonable
9
+ from .operational_state import OperationalState
10
+
11
+ jsonable = mob_jsonable + [History, OperationalState, FeatherState, OperationalPeriod, StateParams]
12
+
13
+ __all__ = ["jsonable", "OperationalState", "FeatherState", "History", "StateParams"]
14
+
@@ -0,0 +1,11 @@
1
+ from coremaker.example import example_core
2
+
3
+ from coreoperator.history import History, StateParams
4
+ from coreoperator.operational_state import OperationalState
5
+
6
+ blank_hist = History()
7
+ example_state = OperationalState(history=blank_hist,
8
+ params=StateParams(power=0),
9
+ tags={"blank"},
10
+ core=example_core,
11
+ )
@@ -0,0 +1,89 @@
1
+ import pickle
2
+ import zlib
3
+ from typing import Any, Literal, Type, TypeVar
4
+
5
+ try:
6
+ from typing import Self
7
+ except ImportError:
8
+ Self = TypeVar("Self")
9
+
10
+ from coremaker.core import Core
11
+
12
+ from .operational_state import OperationalState
13
+
14
+ Zlib_Compression = Literal[-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
15
+ DEFAULT_COMPRESSION = 2 # A sensible default, fast and still has an effect for us
16
+
17
+
18
+ class FeatherState(OperationalState):
19
+ """An OperationalState that takes less space in memory and is much easier to
20
+ transmit over the wire.
21
+
22
+ This comes at the cost of slightly less comfortable ergonomics, because one
23
+ cannot directly edit `state.core` and has to explicitly reset the core with
24
+ a setter method to make changes stick.
25
+ To make the ergonomics similar, we made OperationalState similarly complex,
26
+ but deem the tradeoff to be worth the trouble.
27
+
28
+ """
29
+
30
+ ser_identifier = "FeatherState"
31
+ __zcore: bytes
32
+
33
+ def __init__(self, *, compression_level: Zlib_Compression = DEFAULT_COMPRESSION, **kw):
34
+ """
35
+
36
+ Parameters
37
+ ----------
38
+ compression_level: Zlib_Compression
39
+ The compression level to use. See the `zlib` standard library documentation for details.
40
+ Defaults to a fast compression that still has a significant impact. Subject to change.
41
+ kw:
42
+ Keywords used to make an OperationalState. See that class for details.
43
+
44
+ """
45
+ self.compression_level = compression_level
46
+ super().__init__(**kw)
47
+
48
+ def serialize(self) -> tuple[str, dict[str, Any]]:
49
+ parent_serialized_data = super().serialize()[1]
50
+ parent_serialized_data["compression"] = self.compression_level
51
+ return self.ser_identifier, parent_serialized_data
52
+
53
+ @classmethod
54
+ def deserialize(cls: Type[Self], d: dict[str, Any], *args, **kwargs) -> Self:
55
+ compression = d.pop("compression")
56
+ return cls.from_state(super().deserialize(d=d, *args, **kwargs), compression_level=compression)
57
+
58
+ @classmethod
59
+ def from_state(cls: Type[Self],
60
+ state: OperationalState,
61
+ compression_level: Zlib_Compression = DEFAULT_COMPRESSION,
62
+ ) -> Self:
63
+ """Creates a FeatherState from an OperationalState
64
+
65
+ Parameters
66
+ ----------
67
+ state: OperationalState
68
+ The OperationalState to compress
69
+ compression_level: Zlib_Compression
70
+ The compression level to use. See the `zlib` standard library documentation for details.
71
+
72
+ """
73
+ if isinstance(state, FeatherState):
74
+ state.compression_level = compression_level
75
+ return state
76
+ return cls(**state.as_dict(), compression_level=compression_level)
77
+
78
+ @property
79
+ def core(self) -> Core:
80
+ return pickle.loads(zlib.decompress(self.__zcore))
81
+
82
+ @core.setter
83
+ def core(self, core):
84
+ self.__zcore = zlib.compress(pickle.dumps(core), self.compression_level)
85
+
86
+ @property
87
+ def _core(self) -> Core:
88
+ return self.core
89
+