prefig 0.4.1.dev20250803054516__py3-none-any.whl → 0.4.3.dev20250823053253__py3-none-any.whl
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.
- prefig/core/axes.py +7 -4
- prefig/core/parametric_curve.py +15 -3
- prefig/core/point.py +11 -1
- prefig/core/utilities.py +4 -1
- prefig/resources/schema/pf_schema.rnc +3 -0
- prefig/resources/schema/pf_schema.rng +787 -2223
- {prefig-0.4.1.dev20250803054516.dist-info → prefig-0.4.3.dev20250823053253.dist-info}/METADATA +1 -1
- {prefig-0.4.1.dev20250803054516.dist-info → prefig-0.4.3.dev20250823053253.dist-info}/RECORD +11 -11
- {prefig-0.4.1.dev20250803054516.dist-info → prefig-0.4.3.dev20250823053253.dist-info}/LICENSE +0 -0
- {prefig-0.4.1.dev20250803054516.dist-info → prefig-0.4.3.dev20250823053253.dist-info}/WHEEL +0 -0
- {prefig-0.4.1.dev20250803054516.dist-info → prefig-0.4.3.dev20250823053253.dist-info}/entry_points.txt +0 -0
prefig/core/axes.py
CHANGED
|
@@ -571,7 +571,7 @@ class Axes():
|
|
|
571
571
|
xlabel.set('scale', '0.8')
|
|
572
572
|
else:
|
|
573
573
|
#math_element.text = r'\text{'+'{0:g}'.format(x)+'}'
|
|
574
|
-
math_element.text = label_text(x, commas)
|
|
574
|
+
math_element.text = label_text(x, commas, diagram)
|
|
575
575
|
if self.h_pi_format:
|
|
576
576
|
math_element.text = get_pi_text(x)
|
|
577
577
|
|
|
@@ -680,7 +680,7 @@ class Axes():
|
|
|
680
680
|
ylabel.set('scale', '0.8')
|
|
681
681
|
else:
|
|
682
682
|
#math_element.text = r'\text{'+'{0:g}'.format(y)+'}'
|
|
683
|
-
math_element.text = label_text(y, commas)
|
|
683
|
+
math_element.text = label_text(y, commas, diagram)
|
|
684
684
|
if self.v_pi_format:
|
|
685
685
|
math_element.text = get_pi_text(y)
|
|
686
686
|
# process as a math number
|
|
@@ -712,7 +712,7 @@ class Axes():
|
|
|
712
712
|
user_coords=False)
|
|
713
713
|
self.v_tick_group.append(line_el)
|
|
714
714
|
|
|
715
|
-
def label_text(x, commas):
|
|
715
|
+
def label_text(x, commas, diagram):
|
|
716
716
|
# we'll construct a text representation of x
|
|
717
717
|
# maybe it's simple
|
|
718
718
|
if x < 0:
|
|
@@ -741,13 +741,16 @@ def label_text(x, commas):
|
|
|
741
741
|
return r'\text{' + prefix + text + r'}'
|
|
742
742
|
|
|
743
743
|
period = text.find('.')
|
|
744
|
+
comma_include = '{,}'
|
|
745
|
+
if diagram.get_environment() == 'pyodide':
|
|
746
|
+
comma_include = ','
|
|
744
747
|
if period < 0:
|
|
745
748
|
suffix = ''
|
|
746
749
|
else:
|
|
747
750
|
suffix = text[period:]
|
|
748
751
|
text = text[:period]
|
|
749
752
|
while len(text) > 3:
|
|
750
|
-
suffix =
|
|
753
|
+
suffix = comma_include + text[-3:] + suffix
|
|
751
754
|
text = text[:-3]
|
|
752
755
|
text = text + suffix
|
|
753
756
|
return r'\text{' + prefix + text + r'}'
|
prefig/core/parametric_curve.py
CHANGED
|
@@ -24,8 +24,9 @@ def parametric_curve(element, diagram, parent, outline_status):
|
|
|
24
24
|
log.error(f"Error in <parametric-curve> defining domain={element.get('domain')}")
|
|
25
25
|
return
|
|
26
26
|
|
|
27
|
-
|
|
27
|
+
arrows = int(element.get('arrows', '0'))
|
|
28
28
|
|
|
29
|
+
N = int(element.get('N', '100'))
|
|
29
30
|
t = domain[0]
|
|
30
31
|
dt = (domain[1]-domain[0])/N
|
|
31
32
|
p = diagram.transform(f(t))
|
|
@@ -34,8 +35,21 @@ def parametric_curve(element, diagram, parent, outline_status):
|
|
|
34
35
|
t += dt
|
|
35
36
|
p = diagram.transform(f(t))
|
|
36
37
|
points.append('L ' + util.pt2str(p))
|
|
38
|
+
|
|
37
39
|
if element.get('closed', 'no') == 'yes':
|
|
38
40
|
points.append('Z')
|
|
41
|
+
|
|
42
|
+
if arrows > 0 and element.get('arrow-location', None) is not None:
|
|
43
|
+
arrow_location = un.valid_eval(element.get('arrow-location'))
|
|
44
|
+
num_pts = 5
|
|
45
|
+
t = arrow_location - num_pts*dt
|
|
46
|
+
p = diagram.transform(f(t))
|
|
47
|
+
points.append('M ' + util.pt2str(p))
|
|
48
|
+
for _ in range(num_pts):
|
|
49
|
+
t += dt
|
|
50
|
+
p = diagram.transform(f(t))
|
|
51
|
+
points.append('L ' + util.pt2str(p))
|
|
52
|
+
|
|
39
53
|
d = ' '.join(points)
|
|
40
54
|
|
|
41
55
|
if diagram.output_format() == 'tactile':
|
|
@@ -51,12 +65,10 @@ def parametric_curve(element, diagram, parent, outline_status):
|
|
|
51
65
|
diagram.add_id(path, element.get('id'))
|
|
52
66
|
path.set('d', d)
|
|
53
67
|
util.add_attr(path, util.get_2d_attr(element))
|
|
54
|
-
# path.set('type', 'parametric curve')
|
|
55
68
|
|
|
56
69
|
element.set('cliptobbox', element.get('cliptobbox', 'yes'))
|
|
57
70
|
util.cliptobbox(path, element, diagram)
|
|
58
71
|
|
|
59
|
-
arrows = int(element.get('arrows', '0'))
|
|
60
72
|
forward = 'marker-end'
|
|
61
73
|
backward = 'marker-start'
|
|
62
74
|
if element.get('reverse', 'no') == 'yes':
|
prefig/core/point.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import lxml.etree as ET
|
|
2
2
|
import logging
|
|
3
|
+
import numpy as np
|
|
4
|
+
import math
|
|
3
5
|
from . import user_namespace as un
|
|
4
6
|
from . import math_utilities as math_util
|
|
5
7
|
from . import utilities as util
|
|
@@ -18,7 +20,15 @@ def point(element, diagram, parent, outline_status = None):
|
|
|
18
20
|
|
|
19
21
|
# determine the location and size of the point from the XML element
|
|
20
22
|
try:
|
|
21
|
-
p =
|
|
23
|
+
p = un.valid_eval(element.get('p'))
|
|
24
|
+
if element.get('coordinates', 'cartesian') == 'polar':
|
|
25
|
+
radial = p[0]
|
|
26
|
+
angle = p[1]
|
|
27
|
+
if element.get('degrees', 'no') == 'yes':
|
|
28
|
+
angle = math.radians(angle)
|
|
29
|
+
p = radial * np.array([math.cos(angle), math.sin(angle)])
|
|
30
|
+
element.set('p', util.pt2long_str(p, spacer=','))
|
|
31
|
+
p = diagram.transform(p)
|
|
22
32
|
except:
|
|
23
33
|
log.error(f"Error in <point> defining p={element.get('p')}")
|
|
24
34
|
return
|
prefig/core/utilities.py
CHANGED
|
@@ -2,6 +2,9 @@ import numpy as np
|
|
|
2
2
|
from . import user_namespace as un
|
|
3
3
|
from . import label
|
|
4
4
|
|
|
5
|
+
import logging
|
|
6
|
+
logger = logging.getLogger('prefigure')
|
|
7
|
+
|
|
5
8
|
import warnings
|
|
6
9
|
with warnings.catch_warnings():
|
|
7
10
|
warnings.filterwarnings('ignore', 'legacy print')
|
|
@@ -25,7 +28,7 @@ def get_attr(element, attr, default):
|
|
|
25
28
|
try:
|
|
26
29
|
attribute = un.valid_eval(element.get(attr, default))
|
|
27
30
|
if isinstance(attribute, np.ndarray):
|
|
28
|
-
return
|
|
31
|
+
return ','.join([float2longstr(a) for a in attribute])
|
|
29
32
|
return str(attribute)
|
|
30
33
|
except (TypeError, SyntaxError): # this is a string that's not in the namespace
|
|
31
34
|
return element.get(attr, default)
|
|
@@ -641,6 +641,7 @@ Parametric-Curve = element parametric-curve {
|
|
|
641
641
|
attribute N {text}?,
|
|
642
642
|
attribute closed {"yes"|"no"}?,
|
|
643
643
|
attribute arrows {text}?,
|
|
644
|
+
attribute arrow-location {text}?,
|
|
644
645
|
attribute arrow-width {text}?,
|
|
645
646
|
attribute arrow-angles {text}?,
|
|
646
647
|
attribute reverse {"yes"|"no"}?,
|
|
@@ -685,6 +686,8 @@ Point = element point {
|
|
|
685
686
|
attribute at {text}?,
|
|
686
687
|
attribute style {text}?,
|
|
687
688
|
attribute size {text}?,
|
|
689
|
+
attribute coordinates {"cartesian"|"polar"}?,
|
|
690
|
+
attribute degrees {"yes"|"no"}?,
|
|
688
691
|
LabelAttributes,
|
|
689
692
|
FillAttributes,
|
|
690
693
|
CommonAttributes,
|