DGCV 0.3.3__tar.gz → 0.3.4__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 (57) hide show
  1. {dgcv-0.3.3/src/dgcv.egg-info → dgcv-0.3.4}/PKG-INFO +1 -1
  2. {dgcv-0.3.3 → dgcv-0.3.4}/pyproject.toml +1 -1
  3. {dgcv-0.3.3 → dgcv-0.3.4}/setup.cfg +1 -1
  4. {dgcv-0.3.3 → dgcv-0.3.4}/setup.py +1 -1
  5. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/algebras/algebras_core.py +129 -45
  6. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/algebras/algebras_secondary.py +90 -12
  7. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/filtered_structures.py +2 -3
  8. {dgcv-0.3.3 → dgcv-0.3.4/src/dgcv.egg-info}/PKG-INFO +1 -1
  9. {dgcv-0.3.3 → dgcv-0.3.4}/LICENSE.txt +0 -0
  10. {dgcv-0.3.3 → dgcv-0.3.4}/MANIFEST.in +0 -0
  11. {dgcv-0.3.3 → dgcv-0.3.4}/README.md +0 -0
  12. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/CR_geometry.py +0 -0
  13. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/Riemannian_geometry.py +0 -0
  14. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/__init__.py +0 -0
  15. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/_config.py +0 -0
  16. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/_dgcv_display.py +0 -0
  17. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/_safeguards.py +0 -0
  18. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/_settings.py +0 -0
  19. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/_tensor_field_printers.py +0 -0
  20. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/algebras/algebras_aux.py +0 -0
  21. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/__init__.py +0 -0
  22. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Black.ttf +0 -0
  23. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Black.woff2 +0 -0
  24. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Bold.ttf +0 -0
  25. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Bold.woff2 +0 -0
  26. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-ExtraBold.ttf +0 -0
  27. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-ExtraBold.woff2 +0 -0
  28. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Medium.ttf +0 -0
  29. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Medium.woff2 +0 -0
  30. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Regular.ttf +0 -0
  31. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-Regular.woff2 +0 -0
  32. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-SemiBold.ttf +0 -0
  33. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/Orbitron-SemiBold.woff2 +0 -0
  34. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/PatrickHand-Regular.ttf +0 -0
  35. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/assets/fonts/fonts.css +0 -0
  36. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/combinatorics.py +0 -0
  37. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/complex_structures.py +0 -0
  38. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/conversions.py +0 -0
  39. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/coordinate_maps.py +0 -0
  40. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/dgcv_core.py +0 -0
  41. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/dgcv_formatter.py +0 -0
  42. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/eds/__init__.py +0 -0
  43. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/eds/ast.py +0 -0
  44. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/eds/eds.py +0 -0
  45. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/eds/eds_operations.py +0 -0
  46. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/eds/eds_representations.py +0 -0
  47. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/polynomials.py +0 -0
  48. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/representations.py +0 -0
  49. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/solvers.py +0 -0
  50. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/styles.py +0 -0
  51. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/tensors.py +0 -0
  52. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/vector_fields_and_differential_forms.py +0 -0
  53. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv/vmf.py +0 -0
  54. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv.egg-info/SOURCES.txt +0 -0
  55. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv.egg-info/dependency_links.txt +0 -0
  56. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv.egg-info/requires.txt +0 -0
  57. {dgcv-0.3.3 → dgcv-0.3.4}/src/dgcv.egg-info/top_level.txt +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgcv
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Differential Geometry with Complex Variables
5
5
  Author: David Sykes
6
6
  Author-email: David Sykes <david@realandimaginary.com>
@@ -5,7 +5,7 @@ build-backend = "setuptools.build_meta"
5
5
  [project]
6
6
  requires-python = ">=3.6"
7
7
  name = "dgcv"
8
- version = "0.3.3"
8
+ version = "0.3.4"
9
9
  description = "Differential Geometry with Complex Variables"
10
10
  authors = [{ name = "David Sykes", email = "david@realandimaginary.com" }]
11
11
  license = { text = "MIT" }
@@ -1,6 +1,6 @@
1
1
  [metadata]
2
2
  name = dgcv
3
- version = 0.3.3
3
+ version = 0.3.4
4
4
  description = A package for Differential Geometry with Complex Variables
5
5
  author = David Sykes
6
6
  author_email = david@realandimaginary.com
@@ -15,7 +15,7 @@ To get started, check out the Jupyter Notebook tutorials:
15
15
 
16
16
  setup(
17
17
  name="dgcv",
18
- version="0.3.3",
18
+ version="0.3.4",
19
19
  description="Differential Geometry with Complex Variables",
20
20
  long_description=long_description, # This shows up on PyPI
21
21
  long_description_content_type="text/markdown",
@@ -60,7 +60,7 @@ class algebra_class(sp.Basic):
60
60
  self._registered = True
61
61
  else:
62
62
  self.label = "Alg_" + create_key()
63
- self.basis_labels = None
63
+ self.basis_labels = [f"_e{i+1}" for i in range(len(self.structureData))]
64
64
  self._registered = False
65
65
  self._callLock = _callLock
66
66
  self._print_warning = _print_warning
@@ -971,10 +971,11 @@ class algebra_class(sp.Basic):
971
971
  else:
972
972
  nonAE = []
973
973
  wrongAlgebra = []
974
+ typeCheck={'algebra_element','subalgebra_element'}
974
975
  for elem in elements:
975
- if not isinstance(elem, algebra_element_class):
976
+ if get_dgcv_category(elem) not in typeCheck:
976
977
  nonAE.append(elem)
977
- elif elem.algebra!=self:
978
+ elif elem.algebra!=self or (get_dgcv_category(elem)=='subalgebra_element' and elem.algebra.ambiant!=self):
978
979
  wrongAlgebra.append(elem)
979
980
  if len(nonAE)>0 or len(wrongAlgebra)>0:
980
981
  if len(nonAE)>0:
@@ -988,6 +989,8 @@ class algebra_class(sp.Basic):
988
989
  unique_elements = []
989
990
  seen_coeffs = set()
990
991
  for el in elements:
992
+ if get_dgcv_category(el)=='subalgebra_element':
993
+ el = el.ambiant_rep
991
994
  coeff_tuple = tuple(el.coeffs) # Convert coeffs to a tuple for hashability
992
995
  if coeff_tuple not in seen_coeffs:
993
996
  seen_coeffs.add(coeff_tuple)
@@ -1177,17 +1180,12 @@ class algebra_class(sp.Basic):
1177
1180
  Notes
1178
1181
  -----
1179
1182
  - The (j, k)-entry of the structure matrix is the result of `basis[j] * basis[k]`.
1180
- - If `basis_labels` is None, defaults to "e1", "e2", ..., "ed".
1183
+ - If `basis_labels` is None, defaults to "_e1", "_e2", ..., "_e{d}".
1181
1184
  """
1182
1185
  import pandas as pd
1183
1186
 
1184
- # Dimension of the algebra
1185
1187
  dimension = self.dimension
1186
-
1187
- # Default labels if basis_labels is None
1188
- basis_labels = self.basis_labels or [f"e{i+1}" for i in range(dimension)]
1189
-
1190
- # Initialize the structure matrix as a list of lists
1188
+ basis_labels = self.basis_labels or [f"_e{i+1}" for i in range(dimension)]
1191
1189
  structure_matrix = [
1192
1190
  [(self.basis[j] * self.basis[k]) for k in range(dimension)]
1193
1191
  for j in range(dimension)
@@ -1213,8 +1211,6 @@ class algebra_class(sp.Basic):
1213
1211
  pandas_style
1214
1212
  )
1215
1213
  return styled_df
1216
-
1217
- # Return as a list of lists
1218
1214
  return structure_matrix
1219
1215
 
1220
1216
  def is_ideal(self, subspace_elements):
@@ -1429,7 +1425,6 @@ class algebra_class(sp.Basic):
1429
1425
  return algebra_subspace_class(self,basis,parent_algebra=self,test_weights=grading)
1430
1426
 
1431
1427
 
1432
-
1433
1428
  class algebra_element_class(sp.Basic):
1434
1429
  def __new__(cls, alg, coeffs, valence, format_sparse=False):
1435
1430
 
@@ -1866,10 +1861,6 @@ class algebra_element_class(sp.Basic):
1866
1861
  - 'AllW' is returned for zero elements, which are compaible with all weights.
1867
1862
  - 'NoW' is returned for non-homogeneous elements that do not satisfy the grading constraints.
1868
1863
  """
1869
- if not hasattr(self, "algebra") or not isinstance(self.algebra, algebra_class):
1870
- raise ValueError(
1871
- "This algebra_element_class is not associated with a valid algebra."
1872
- ) from None
1873
1864
 
1874
1865
  return self.algebra.check_element_weight(self)
1875
1866
 
@@ -1877,24 +1868,55 @@ class algebra_subspace_class(sp.Basic):
1877
1868
  def __new__(cls, basis, parent_algebra=None, test_weights=None,_grading=None,_internal_lock=None,**kwargs):
1878
1869
  if not isinstance(basis,(list,tuple)):
1879
1870
  raise TypeError('algebra_subspace_class expects first argument to a be a list or tuple of algebra_element_class instances') from None
1880
- if not all(isinstance(j,algebra_element_class) for j in basis):
1871
+ typeCheck = {'subalgebra_element', 'algebra_element'}
1872
+ if (not all(get_dgcv_category(j) in typeCheck for j in basis)):
1881
1873
  raise TypeError('algebra_subspace_class expects first argument to a be a list or tuple of algebra_element_class instances') from None
1882
1874
  if parent_algebra is None:
1883
1875
  if len(basis)>0:
1884
- parent_algebra=basis[0].algebra
1885
- elif not isinstance(parent_algebra, algebra_class):
1886
- raise TypeError('algebra_subspace_class expects second argument to an algebra instance.') from None
1887
- if not all([j.algebra == parent_algebra for j in basis]):
1888
- raise TypeError('algebra_subspace_class expects all algebra_element_class instances given in the first argument to have the same `algebra_element_class.algebra` value as the second argument.') from None
1876
+ if get_dgcv_category(basis[0].algebra)!='algebra':
1877
+ if all(j.algebra==basis[0].algebra for j in basis[1:]):
1878
+ parent_alg = basis[0].algebra.ambiant
1879
+ if test_weights and isinstance(test_weights,(list,tuple)) and len(test_weights[0])==len(basis[0].algebra):
1880
+ weight_subspace = basis[0].algebra
1881
+ else:
1882
+ weight_subspace = parent_alg
1883
+ else:
1884
+ parent_alg = basis[0].algebra.ambiant
1885
+ weight_subspace = parent_alg
1886
+ else:
1887
+ parent_alg=basis[0].algebra
1888
+ weight_subspace = parent_alg
1889
+ else:
1890
+ weight_subspace = []
1891
+ elif get_dgcv_category(parent_algebra) in {'subalgebra', 'algebra_subspace'}:
1892
+ parent_alg = parent_algebra.ambiant
1893
+ weight_subspace = parent_algebra if test_weights else parent_alg
1894
+ elif get_dgcv_category(parent_algebra)=='algebra':
1895
+ parent_alg = parent_algebra
1896
+ weight_subspace = parent_algebra
1897
+ else:
1898
+ raise TypeError('algebra_subspace_class expects second argument to an algebra instance or algebra subspace or subalgebra.') from None
1899
+
1900
+ if not all([j.algebra == weight_subspace for j in basis]):
1901
+ if get_dgcv_category(weight_subspace)=='algebra':
1902
+ new_basis = []
1903
+ for elem in basis:
1904
+ if get_dgcv_category(elem)=='algebra_element':
1905
+ new_basis.append(elem)
1906
+ else:
1907
+ new_basis.append(elem.ambiant_rep)
1908
+ basis=new_basis
1909
+ if not all([j.algebra == weight_subspace for j in basis]):
1910
+ raise TypeError('algebra_subspace_class expects all (sub)algebra_element_class instances given in the first argument to have the same `(sub)algebra_element_class.algebra` value as the second argument.') from None
1889
1911
  if test_weights and not(_internal_lock==retrieve_passkey() and _grading is not None):
1890
1912
  if not isinstance(test_weights,(list,tuple)):
1891
- raise TypeError('`check_element_weight` expects `check_element_weight` to be None or a list/tuple of lists of weight values (int,float, or sp.Expr).') from None
1913
+ raise TypeError('`algebra_subspace_class` initializer expects `test_weight` to be None or a list/tuple of lists of weight values (int,float, or sp.Expr).') from None
1892
1914
  for tw in test_weights:
1893
1915
  if not isinstance(tw,(list,tuple)):
1894
- raise TypeError('`check_element_weight` expects `check_element_weight` to be None or a list/tuple of lists of weight values (int,float, or sp.Expr).') from None
1895
- if parent_algebra.dimension != len(tw) or not all([isinstance(j,(int,float,sp.Expr)) for j in tw]):
1896
- raise TypeError('`check_element_weight` expects `check_element_weight` to be None or a length {alg.dimension} list/tuple of weight values (int,float, or sp.Expr).') from None
1897
- filtered_basis = parent_algebra.filter_independent_elements(basis)
1916
+ raise TypeError('`algebra_subspace_class` initializer expects `test_weight` to be None or a list/tuple of lists of weight values (int,float, or sp.Expr).') from None
1917
+ if weight_subspace.dimension != len(tw) or not all([isinstance(j,(int,float,sp.Expr)) for j in tw]):
1918
+ raise TypeError('`algebra_subspace_class` initializer expects `test_weight` to be None or a length {alg.dimension} list/tuple of weight values (int,float, or sp.Expr).') from None
1919
+ filtered_basis = parent_alg.filter_independent_elements(basis)
1898
1920
  if len(filtered_basis)<len(basis):
1899
1921
  basis = filtered_basis
1900
1922
  warnings.warn('The given list for `basis` was not linearly independent, so the algebra_subspace_class initializer computed a basis for its span to use instead.')
@@ -1902,30 +1924,28 @@ class algebra_subspace_class(sp.Basic):
1902
1924
  # Create the new instance
1903
1925
  obj = sp.Basic.__new__(cls, basis, parent_algebra, test_weights)
1904
1926
  obj.filtered_basis = filtered_basis
1905
- return obj
1906
-
1907
- def __init__(self, basis, parent_algebra=None, test_weights=None,_grading=None,_internal_lock=None):
1908
- if parent_algebra is None:
1909
- if len(basis)>0:
1910
- parent_algebra=basis[0].algebra
1911
- self.ambiant = parent_algebra
1912
- self.basis = tuple(self.filtered_basis)
1913
- self.original_basis = basis
1914
- self.dimension = len(self.basis)
1927
+ obj.basis = tuple(filtered_basis)
1928
+ obj.dimension = len(filtered_basis)
1929
+ obj.ambiant = parent_alg
1915
1930
  grading_per_elem = []
1916
1931
  if test_weights is None and _internal_lock==retrieve_passkey() and _grading is not None:
1917
- self.grading=_grading
1932
+ obj.grading=_grading
1918
1933
  else:
1919
- for elem in self.basis:
1920
- weight = parent_algebra.check_element_weight(elem,test_weights=test_weights)
1934
+ for elem in filtered_basis:
1935
+ weight = weight_subspace.check_element_weight(elem,test_weights=test_weights)
1921
1936
  grading_per_elem.append(weight)
1922
- self.grading = list(zip(*grading_per_elem))
1923
- self.grading = [elem for elem in self.grading if 'NoW' not in elem]
1937
+ obj.grading = list(zip(*grading_per_elem))
1938
+ obj.grading = [elem for elem in obj.grading if 'NoW' not in elem]
1939
+ return obj
1940
+
1941
+ def __init__(self, basis, parent_algebra=None, test_weights=None,_grading=None,_internal_lock=None):
1942
+ self.original_basis = basis
1924
1943
  self._dgcv_class_check=retrieve_passkey()
1925
1944
  self._dgcv_category='algebra_subspace'
1926
1945
 
1927
1946
  # immutables
1928
1947
  self._grading = tuple(self.grading)
1948
+ self._gradingNumber = len(self._grading)
1929
1949
 
1930
1950
  # attribute caches
1931
1951
  self._is_subalgebra = None
@@ -1943,10 +1963,65 @@ class algebra_subspace_class(sp.Basic):
1943
1963
  def __contains__(self, item):
1944
1964
  return item in self.basis
1945
1965
 
1946
- def contains(self, items):
1966
+ def check_element_weight(self, element, test_weights = None):
1967
+ """
1968
+ Determines the weight vector of an algebra_element_class with respect to the grading vectors assigned to an algebra_subspace_class. Weight can be instead computed against another grading vector passed a list of weights as the keyword `test_weights`.
1969
+
1970
+ Parameters
1971
+ ----------
1972
+ element : (sub)algebra_element_class
1973
+ The (sub)algebra_element_class to analyze.
1974
+ test_weights : list of int or sympy.Expr, optional (default: None)
1975
+
1976
+ Returns
1977
+ -------
1978
+ list
1979
+ A list of weights corresponding to the grading vectors of this algebra subspace (or test_weights if provided).
1980
+ Each entry is either an integer, sympy.Expr (weight), the string 'AllW' (i.e., All Weights) if the element is the zero element,
1981
+ or 'NoW' (i.e., No Weights) if the element is not homogeneous.
1982
+
1983
+ Notes
1984
+ -----
1985
+ - 'AllW' (meaning, All Weights) is returned for zero elements, which are compatible with all weights.
1986
+ - 'NoW' (meaning, No Weights) is returned for non-homogeneous elements that do not satisfy the grading constraints.
1987
+ """
1988
+ if not isinstance(element, algebra_element_class) or element.algebra!=self:
1989
+ if get_dgcv_category(element)=='subalgebra_element' and element.algebra.ambiant==self.ambiant:
1990
+ pass
1991
+ else:
1992
+ raise TypeError("Input in `algebra_subspace_class.check_element_weight` must be an `(sub)algebra_element_class` instance belonging to the `(sub)algebra_class` instance whose `check_element_weight` is being called.") from None
1993
+ if not test_weights:
1994
+ if self._gradingNumber == 0:
1995
+ raise ValueError("This algebra subspace instance has no assigned grading vectors to test weighting w.r.t..") from None
1996
+ if all(coeff == 0 for coeff in element.coeffs):
1997
+ return ["AllW"] * self._gradingNumber
1998
+ if test_weights:
1999
+ if not isinstance(test_weights,(list,tuple)):
2000
+ raise TypeError('`check_element_weight` expects `test_weights` to be None or a list/tuple of lists/tuples of weight values (int,float, or sp.Expr).') from None
2001
+ for weight in test_weights:
2002
+ if not isinstance(weight,(list,tuple)):
2003
+ raise TypeError('`check_element_weight` expects `test_weights` to be None or a list/tuple of lists/tuples of weight values (int,float, or sp.Expr).') from None
2004
+ if self.dimension != len(weight) or not all([isinstance(j,(int,float,sp.Expr)) for j in weight]):
2005
+ raise TypeError('`check_element_weight` expects `test_weights` to be None or a list/tuple of lists/tuples of weight values (int,float, or sp.Expr).') from None
2006
+ GVs = test_weights
2007
+ else:
2008
+ GVs = self.grading
2009
+ weights = []
2010
+ for grading_vector in GVs:
2011
+ non_zero_indices = [i for i, coeff in enumerate(element.coeffs) if coeff != 0]
2012
+ basis_weights = [grading_vector[i] for i in non_zero_indices]
2013
+ if len(set(basis_weights)) == 1:
2014
+ weights.append(basis_weights[0])
2015
+ else:
2016
+ weights.append("NoW")
2017
+ return weights
2018
+
2019
+ def contains(self, items, return_basis_coeffs = False):
1947
2020
  if not isinstance(items,(list,tuple)):
1948
2021
  items = [items]
1949
2022
  for item in items:
2023
+ if get_dgcv_category(item)=='subalgebra_element':
2024
+ item=item.ambiant_rep
1950
2025
  if not isinstance(item,algebra_element_class) or item.algebra!=self.ambiant:
1951
2026
  return False
1952
2027
  if item not in self.basis:
@@ -1954,9 +2029,18 @@ class algebra_subspace_class(sp.Basic):
1954
2029
  variableProcedure(tempVarLabel, len(self.basis), _tempVar=retrieve_passkey())
1955
2030
  genElement = sum([_cached_caller_globals[tempVarLabel][j+1] * elem for j,elem in enumerate(self.basis[1:])],_cached_caller_globals[tempVarLabel][0]*(self.basis[0]))
1956
2031
  sol = solve_dgcv(item-genElement,_cached_caller_globals[tempVarLabel])
1957
- clearVar(*listVar(temporary_only=True))
1958
2032
  if len(sol)==0:
2033
+ clearVar(*listVar(temporary_only=True))
1959
2034
  return False
2035
+ else:
2036
+ if return_basis_coeffs is True:
2037
+ idx = (self.basis).index(item)
2038
+ return [1 if _==idx else 0 for _ in range(len(self.basis))]
2039
+ if return_basis_coeffs is True:
2040
+ vec=[var.subs(sol[0]) for var in _cached_caller_globals[tempVarLabel]]
2041
+ clearVar(*listVar(temporary_only=True))
2042
+ return vec
2043
+ clearVar(*listVar(temporary_only=True))
1960
2044
  return True
1961
2045
 
1962
2046
  def __iter__(self):
@@ -7,10 +7,13 @@ from .._safeguards import (
7
7
  _cached_caller_globals,
8
8
  get_dgcv_category,
9
9
  retrieve_passkey,
10
+ retrieve_public_key,
10
11
  validate_label,
11
12
  validate_label_list,
12
13
  )
13
14
  from ..combinatorics import carProd
15
+ from ..dgcv_core import variableProcedure
16
+ from ..solvers import solve_dgcv
14
17
  from ..tensors import tensorProduct
15
18
  from ..vmf import clearVar, listVar
16
19
  from .algebras_aux import _validate_structure_data
@@ -22,14 +25,18 @@ from .algebras_core import (
22
25
 
23
26
 
24
27
  class subalgebra_class(algebra_subspace_class):
28
+ def __new__(cls, basis, alg, grading=None, _compressed_structure_data=None, _internal_lock=None):
29
+ return super().__new__(cls, basis, alg, test_weights=None, _grading=grading, _internal_lock=_internal_lock)
25
30
  def __init__(self, basis, alg, grading=None, _compressed_structure_data=None, _internal_lock=None):
26
31
  super().__init__(basis, alg, test_weights=None, _grading=grading, _internal_lock=_internal_lock)
32
+ basis = self.filtered_basis
27
33
  self.structureData = None
28
34
  if _internal_lock==retrieve_passkey():
29
35
  if _compressed_structure_data is not None:
30
- self.structureData==_compressed_structure_data
36
+ self.structureData=_compressed_structure_data
31
37
  if self.structureData is None:
32
38
  self.structureData = self.is_subalgebra(return_structure_data=True)['structure_data']
39
+ self._structureData=tuple(map(tuple, self.structureData))
33
40
  self.subindices_to_ambiant_dict = {count:elem for count,elem in enumerate(basis)}
34
41
  self.basis_in_ambiant_alg = tuple(basis)
35
42
  self.basis = [subalgebra_element(self,[1 if j==count else 0 for j in range(self.dimension)],elem.valence) for count,elem in enumerate(basis)]
@@ -79,7 +86,41 @@ class subalgebra_class(algebra_subspace_class):
79
86
  return self.ambiant.subalegra(basis,grading=grading)
80
87
  def subspace(self,basis,grading=None):
81
88
  return self.ambiant.subspace(basis,grading=grading)
82
-
89
+ def contains(self, items, return_basis_coeffs = False):
90
+ if not isinstance(items,(list,tuple)):
91
+ items = [items]
92
+ for item in items:
93
+ if get_dgcv_category(item)=='subalgebra_element':
94
+ if item.algebra==self:
95
+ bas=self.basis
96
+ elif item.algebra.ambiant==self.ambiant:
97
+ item=item.ambiant_rep
98
+ bas=self.basis_in_ambiant_alg
99
+ else:
100
+ return False
101
+ elif get_dgcv_category(item)=='algebra_element' and item.algebra.ambiant==self.ambiant:
102
+ item=item.ambiant_rep
103
+ bas=self.basis_in_ambiant_alg
104
+ else:
105
+ return False
106
+ if item not in bas:
107
+ tempVarLabel = "T" + retrieve_public_key()
108
+ variableProcedure(tempVarLabel, len(bas), _tempVar=retrieve_passkey())
109
+ genElement = sum([_cached_caller_globals[tempVarLabel][j+1] * elem for j,elem in enumerate(bas[1:])],_cached_caller_globals[tempVarLabel][0]*(bas[0]))
110
+ sol = solve_dgcv(item-genElement,_cached_caller_globals[tempVarLabel])
111
+ if len(sol)==0:
112
+ clearVar(*listVar(temporary_only=True))
113
+ return False
114
+ else:
115
+ if return_basis_coeffs is True:
116
+ idx = bas.index(item)
117
+ return [1 if _==idx else 0 for _ in range(len(bas))]
118
+ if return_basis_coeffs is True:
119
+ vec=[var.subs(sol[0]) for var in _cached_caller_globals[tempVarLabel]]
120
+ clearVar(*listVar(temporary_only=True))
121
+ return vec
122
+ clearVar(*listVar(temporary_only=True))
123
+ return True
83
124
 
84
125
  class subalgebra_element():
85
126
  def __init__(self,alg,coeffs,valence,ambiant_rep=None,_internalLock=None):
@@ -262,11 +303,11 @@ class subalgebra_element():
262
303
 
263
304
  Notes
264
305
  -----
265
- - This method calls the parentt algebra' check_element_weight method.
306
+ - This method calls the parent algebra' check_element_weight method.
266
307
  - 'AllW' is returned for zero elements, which are compaible with all weights.
267
308
  - 'NoW' is returned for non-homogeneous elements that do not satisfy the grading constraints.
268
309
  """
269
- return self.ambiant_rep.check_element_weight()
310
+ return self.algebra.check_element_weight(self)
270
311
 
271
312
  class simpleLieAlgebra(algebra_class):
272
313
  def __init__(self, structure_data, grading=None, format_sparse=False, process_matrix_rep=False, preferred_representation=None, _label=None, _basis_labels=None, _calledFromCreator=None, _callLock=None, _print_warning=None, _child_print_warning=None, _exclude_from_VMF=None,_simple_data=None):
@@ -441,9 +482,17 @@ class simpleLieAlgebra(algebra_class):
441
482
  roots=[roots]
442
483
  elif not isinstance(roots,(list,tuple)):
443
484
  raise TypeError(f'The `roots` parameter in `simpleLieAlgebra.parabolic_grading(roots)` should be either `None`, an `int`, or a list of integers in the range (1,...,{self.rank}) representing indices of simple roots as enumerated in the algebras Dynkin diagram (see `simpleLieAlgebra.root_space_summary()` for a summary of this indexing).') from None
444
- return [sum([self.grading[idx-1][j] for idx in roots]) for j in range(self.dimension)]
445
-
446
- def parabolic_subalgebra(self,roots=None,label=None,basis_labels=None,register_in_vmf=True, return_Alg=False,use_non_positive_weights=False):
485
+ gradingVector = [sum([self.grading[idx-1][j] for idx in roots]) for j in range(self.dimension)]
486
+ denom = 1
487
+ for weight in gradingVector:
488
+ if isinstance(weight,sp.Rational):
489
+ if denom<weight.denominator:
490
+ denom=weight.denominator
491
+ if denom>1:
492
+ gradingVector=[denom*weight for weight in gradingVector]
493
+ return gradingVector
494
+
495
+ def parabolic_subalgebra(self,roots=None,label=None,basis_labels=None,register_in_vmf=None, return_Alg=False,use_non_positive_weights=False, format_as_subalgebra_class=False):
447
496
  if roots is None:
448
497
  roots=[]
449
498
  if isinstance(roots,int):
@@ -451,33 +500,62 @@ class simpleLieAlgebra(algebra_class):
451
500
  elif not isinstance(roots,(list,tuple)):
452
501
  raise TypeError(f'The `roots` parameter in `simpleLieAlgebra.parabolic_subalgebra(roots)` should be either `None`, an `int`, or a list of integers in the range (1,...,{self.rank}) representing indices of simple roots as enumerated in the algebras Dynkin diagram (see `simpleLieAlgebra.root_space_summary()` for a summary of this indexing).') from None
453
502
  newGrading = [sum([self.grading[idx-1][j] for idx in roots]) for j in range(self.dimension)]
454
- # parabolic = []
503
+ if format_as_subalgebra_class is True:
504
+ parabolic = []
455
505
  subIndices = []
456
506
  filtered_grading = []
457
507
  if not isinstance(use_non_positive_weights,bool):
458
508
  use_non_positive_weights = False
459
509
  for count, weight in enumerate(newGrading):
460
510
  if (weight>=0 and use_non_positive_weights is False) or (weight<=0 and use_non_positive_weights is True):
461
- # parabolic.append(self.basis[count])
511
+ if format_as_subalgebra_class is True:
512
+ parabolic.append(self.basis[count])
462
513
  subIndices.append(count)
463
514
  filtered_grading.append(weight)
515
+ denom = 1
516
+ for weight in filtered_grading:
517
+ if isinstance(weight,sp.Rational):
518
+ if denom<weight.denominator:
519
+ denom=weight.denominator
520
+ if denom>1:
521
+ filtered_grading=[denom*weight for weight in filtered_grading]
522
+
464
523
  def truncateBySubInd(li):
465
524
  return [li[j] for j in subIndices]
466
525
  structureData = truncateBySubInd(self._structureData)
467
526
  structureData = [truncateBySubInd(plane) for plane in structureData]
468
527
  structureData = [[truncateBySubInd(li) for li in plane] for plane in structureData]
528
+ if format_as_subalgebra_class is True:
529
+ ignoredList = []
530
+ if label is not None:
531
+ ignoredList.append('label')
532
+ if basis_labels is not None:
533
+ ignoredList.append('basis_labels')
534
+ if register_in_vmf is True:
535
+ ignoredList.append('register_in_vmf')
536
+ if len(ignoredList)==1:
537
+ warnings.warn(f'A parameter value was supplied for `{ignoredList[0]}`, but `format_as_subalgebra_class=True` was set. The `subalgebra_class` is not tracked in the vmf, so this parameter value was ignored. A subalgebra_class instance was returned instead.')
538
+ elif len(ignoredList)==2:
539
+ warnings.warn(f'Parameter values were supplied for `{ignoredList[0]}` and `{ignoredList[1]}`, but `format_as_subalgebra_class=True` was set. The `subalgebra_class` is not tracked in the vmf, so these parameter values were ignored. A subalgebra_class instance was returned instead.')
540
+ elif len(ignoredList)==3:
541
+ warnings.warn(f'Parameter values were supplied for `{ignoredList[0]}`, `{ignoredList[1]}`, and `{ignoredList[2]}`, but `format_as_subalgebra_class=True` was set. The `subalgebra_class` is not tracked in the vmf, so these parameter values were ignored. `A subalgebra_class instance was returned instead.`')
542
+ return subalgebra_class(parabolic, self, grading=[filtered_grading], _compressed_structure_data=structureData, _internal_lock=retrieve_passkey())
469
543
  if isinstance(label,str) or isinstance(basis_labels,(list,tuple,str)):
470
544
  register_in_vmf=True
471
545
  if register_in_vmf is True:
472
546
  if label is None:
473
547
  label = self.label+'_parabolic'
474
- if (isinstance(basis_labels,(list,tuple)) and not all(isinstance(elem,str) for elem in basis_labels)) or not isinstance(basis_labels,str):
548
+ if basis_labels is None:
549
+ basis_labels = label
550
+ elif (isinstance(basis_labels,(list,tuple)) and not all(isinstance(elem,str) for elem in basis_labels)) or not isinstance(basis_labels,str):
475
551
  raise TypeError('If supplying the optional parameter `basis_labels` to `simpleLieAlgebra.parabolic_subalgebra` then it should be either a string or list of strings') from None
476
552
  createAlgebra(structureData,label=label,basis_labels=basis_labels,grading=filtered_grading)
477
553
  if return_Alg is True:
478
554
  return _cached_caller_globals[label]
479
- if return_Alg is True or register_in_vmf is False:
480
- return algebra_class(structureData,grading=filtered_grading)
555
+ if return_Alg is True:
556
+ return algebra_class(structureData,grading=[filtered_grading])
557
+ elif register_in_vmf is not True:
558
+ warnings.warn('Optional keywords for the `parabolic_subalgebra` method indicate that nothing should be return returned or registered in the vmf. Probably that is not intended, in which case at least one keyword `label`, `basis_labels`, `register_in_vmf`, `return_Alg`, or `format_as_subalgebra_class` should be set differently.')
481
559
 
482
560
 
483
561
  def createSimpleLieAlgebra(
@@ -55,11 +55,11 @@ class Tanaka_symbol(sp.Basic):
55
55
  elif isinstance(GLA.grading[0],(list,tuple)):
56
56
  if not all(j<=0 for j in GLA.grading[0]):
57
57
  raise TypeError(
58
- "`Tanaka_symbol` expects `GLA` to be a graded Lie algebra (`algebra`, `algebra_subspace_class`, or `sualgebra` in particular) with non-positive weights in the first element of `GLA.grading`."
58
+ f"`Tanaka_symbol` expects `GLA` to be a graded Lie algebra (`algebra`, `algebra_subspace_class`, or `sualgebra` in particular) with non-positive weights in the first element of `GLA.grading`. Recieved grading data: {GLA.grading}"
59
59
  )
60
60
  elif not all(j<=0 for j in GLA.grading):
61
61
  raise TypeError(
62
- "`Tanaka_symbol` expects `GLA` to be a graded Lie algebra (`algebra`, `algebra_subspace_class`, or `sualgebra` in particular) with non-positive weights in the first element of `GLA.grading`."
62
+ f"`Tanaka_symbol` expects `GLA` to be a graded Lie algebra (`algebra`, `algebra_subspace_class`, or `sualgebra` in particular) with non-positive weights in the first element of `GLA.grading`. Recieved grading data: {GLA.grading}."
63
63
  )
64
64
 
65
65
  if isinstance(nonnegParts,dict):
@@ -668,7 +668,6 @@ class Tanaka_symbol(sp.Basic):
668
668
  def bracket_decomp(idx1,idx2):
669
669
  w1,sId1=flatToLayered(idx1)
670
670
  w2,sId2=flatToLayered(idx2)
671
- _cached_caller_globals['DEBUG']=(f'Grading len={len(grading_vec)}.\n Thresholds={indexThresholds}\n levelLengths={levelLengths} \n For {idx1}: {w1}, {sId1}. \n For {idx2}: {w2}, {sId2}')
672
671
  newElem = self.levels[w1][sId1]*self.levels[w2][sId2]
673
672
  newWeight = w1+w2
674
673
  ambiant_basis = self.levels[newWeight]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dgcv
3
- Version: 0.3.3
3
+ Version: 0.3.4
4
4
  Summary: Differential Geometry with Complex Variables
5
5
  Author: David Sykes
6
6
  Author-email: David Sykes <david@realandimaginary.com>
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes