Skip to content

Commit

Permalink
Hide Array and GF2 inherited methods and properties
Browse files Browse the repository at this point in the history
  • Loading branch information
mhostetter committed Apr 22, 2022
1 parent 98c2272 commit d00abbc
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 33 deletions.
3 changes: 0 additions & 3 deletions docs/.gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1 @@
build/
api/galois.*.rst
api/np.*
.ipynb_checkpoints/
6 changes: 3 additions & 3 deletions docs/api/galois-fields.rst
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,11 @@ Abstract base classes

FieldArray

Pre-made `FieldArray` subclasses
...................................
Pre-made :obj:`~galois.FieldArray` subclasses
.............................................

.. autosummary::
:template: class_only_init.rst
:template: class.rst
:toctree:

GF2
Expand Down
7 changes: 7 additions & 0 deletions docs/api/galois.Array.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
galois.Array
============

.. currentmodule:: galois

.. autoclass:: Array
:exclude-members: Identity, Ones, Random, Range, Zeros, compile, display
7 changes: 7 additions & 0 deletions docs/api/galois.GF2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
galois.GF2
==========

.. currentmodule:: galois

.. autoclass:: GF2
:inherited-members: FieldArray
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@
}

autosummary_generate = True
autosummary_generate_overwrite = True
autosummary_generate_overwrite = False
autosummary_imported_members = True

ipython_execlines = ["import math", "import numpy as np", "import galois"]
Expand Down
31 changes: 5 additions & 26 deletions galois/_fields/_gf2.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,6 @@ class GF2(FieldArray, characteristic=2, degree=1, order=2, irreducible_poly_int=
This class is a pre-generated :obj:`~galois.FieldArray` subclass generated with `galois.GF(2)` and is included in the API
for convenience.
Only the constructor is documented on this page. See :obj:`~galois.FieldArray` for all other classmethods and methods
for :obj:`~galois.GF2`.
Examples
--------
This class is equivalent, and in fact identical, to the :obj:`~galois.FieldArray` subclass returned from the class factory
Expand All @@ -38,6 +35,11 @@ class GF2(FieldArray, characteristic=2, degree=1, order=2, irreducible_poly_int=
x = galois.GF2([1, 0, 1, 1]); x
isinstance(x, galois.GF2)
Note
----
Only the class docstring is documented on this page. See :obj:`~galois.FieldArray` for all other classmethods, class properties,
and methods inherited by :obj:`~galois.GF2`.
"""
# Need to have a unique cache of "calculate" functions for GF(2)
_FUNC_CACHE_CALCULATE = {}
Expand All @@ -52,29 +54,6 @@ class GF2(FieldArray, characteristic=2, degree=1, order=2, irreducible_poly_int=
# return "jit-calculate"
_default_ufunc_mode = "jit-calculate"

if SPHINX_BUILD:
# Only during Sphinx builds, monkey-patch the metaclass properties into this class as "class properties". In Python 3.9 and greater,
# class properties may be created using `@classmethod @property def foo(cls): return "bar"`. In earlier versions, they must be created
# in the metaclass, however Sphinx cannot find or document them. Adding this workaround allows Sphinx to document them.
characteristic = classproperty(FieldArrayMeta.characteristic)
default_ufunc_mode = classproperty(FieldArrayMeta.default_ufunc_mode)
degree = classproperty(FieldArrayMeta.degree)
display_mode = classproperty(FieldArrayMeta.display_mode)
dtypes = classproperty(FieldArrayMeta.dtypes)
irreducible_poly = classproperty(FieldArrayMeta.irreducible_poly)
is_extension_field = classproperty(FieldArrayMeta.is_extension_field)
is_prime_field = classproperty(FieldArrayMeta.is_prime_field)
is_primitive_poly = classproperty(FieldArrayMeta.is_primitive_poly)
name = classproperty(FieldArrayMeta.name)
order = classproperty(FieldArrayMeta.order)
prime_subfield = classproperty(FieldArrayMeta.prime_subfield)
primitive_element = classproperty(FieldArrayMeta.primitive_element)
primitive_elements = classproperty(FieldArrayMeta.primitive_elements)
quadratic_non_residues = classproperty(FieldArrayMeta.quadratic_non_residues)
quadratic_residues = classproperty(FieldArrayMeta.quadratic_residues)
ufunc_mode = classproperty(FieldArrayMeta.ufunc_mode)
ufunc_modes = classproperty(FieldArrayMeta.ufunc_modes)

@classmethod
def _reset_ufuncs(cls):
super()._reset_ufuncs()
Expand Down

0 comments on commit d00abbc

Please sign in to comment.