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

Support pickling FieldArray subclasses and instances #393

Merged
merged 3 commits into from Jul 28, 2022

Conversation

mhostetter
Copy link
Owner

Fixes #388

Pickle FieldArray subclasses

In [1]: import pickle

In [2]: import galois

In [3]: GF = galois.GF(47)

In [4]: print(GF.properties)
Galois Field:
  name: GF(47)
  characteristic: 47
  degree: 1
  order: 47
  irreducible_poly: x + 42
  is_primitive_poly: True
  primitive_element: 5

In [5]: with open("gf_class.pkl", "wb") as f:
   ...:     pickle.dump(GF, f)
   ...: 

In [6]: with open("gf_class.pkl", "rb") as f:
   ...:     GF_loaded = pickle.load(f)
   ...:

In [7]: print(GF_loaded.properties)
Galois Field:
  name: GF(47)
  characteristic: 47
  degree: 1
  order: 47
  irreducible_poly: x + 42
  is_primitive_poly: True
  primitive_element: 5

Pickle FieldArray instance

In [1]: import pickle

In [2]: import galois

In [3]: GF = galois.GF(47)

In [4]: x = GF.Random(10, low=1, seed=1); x
Out[4]: GF([46, 41,  7, 22, 44, 34, 24, 19, 31, 15], order=47)

In [5]: with open("gf_array.pkl", "wb") as f:
   ...:     pickle.dump(x, f)
   ...: 

In [6]: with open("gf_array.pkl", "rb") as f:
   ...:     x_loaded = pickle.load(f)
   ...: 

In [7]: x_loaded
Out[7]: GF([46, 41,  7, 22, 44, 34, 24, 19, 31, 15], order=47)

@mhostetter mhostetter added the bug-fix Fixes a reported bug label Jul 26, 2022
@codecov
Copy link

codecov bot commented Jul 26, 2022

Codecov Report

Merging #393 (b0ff7fd) into master (d94c3b6) will increase coverage by 0.00%.
The diff coverage is 100.00%.

@@           Coverage Diff           @@
##           master     #393   +/-   ##
=======================================
  Coverage   95.05%   95.05%           
=======================================
  Files          42       42           
  Lines        5395     5400    +5     
=======================================
+ Hits         5128     5133    +5     
  Misses        267      267           
Impacted Files Coverage Δ
galois/_fields/_array.py 98.85% <100.00%> (+<0.01%) ⬆️
galois/_fields/_factory.py 96.63% <100.00%> (+0.08%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update d94c3b6...b0ff7fd. Read the comment docs.

@mhostetter
Copy link
Owner Author

/fast-forward

@github-actions
Copy link

Success! Fast forwarded master to support-pickle! git checkout master && git merge support-pickle --ff-only

@github-actions github-actions bot merged commit b0ff7fd into master Jul 28, 2022
@github-actions github-actions bot deleted the support-pickle branch July 28, 2022 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-fix Fixes a reported bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow serialization of Galois field
1 participant