DGCV 0.3.1__tar.gz → 0.3.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 (55) hide show
  1. {dgcv-0.3.1/src/dgcv.egg-info → dgcv-0.3.2}/PKG-INFO +1 -1
  2. {dgcv-0.3.1 → dgcv-0.3.2}/pyproject.toml +1 -1
  3. {dgcv-0.3.1 → dgcv-0.3.2}/setup.cfg +1 -1
  4. {dgcv-0.3.1 → dgcv-0.3.2}/setup.py +1 -1
  5. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/CR_geometry.py +20 -8
  6. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/_config.py +1 -1
  7. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/_tensor_field_printers.py +3 -3
  8. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/dgcv_core.py +11 -4
  9. dgcv-0.3.2/src/dgcv/eds/ast.py +158 -0
  10. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/eds/eds.py +97 -35
  11. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/eds/eds_representations.py +10 -2
  12. dgcv-0.3.2/src/dgcv/filtered_structures.py +426 -0
  13. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/finite_dim_algebras.py +128 -185
  14. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/polynomials.py +92 -0
  15. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/solvers.py +3 -0
  16. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/styles.py +64 -5
  17. {dgcv-0.3.1 → dgcv-0.3.2/src/dgcv.egg-info}/PKG-INFO +1 -1
  18. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv.egg-info/SOURCES.txt +1 -0
  19. dgcv-0.3.1/src/dgcv/filtered_structures.py +0 -377
  20. {dgcv-0.3.1 → dgcv-0.3.2}/LICENSE.txt +0 -0
  21. {dgcv-0.3.1 → dgcv-0.3.2}/MANIFEST.in +0 -0
  22. {dgcv-0.3.1 → dgcv-0.3.2}/README.md +0 -0
  23. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/Riemannian_geometry.py +0 -0
  24. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/__init__.py +0 -0
  25. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/_dgcv_display.py +2 -2
  26. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/_safeguards.py +0 -0
  27. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/_settings.py +0 -0
  28. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/__init__.py +0 -0
  29. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Black.ttf +0 -0
  30. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Black.woff2 +0 -0
  31. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Bold.ttf +0 -0
  32. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Bold.woff2 +0 -0
  33. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-ExtraBold.ttf +0 -0
  34. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-ExtraBold.woff2 +0 -0
  35. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Medium.ttf +0 -0
  36. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Medium.woff2 +0 -0
  37. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Regular.ttf +0 -0
  38. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-Regular.woff2 +0 -0
  39. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-SemiBold.ttf +0 -0
  40. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/Orbitron-SemiBold.woff2 +0 -0
  41. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/PatrickHand-Regular.ttf +0 -0
  42. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/assets/fonts/fonts.css +0 -0
  43. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/combinatorics.py +0 -0
  44. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/complex_structures.py +0 -0
  45. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/conversions.py +0 -0
  46. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/coordinate_maps.py +0 -0
  47. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/dgcv_formatter.py +0 -0
  48. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/eds/__init__.py +0 -0
  49. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/eds/eds_operations.py +0 -0
  50. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/tensors.py +0 -0
  51. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/vector_fields_and_differential_forms.py +0 -0
  52. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv/vmf.py +0 -0
  53. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv.egg-info/dependency_links.txt +0 -0
  54. {dgcv-0.3.1 → dgcv-0.3.2}/src/dgcv.egg-info/requires.txt +0 -0
  55. {dgcv-0.3.1 → dgcv-0.3.2}/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.1
3
+ Version: 0.3.2
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.1"
8
+ version = "0.3.2"
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.1
3
+ version = 0.3.2
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.1",
18
+ version="0.3.2",
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",
@@ -43,7 +43,7 @@ from .dgcv_core import (
43
43
  symToReal,
44
44
  variableProcedure,
45
45
  )
46
- from .polynomials import createPolynomial
46
+ from .polynomials import createMultigradedPolynomial
47
47
  from .solvers import solve_dgcv
48
48
  from .vector_fields_and_differential_forms import assembleFromHolVFC
49
49
 
@@ -130,14 +130,20 @@ def weightedHomogeneousVF(
130
130
  NA
131
131
  """
132
132
  pListLoc = []
133
- for j in range(len(arg3)):
133
+ if not isinstance(arg2, (list,tuple)):
134
+ arg2 = [arg2]
135
+ if not isinstance(arg3[0],(list,tuple)):
136
+ arg3 = [arg3]
137
+ if not all(len(weightList)==len(arg1) for weightList in arg3):
138
+ raise KeyError('weight systems given to weightedHomogeneousVF must be lists whose length is the number of variables given.')
139
+ for j in range(len(arg1)):
134
140
  pListLoc.append(
135
- createPolynomial(
141
+ createMultigradedPolynomial(
136
142
  arg4 + "_" + str(j) + "_",
137
- arg2 + arg3[j],
143
+ [d + L[j] for d,L in zip(arg2,arg3)],
138
144
  arg1,
145
+ arg3,
139
146
  degreeCap=degreeCap,
140
- weightedHomogeneity=arg3,
141
147
  _tempVar=_tempVar,
142
148
  assumeReal=assumeReal,
143
149
  report=False
@@ -303,6 +309,12 @@ def findWeightedCRSymmetries(
303
309
  ):
304
310
  """
305
311
  """
312
+ if not isinstance(coordinate_weights[0],(list,tuple)):
313
+ coordinate_weights = [coordinate_weights]
314
+ if not isinstance(symmetry_weight,(list,tuple)):
315
+ symmetry_weight = [symmetry_weight]
316
+ if not len(symmetry_weight)==len(coordinate_weights):
317
+ raise KeyError('`findWeightedCRSymmetries` was given a tuple of weight systems whose length does not match the length of given symmetry weights to test for.')
306
318
  if returnAllformats:
307
319
  returnVectorFieldBasis = True
308
320
  vr = get_variable_registry()
@@ -369,13 +381,13 @@ def findWeightedCRSymmetries(
369
381
 
370
382
  subVar = set()
371
383
  for term in VFCLoc:
372
- subVar |= term.atoms(sp.Symbol)
384
+ if hasattr(term, 'atoms'):
385
+ subVar |= term.atoms(sp.Symbol)
373
386
  subVar.difference_update(set(holomorphic_coordinates))
374
387
  variableProcedure(coeff_label, len(subVar), assumeReal=True)
375
388
  coeff_vars = _cached_caller_globals[coeff_label]
376
389
  VFCLoc = [
377
- j.subs(dict(zip(subVar, coeff_vars)))
378
- for j in VFCLoc
390
+ j.subs(dict(zip(subVar, coeff_vars))) if hasattr(j,'subs') else j for j in VFCLoc
379
391
  ]
380
392
  clearVar(*listVar(temporary_only=True), report=False)
381
393
  if returnVectorFieldBasis:
@@ -186,7 +186,7 @@ variable_registry = {
186
186
  }
187
187
  dgcv_settings_registry = {
188
188
  'use_latex':False,
189
- 'theme':'default',
189
+ 'theme':'blue',
190
190
  'format_displays':False,
191
191
  'version_specific_defaults':f'v{__version__}'
192
192
  }
@@ -138,9 +138,9 @@ def tensor_VS_printer(tp):
138
138
  vec = vec[:len(vec)//2]
139
139
  if scalar != 0:
140
140
  basis_elements = [
141
- f"{_process_var_label(basis_labels[vec[j]])}"
141
+ f"{basis_labels[vec[j]]}"
142
142
  if valence[j] == 1
143
- else f"{_process_var_label(basis_labels[vec[j]])}^''"
143
+ else f"{basis_labels[vec[j]]}^''"
144
144
  for j in range(len(valence))
145
145
  ]
146
146
  basis_element = '@'.join(basis_elements)
@@ -148,7 +148,7 @@ def tensor_VS_printer(tp):
148
148
 
149
149
  if not formatted_terms: # If all scalars are zero
150
150
  basis_elements = [
151
- f"{_process_var_label(basis_labels[vec[j]])}"
151
+ f"{basis_labels[vec[j]]}"
152
152
  for j in range(tp.max_degree)
153
153
  ]
154
154
  formatted_terms.append(f"0{'@'.join(basis_elements)}")
@@ -1322,13 +1322,11 @@ class VFClass(tensorField):
1322
1322
  if len(varSpace) != len(coeffs):
1323
1323
  raise ValueError("`varSpace` and `coeffs` must have the same length.")
1324
1324
 
1325
- # Convert coeffs to coeff_dict
1326
1325
  coeff_dict = {(i,): coeff for i, coeff in enumerate(coeffs)}
1327
1326
 
1328
- # Set valence for vector field (degree 1 contravariant tensor)
1327
+ # Set valence degree 1 for contravariant tensor
1329
1328
  valence = (1,)
1330
1329
 
1331
- # Call the parent class's __new__ with data_shape="skew"
1332
1330
  return super().__new__(
1333
1331
  cls,
1334
1332
  varSpace=varSpace,
@@ -1469,6 +1467,16 @@ class VFClass(tensorField):
1469
1467
  def __mul__(self, scalar):
1470
1468
  return scaleVF(scalar, self)
1471
1469
 
1470
+ def __truediv__(self, scalar):
1471
+ if isinstance(scalar, float):
1472
+ inverse = 1 / scalar
1473
+ elif isinstance(scalar, (int,sp.Expr)):
1474
+ inverse = sp.Rational(1, scalar)
1475
+ else:
1476
+ return NotImplemented
1477
+
1478
+ return scaleVF(inverse, self)
1479
+
1472
1480
  def __rmul__(self, scalar):
1473
1481
  return scaleVF(scalar, self)
1474
1482
 
@@ -4427,7 +4435,6 @@ def VF_coeffs(vf, var_list, sparse=False):
4427
4435
  final_vs += vs[:1]
4428
4436
  vs = vs[1:]
4429
4437
  else:
4430
- startLen = len(vs)
4431
4438
  relatives = []
4432
4439
  for parent in variable_registry['complex_variable_systems'].values():
4433
4440
  if relatives == []:
@@ -0,0 +1,158 @@
1
+ # src/dgcv/eds/ast.py
2
+
3
+ import sympy as sp
4
+
5
+ from .eds import abstDFAtom, abstract_ZF
6
+
7
+ _math_functions_registry = {
8
+ 'sub': {
9
+ 'arguments': 2,
10
+ 'derivative': None,
11
+ 'simplify': lambda expr: expr, # placeholder
12
+ 'latex': lambda args: f"{args[0]} - {args[1]}"
13
+ },
14
+ 'log': {
15
+ 'arguments': 1,
16
+ 'derivative': lambda arg: 1 / arg,
17
+ 'simplify': lambda expr: expr,
18
+ 'latex': lambda args: f"\\log\\left({args[0]}\\right)"
19
+ },
20
+ 'sin': {
21
+ 'arguments': 1,
22
+ 'derivative': lambda arg: dgcv_AST_assembler('cos', arg),
23
+ 'simplify': lambda expr: expr,
24
+ 'latex': lambda args: f"\\sin\\left({args[0]}\\right)"
25
+ },
26
+ }
27
+
28
+ def dgcv_AST_assembler(func_name, *args):
29
+ """
30
+ Constructs an abstract syntax tree node representing a symbolic function call.
31
+
32
+ Parameters:
33
+ func_name (str): The function name (must be in _math_functions_registry).
34
+ *args: Positional arguments to the symbolic function.
35
+
36
+ Returns:
37
+ tuple: An AST node represented as (func_name, *args).
38
+ """
39
+ if func_name not in _math_functions_registry:
40
+ raise ValueError(f"Function '{func_name}' is not registered in _math_functions_registry.")
41
+
42
+ expected_arity = _math_functions_registry[func_name]['arguments']
43
+ if len(args) != expected_arity:
44
+ raise ValueError(f"Function '{func_name}' expects {expected_arity} argument(s), got {len(args)}.")
45
+
46
+ return abstract_ZF((func_name, *args))
47
+
48
+
49
+
50
+ def _add_ID(base):
51
+ # remove zero terms: 0 + x → x
52
+ if isinstance(base, tuple) and base[0] == "add":
53
+ args = [arg for arg in base[1:] if arg != 0]
54
+ if not args:
55
+ return 0
56
+ if len(args) == 1:
57
+ return args[0]
58
+ return tuple(["add"] + args)
59
+ return base
60
+
61
+ def _add_flatten(base):
62
+ # flatten nested adds: add(add(a,b),c) → add(a,b,c)
63
+ if isinstance(base, tuple) and base[0] == "add":
64
+ new_args = []
65
+ for arg in base[1:]:
66
+ if isinstance(arg, tuple) and arg[0] == "add":
67
+ new_args.extend(arg[1:])
68
+ else:
69
+ new_args.append(arg)
70
+ return tuple(["add"] + new_args)
71
+ return base
72
+
73
+ def _mul_ID(base):
74
+ # remove ones: 1 * x → x
75
+ if isinstance(base, tuple) and base[0] == "mul":
76
+ args = [arg for arg in base[1:] if arg != 1]
77
+ if not args:
78
+ return 1
79
+ if len(args) == 1:
80
+ return args[0]
81
+ return tuple(["mul"] + args)
82
+ return base
83
+
84
+ def _mul_zero(base):
85
+ # zero annihilator: 0 * x → 0
86
+ if isinstance(base, tuple) and base[0] == "mul":
87
+ if any(arg == 0 for arg in base[1:]):
88
+ return 0
89
+ return base
90
+
91
+ def _pow_one(base):
92
+ # x**1 → x
93
+ if isinstance(base, tuple) and base[0] == "pow":
94
+ _, b, e = base
95
+ if e == 1:
96
+ return b
97
+ return base
98
+
99
+ def _pow_zero(base):
100
+ # x**0 → 1
101
+ if isinstance(base, tuple) and base[0] == "pow":
102
+ _, b, e = base
103
+ if e == 0:
104
+ return 1
105
+ return base
106
+
107
+ _simplification_rules_registry = {
108
+ # Additive normalizations
109
+ "a1": _add_ID,
110
+ "a2": _add_flatten,
111
+ # Multiplicative normalizations
112
+ "m1": _mul_ID,
113
+ "m2": _mul_zero,
114
+ # Power rules
115
+ "p1": _pow_one,
116
+ "p2": _pow_zero,
117
+ }
118
+
119
+ class abstract_ZF_test(sp.Basic):
120
+ """
121
+ Experimental version of abstract_ZF supporting a symbolic function registry and planned simplification logic.
122
+ """
123
+ def __new__(cls, base):
124
+ if base is None or base == list() or base == tuple():
125
+ base = 0
126
+ if isinstance(base, list):
127
+ base = tuple(base)
128
+ if isinstance(base, abstract_ZF_test):
129
+ base = base.base
130
+ if isinstance(base, abstDFAtom) and base.degree == 0:
131
+ base = base.coeff
132
+ if isinstance(base, tuple):
133
+ op, *args = base
134
+ new_args = []
135
+ for arg in args:
136
+ if isinstance(arg, abstDFAtom) and arg.degree == 0:
137
+ new_args.append(arg.coeff)
138
+ elif isinstance(arg, abstract_ZF_test):
139
+ new_args.append(arg.base)
140
+ else:
141
+ new_args.append(arg)
142
+ return sp.Basic.__new__(cls, (op, *new_args))
143
+ return sp.Basic.__new__(cls, base)
144
+
145
+ def __init__(self, base):
146
+ self.base = base
147
+
148
+ def _repr_latex_(self):
149
+ return f"${self._latex(self.base)}$"
150
+
151
+ def _latex(self, expr):
152
+ if isinstance(expr, tuple):
153
+ op, *args = expr
154
+ if op in _math_functions_registry and "latex" in _math_functions_registry[op]:
155
+ latex_func = _math_functions_registry[op]["latex"]
156
+ return latex_func([self._latex(arg) for arg in args])
157
+ return f"{op}({', '.join(map(self._latex, args))})"
158
+ return sp.latex(expr)
@@ -34,7 +34,6 @@ def expand_dgcv(expr, **kw):
34
34
 
35
35
  return sp.expand(expr, **kw) if isinstance(expr, sp.Basic) else expr
36
36
 
37
-
38
37
  @total_ordering
39
38
  class SortableObj:
40
39
  def __init__(self, pair: tuple):
@@ -256,26 +255,47 @@ class zeroFormAtom(sp.Basic):
256
255
 
257
256
  def __truediv__(self, other):
258
257
  """
259
- Division of zeroFormAtom:
260
- - Returns a structured `abstract_ZF` division.
258
+ Division with zeroFormAtom
261
259
  """
262
260
  if isinstance(other, (zeroFormAtom, int, float, sp.Expr)):
263
261
  return abstract_ZF(("div", self, other))
264
262
  return NotImplemented
265
263
 
264
+ def __rtruediv__(self, other):
265
+ """
266
+ Division with zeroFormAtom instances
267
+ """
268
+ if isinstance(other, (int, float, sp.Expr, zeroFormAtom, abstract_ZF)):
269
+ return abstract_ZF(("div", other, self))
270
+
271
+ return NotImplemented
272
+
273
+
266
274
  def __pow__(self, exp):
267
275
  """
268
276
  Exponentiation of zeroFormAtom:
269
277
  - Returns a structured `abstract_ZF` exponentiation.
270
278
  """
271
279
  if isinstance(exp, (int, float, sp.Expr, zeroFormAtom, abstract_ZF)):
272
- return abstract_ZF(('pow',self,exp))
280
+ return abstract_ZF(('pow', self, exp))
281
+ return NotImplemented
282
+
283
+ def __rpow__(self, other):
284
+ if isinstance(other, (int, float, sp.Expr, zeroFormAtom, abstract_ZF)):
285
+ return abstract_ZF(("pow", other, self))
286
+
273
287
  return NotImplemented
274
288
 
275
289
  def __add__(self, other):
276
290
  """
277
- Addition of zeroFormAtom:
278
- - Returns a structured `abstract_ZF` addition.
291
+ Addition with zeroFormAtom
292
+ """
293
+ if isinstance(other, (zeroFormAtom, int, float, sp.Expr, abstract_ZF)):
294
+ return abstract_ZF(("add", self, other))
295
+ return NotImplemented
296
+ def __radd__(self, other):
297
+ """
298
+ Addition with zeroFormAtom
279
299
  """
280
300
  if isinstance(other, (zeroFormAtom, int, float, sp.Expr, abstract_ZF)):
281
301
  return abstract_ZF(("add", self, other))
@@ -284,11 +304,17 @@ class zeroFormAtom(sp.Basic):
284
304
  def __sub__(self, other):
285
305
  """
286
306
  Subtraction of zeroFormAtom:
287
- - Returns a structured `abstract_ZF` subtraction.
288
307
  """
289
308
  if isinstance(other, (zeroFormAtom, int, float, sp.Expr, abstract_ZF)):
290
309
  return abstract_ZF(("sub", self, other))
291
310
  return NotImplemented
311
+ def __rsub__(self, other):
312
+ """
313
+ Subtraction of zeroFormAtom
314
+ """
315
+ if isinstance(other, (zeroFormAtom, int, float, sp.Expr, abstract_ZF)):
316
+ return abstract_ZF(("sub", other, self))
317
+ return NotImplemented
292
318
 
293
319
  def _canonicalize_step(self):
294
320
  for count,elem in enumerate(self.coframe_derivatives):
@@ -754,7 +780,6 @@ class abstract_ZF(sp.Basic):
754
780
  return (th,obj.label)
755
781
  else:
756
782
  return (th,th)
757
-
758
783
  def is_zero_check(x):
759
784
  """Helper function to check if x is zero."""
760
785
  return x == 0 or x == 0.0 or (hasattr(x, "is_zero") and x.is_zero)
@@ -1002,6 +1027,9 @@ class abstract_ZF(sp.Basic):
1002
1027
  def sub_process(arg,sub_data):
1003
1028
  if isinstance(arg,tuple):
1004
1029
  arg = abstract_ZF(arg)
1030
+ if isinstance(arg, abstDFAtom) and arg.degree==0: ###!!!
1031
+ arg = arg.coeff
1032
+ warnings.warn('DEGUB8493')
1005
1033
  if isinstance(arg, (zeroFormAtom,abstract_ZF)):
1006
1034
  newArg = arg.subs(sub_data,with_diff_corollaries=with_diff_corollaries)
1007
1035
  if isinstance(newArg,abstDFAtom):
@@ -1029,9 +1057,6 @@ class abstract_ZF(sp.Basic):
1029
1057
  else:
1030
1058
  raise ValueError('dgcv subs methods do not support replacing 0-forms with higher degree forms.')
1031
1059
  return arg
1032
- if isinstance(arg, abstDFAtom) and arg.degree==0: ###!!!
1033
- arg += [arg.coeff]
1034
- warnings.warn('DEGUB8493')
1035
1060
  return arg
1036
1061
  new_base = tuple([op]+[sub_process(arg,data) for arg in args])
1037
1062
  return _loop_ZF_format_conversions(abstract_ZF(new_base))
@@ -1144,10 +1169,9 @@ class abstract_ZF(sp.Basic):
1144
1169
  def __rpow__(self, other):
1145
1170
  """
1146
1171
  Exponentiation of abstract_ZF instances.
1147
- Supports exponentiation with int, float, and sympy.Expr.
1148
1172
  """
1149
1173
  if isinstance(other, (int, float, sp.Expr, zeroFormAtom, abstract_ZF)):
1150
- return abstract_ZF(("pow", self, other))
1174
+ return abstract_ZF(("pow", other, self))
1151
1175
 
1152
1176
  return NotImplemented
1153
1177
 
@@ -1454,6 +1478,8 @@ class abstract_ZF(sp.Basic):
1454
1478
  count += 1
1455
1479
  return zf
1456
1480
 
1481
+
1482
+
1457
1483
  class abstDFAtom(sp.Basic):
1458
1484
 
1459
1485
  def __new__(cls, coeff, degree, label=None, ext_deriv_order=0, _markers=frozenset()):
@@ -1790,29 +1816,65 @@ def createDiffForm(labels, degree, number_of_variables=None, initialIndex=1, ass
1790
1816
  - assumeReal (bool, optional): If True, marks instances as real and skips conjugate handling.
1791
1817
  - remove_guardrails (None, optional): If set, bypasses safeguards for label validation.
1792
1818
  """
1793
- if not isinstance(labels, str):
1794
- raise TypeError(
1795
- "`createDiffForm` requires its first argument to be a string, which will be used in lables for the created DF."
1796
- )
1797
- def reformat_string(input_string: str):
1798
- # Replace commas with spaces, then split on spaces
1799
- substrings = input_string.replace(",", " ").split()
1800
- # Return the list of non-empty substrings
1801
- return [s for s in substrings if len(s) > 0]
1802
-
1803
- if isinstance(labels, str):
1804
- labels = reformat_string(labels)
1805
- if return_obj is True:
1806
- returnList = []
1807
- for label in labels:
1808
- if return_obj is True:
1809
- returnList.append(_DFFactory(label,degree, number_of_variables=number_of_variables, initialIndex=initialIndex, assumeReal=assumeReal, remove_guardrails=remove_guardrails,return_obj=True))
1819
+ if isinstance(labels,(list,tuple)):
1820
+ if len(set(labels))<len(labels):
1821
+ raise NameError('`createDiffForm` was given the same label repeatedly. Labels need to be distinct.')
1822
+ if isinstance(degree,(list,tuple)):
1823
+ if len(degree)<len(labels):
1824
+ degree = list(degree)+([degree[-1]]*(len(labels)-len(degree)))
1825
+ else:
1826
+ degree = [degree]*len(labels)
1827
+ if isinstance(number_of_variables,(list,tuple)):
1828
+ if len(number_of_variables)<len(labels):
1829
+ number_of_variables = list(number_of_variables)+([number_of_variables[-1]]*(len(labels)-len(number_of_variables)))
1830
+ else:
1831
+ number_of_variables = [number_of_variables]*len(labels)
1832
+ if isinstance(initialIndex,(list,tuple)):
1833
+ if len(initialIndex)<len(labels):
1834
+ initialIndex = list(initialIndex)+([initialIndex[-1]]*(len(labels)-len(initialIndex)))
1835
+ else:
1836
+ initialIndex = [initialIndex]*len(labels)
1837
+ if isinstance(assumeReal,(list,tuple)):
1838
+ if len(assumeReal)<len(labels):
1839
+ assumeReal = list(assumeReal)+([assumeReal[-1]]*(len(labels)-len(assumeReal)))
1810
1840
  else:
1811
- _DFFactory(label,degree, number_of_variables=number_of_variables, initialIndex=initialIndex, assumeReal=assumeReal, remove_guardrails=remove_guardrails)
1812
- if return_obj is True:
1813
- if len(returnList)==1:
1814
- return returnList[0]
1815
- return returnList
1841
+ assumeReal = [assumeReal]*len(labels)
1842
+ if isinstance(remove_guardrails,(list,tuple)):
1843
+ if len(remove_guardrails)<len(labels):
1844
+ remove_guardrails = list(remove_guardrails)+([remove_guardrails[-1]]*(len(labels)-len(remove_guardrails)))
1845
+ else:
1846
+ remove_guardrails = [remove_guardrails]*len(labels)
1847
+ if isinstance(return_obj,(list,tuple)):
1848
+ if len(return_obj)<len(labels):
1849
+ return_obj = list(return_obj)+([return_obj[-1]]*(len(labels)-len(return_obj)))
1850
+ else:
1851
+ return_obj = [return_obj]*len(labels)
1852
+ for idx in range(len(labels)):
1853
+ createDiffForm(labels[idx],degree[idx],number_of_variables[idx],initialIndex[idx],assumeReal[idx],remove_guardrails[idx],return_obj[idx])
1854
+ else:
1855
+ if not isinstance(labels, str):
1856
+ raise TypeError(
1857
+ "`createDiffForm` requires its first argument to be a string, which will be used in lables for the created DF."
1858
+ )
1859
+ def reformat_string(input_string: str):
1860
+ # Replace commas with spaces, then split on spaces
1861
+ substrings = input_string.replace(",", " ").split()
1862
+ # Return the list of non-empty substrings
1863
+ return [s for s in substrings if len(s) > 0]
1864
+
1865
+ if isinstance(labels, str):
1866
+ labels = reformat_string(labels)
1867
+ if return_obj is True:
1868
+ returnList = []
1869
+ for label in labels:
1870
+ if return_obj is True:
1871
+ returnList.append(_DFFactory(label,degree, number_of_variables=number_of_variables, initialIndex=initialIndex, assumeReal=assumeReal, remove_guardrails=remove_guardrails,return_obj=True))
1872
+ else:
1873
+ _DFFactory(label,degree, number_of_variables=number_of_variables, initialIndex=initialIndex, assumeReal=assumeReal, remove_guardrails=remove_guardrails)
1874
+ if return_obj is True:
1875
+ if len(returnList)==1:
1876
+ return returnList[0]
1877
+ return returnList
1816
1878
 
1817
1879
  def _DFFactory(label,degree, number_of_variables=None, initialIndex=1, assumeReal=False, _tempVar=None, _doNotUpdateVar=None, remove_guardrails=None,return_obj = False):
1818
1880
  """
@@ -134,13 +134,21 @@ class DF_representation(sp.Basic):
134
134
  def flatten(self):
135
135
  return [entry for entry in self]
136
136
 
137
+ @property
138
+ def free_symbols(self):
139
+ fs_set = set()
140
+ for entry in self:
141
+ if hasattr(entry,'free_symbols'):
142
+ fs_set = fs_set | entry.free_symbols
143
+ return fs_set
144
+
137
145
  def _latex(self,printer=None):
138
146
  rows = []
139
147
  for row in self.array:
140
148
  rendered_row = []
141
149
  for entry in row:
142
150
  if hasattr(entry, "_latex"):
143
- latex = entry._latex()
151
+ latex = sp.latex(entry)
144
152
  else:
145
153
  latex = str(entry)
146
154
  rendered_row.append(latex)
@@ -153,7 +161,7 @@ class DF_representation(sp.Basic):
153
161
  rendered_row = []
154
162
  for entry in row:
155
163
  if hasattr(entry, "_latex"):
156
- latex = entry._latex()
164
+ latex = sp.latex(entry)
157
165
  else:
158
166
  latex = str(entry)
159
167
  rendered_row.append(latex)