prefig 0.5.0__py3-none-any.whl → 0.5.2__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.
@@ -33,14 +33,20 @@ def annotate(element, diagram, parent = None):
33
33
  parent = diagram.get_annotations_root()
34
34
 
35
35
  if element.get('ref', None) is not None:
36
- element.set('id', element.get('ref'))
36
+ ref = element.get('ref')
37
+ if not ref.startswith('pf__'):
38
+ ref = 'pf__' + ref
39
+ element.set('id', ref)
37
40
  element.attrib.pop('ref')
38
41
  else:
39
42
  log.info(f"An annotation has an empty attribute ref")
40
43
  element.attrib.pop('annotate', None)
41
44
 
42
45
  # let's check to see if this is a reference to an annotation branch
43
- annotation = diagram.get_annotation_branch(element.get('id'))
46
+ id = element.get('id')
47
+ if not id.startswith('pf__'):
48
+ id = 'pf__' + id
49
+ annotation = diagram.get_annotation_branch(id)
44
50
  if annotation is not None:
45
51
  annotate(annotation, diagram, parent)
46
52
  return
prefig/core/arrow.py CHANGED
@@ -22,7 +22,7 @@ def add_tactile_arrowhead_marker(diagram, path, mid=False):
22
22
  # get the stroke width from the graphical component
23
23
  stroke_width_str = path.get('stroke-width', '1')
24
24
  stroke_width = int(stroke_width_str)
25
- id = 'arrow-head-'+stroke_width_str
25
+ id = 'pf__arrow-head-'+stroke_width_str
26
26
 
27
27
  # if we've seen this already, there's no need to create it again
28
28
  if diagram.has_reusable(id):
@@ -180,12 +180,12 @@ def add_arrowhead_marker(diagram,
180
180
  # end or in the middle of a path
181
181
  id_data = f"_{arrow_width}_{arrow_angles[0]}_{arrow_angles[1]}"
182
182
  if not mid:
183
- id = 'arrow-head-end-'+stroke_width_str+id_data+'-'+stroke_color
183
+ id = 'pf__arrow-head-end-'+stroke_width_str+id_data+'-'+stroke_color
184
184
  if arrow_width is None:
185
185
  arrow_width = 4
186
186
  dims = (1, arrow_width)
187
187
  else:
188
- id = 'arrow-head-mid-'+stroke_width_str+id_data+'-'+stroke_color
188
+ id = 'pf__arrow-head-mid-'+stroke_width_str+id_data+'-'+stroke_color
189
189
  if arrow_width is None:
190
190
  arrow_width = 13/3
191
191
  dims = (1, arrow_width) #11/3)
prefig/core/axes.py CHANGED
@@ -147,7 +147,7 @@ class Axes():
147
147
 
148
148
  self.axes = ET.SubElement(parent, 'g',
149
149
  attrib={
150
- 'id': element.get('id', 'axes'),
150
+ 'id': element.get('id', 'pf__axes'),
151
151
  'stroke': self.stroke,
152
152
  'stroke-width': self.thickness
153
153
  }
prefig/core/clip.py CHANGED
@@ -18,7 +18,7 @@ def clip(element, diagram, parent, outline_status):
18
18
 
19
19
  clip = ET.Element('clipPath')
20
20
  clip.append(shape)
21
- clip_id = 'clip-'+shape_ref
21
+ clip_id = shape_ref + '-clip'
22
22
  clip.set('id', clip_id)
23
23
 
24
24
  diagram.add_reusable(clip)
prefig/core/diagram.py CHANGED
@@ -60,7 +60,7 @@ class Diagram:
60
60
  self.root = ET.Element("svg", nsmap = nsmap)
61
61
 
62
62
  self.id_suffix = ['']
63
- self.add_id(self.root, diagram_element.get('id', 'diagram'))
63
+ self.add_id(self.root, diagram_element.get('id', 'pf__figure'))
64
64
 
65
65
  # prepare the XML tree for annotations, if there are any
66
66
  self.annotations_root = None
@@ -195,9 +195,12 @@ class Diagram:
195
195
  suffix = ''.join(self.id_suffix)
196
196
  if id is None:
197
197
  self.ids[element.tag] = self.ids.get(element.tag, -1) + 1
198
- return element.tag+'-'+str(self.ids[element.tag])+suffix
198
+ result_id = element.tag+'-'+str(self.ids[element.tag])+suffix
199
199
  else:
200
- return id + suffix
200
+ result_id = id + suffix
201
+ if result_id.startswith('pf__'):
202
+ return result_id
203
+ return 'pf__' + result_id
201
204
 
202
205
  def append_id_suffix(self, element):
203
206
  return self.find_id(element, element.get('id', None))
@@ -671,10 +674,16 @@ class Diagram:
671
674
 
672
675
  def add_annotation_to_branch(self, annotation):
673
676
  if len(self.annotation_branch_stack) == 0:
674
- self.annotation_branches[annotation.get('id')] = annotation
677
+ id = annotation.get('id')
678
+ if not id.startswith('pf__'):
679
+ id = 'pf__' + id
680
+ self.annotation_branches[id] = annotation
675
681
  return
676
682
  self.annotation_branch_stack[-1].append(annotation)
677
- annotation.set('id', self.append_id_suffix(annotation))
683
+ id = self.append_id_suffix(annotation)
684
+ if not id.startswith('pf__'):
685
+ id = 'pf__' + id
686
+ annotation.set('id', id)
678
687
 
679
688
  def get_annotation_branch(self, id):
680
689
  return self.annotation_branches.pop(id, None)
prefig/core/grid_axes.py CHANGED
@@ -120,9 +120,14 @@ def grid(element, diagram, parent, outline_status):
120
120
 
121
121
  thickness = element.get('thickness', '1')
122
122
  stroke = element.get('stroke', r'#ccc')
123
+ id = element.get('id')
124
+ if id is None:
125
+ id = 'pf__grid'
126
+ if not id.startswith('pf__'):
127
+ id = 'pf__' + id
123
128
  grid = ET.SubElement(parent, 'g',
124
129
  attrib={
125
- 'id': element.get('id', 'grid'),
130
+ 'id': id,
126
131
  'stroke': stroke,
127
132
  'stroke-width': thickness
128
133
  }
@@ -268,27 +273,27 @@ def grid_axes(element, diagram, parent, outline_status):
268
273
  group = ET.SubElement(parent, 'g',
269
274
  attrib=
270
275
  {
271
- 'id': 'grid-axes'
276
+ 'id': 'pf__grid-axes'
272
277
  }
273
278
  )
274
279
 
275
280
  group_annotation = ET.Element('annotation')
276
- group_annotation.set('ref', 'grid-axes')
281
+ group_annotation.set('ref', 'pf__grid-axes')
277
282
  group_annotation.set('text', 'The coordinate grid and axes')
278
283
  diagram. add_default_annotation(group_annotation)
279
284
 
280
285
  grid(element, diagram, group, outline_status)
281
286
 
282
287
  annotation = ET.Element('annotation')
283
- annotation.set('ref', 'grid')
288
+ annotation.set('ref', 'pf__grid')
284
289
  annotation.set('text', 'The coordinate grid')
285
290
  group_annotation.append(annotation)
286
291
 
287
- element.set('id', 'axes')
292
+ element.set('id', 'pf__axes')
288
293
  axes.axes(element, diagram, group, outline_status)
289
294
 
290
295
  annotation = ET.Element('annotation')
291
- annotation.set('ref', 'axes')
296
+ annotation.set('ref', 'pf__axes')
292
297
  annotation.set('text', 'The coordinate axes')
293
298
  group_annotation.append(annotation)
294
299
 
prefig/core/legend.py CHANGED
@@ -64,7 +64,7 @@ class Legend:
64
64
  # first we'll create the label
65
65
  label_el = copy.deepcopy(li)
66
66
  label_el.tag = 'label'
67
- label_el.set('id', f"legend-label-{num}")
67
+ label_el.set('id', f"pf__legend-label-{num}")
68
68
  label_el.set('alignment', 'se')
69
69
  label_el.set('anchor', element.get('anchor', anchor_str))
70
70
  label_el.set('abs-offset', '(0,0)')
@@ -87,7 +87,7 @@ class Legend:
87
87
  key = copy.deepcopy(key)
88
88
  key.set('p', anchor_str)
89
89
  key.set('size', '4')
90
- key.set('id', f"legend-point-{num}")
90
+ key.set('id', f"pf__legend-point-{num}")
91
91
  key_width = max(key_width, point_width)
92
92
  else:
93
93
  fill = key.get('fill')
@@ -219,11 +219,11 @@ class Legend:
219
219
  id = group.get('id', 'none')
220
220
  if id == 'background-group':
221
221
  for rectangle in group:
222
- if rectangle.get('id', 'none').startswith('legend-label'):
222
+ if rectangle.get('id', 'none').startswith('pf__legend-label'):
223
223
  group.remove(rectangle)
224
224
  if id == 'braille-group':
225
225
  for label in group:
226
- if label.get('id','none').startswith('legend-label'):
226
+ if label.get('id','none').startswith('pf__legend-label'):
227
227
  label_groups.append(label)
228
228
  group.remove(label)
229
229
 
prefig/core/repeat.py CHANGED
@@ -60,7 +60,10 @@ def repeat(element, diagram, parent, outline_status):
60
60
  if outline is not None:
61
61
  element.set('outline', outline)
62
62
  if id is not None:
63
+ if not id.startswith('pf__'):
64
+ id = 'pf__' + id
63
65
  element.set('id', id)
66
+ element_cp.set('id', id)
64
67
 
65
68
  for num, k in enumerate(iterator):
66
69
  if isinstance(k, np.ndarray):
prefig/core/shape.py CHANGED
@@ -36,7 +36,10 @@ def define(element, diagram, parent, outline_status):
36
36
  log.error(f"In <define-shapes>, {child.tag} does not define a shape")
37
37
  continue
38
38
  if child.get('at', None) is not None:
39
- child.set('id', child.get('at'))
39
+ id = child.get('at')
40
+ if not id.startswith('pf__'):
41
+ id = 'pf__' + id
42
+ child.set('id', id)
40
43
  dummy_parent = ET.Element('group')
41
44
  # this is kind of a hack, but we only need to construct the shape
42
45
  # so we stash the format temporarily in case we're building a
@@ -69,6 +72,12 @@ def shape(element, diagram, parent, outline_status):
69
72
  return
70
73
 
71
74
  shape_refs = [r.strip() for r in reference.split(',')]
75
+ shape_edit = []
76
+ for shape_ref in shape_refs:
77
+ if not shape_ref.startswith('pf__'):
78
+ shape_ref = 'pf__' + shape_ref
79
+ shape_edit.append(shape_ref)
80
+ shape_refs = shape_edit
72
81
  shapes = []
73
82
  for ref in shape_refs:
74
83
  shapes.append(diagram.recall_shape(ref))
@@ -82,6 +91,8 @@ def shape(element, diagram, parent, outline_status):
82
91
  operation = 'union'
83
92
  else:
84
93
  path = ET.SubElement(parent, 'use')
94
+ if not reference.startswith('pf__'):
95
+ reference = 'pf__' + reference
85
96
  path.set('href', r'#' + reference)
86
97
 
87
98
  if operation is not None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: prefig
3
- Version: 0.5.0
3
+ Version: 0.5.2
4
4
  Summary: An authoring system for mathematical diagrams
5
5
  Home-page: https://prefigure.org
6
6
  License: GPL-3.0-or-later
@@ -2,26 +2,26 @@ prefig/__init__.py,sha256=tAf78JkO5kBvFM23RmchK8TEDYO6v8AXqzOv-kq7TR0,53
2
2
  prefig/cli.py,sha256=-jbXTVb2Vao4uefq3ia69DDh7ZQivIO-H1grzCVPg0I,12495
3
3
  prefig/core/CTM.py,sha256=P32b5rfJD_8QwMNCHRAS6lIB5ellBi1gaSdhxTV4a00,5781
4
4
  prefig/core/__init__.py,sha256=roT0a8-iBrp8WXTbPN5RzMWFiCXfpKrEXa2xE-F-yBo,728
5
- prefig/core/annotations.py,sha256=YYt7xVVVTbsuxGx7cSaW7KMMDa52STLEhTwAlDkBfoA,7710
5
+ prefig/core/annotations.py,sha256=0vNxWkSAIDIs2L6pTJT0vGgL7qn0yBRw0to6kUeWcTw,7869
6
6
  prefig/core/area.py,sha256=U-AxXvaZJWgVccpLlh-aaRfM_QtTa09NR2TqAd8Yk0o,3710
7
- prefig/core/arrow.py,sha256=D5JWKt3Va13f1tNeiyvpohwm6en0EA3KSFODbiE_bio,11498
8
- prefig/core/axes.py,sha256=3J6eWNXRWTlbFVNfWkv_-Hyq4L7UP54EQ5u1r82Cfy0,31830
7
+ prefig/core/arrow.py,sha256=NJIh6E1W7NDfyw0BK9mhIrdF1s0Z8iKI0Ut8cM0qvDA,11510
8
+ prefig/core/axes.py,sha256=8cvN0R_-dd6F11tTzGZU9sFy0qUPseJc8jsRFQUenSk,31834
9
9
  prefig/core/calculus.py,sha256=Q4kSGTTTeQYEEVKgmYWpFP0JLHmCsBchB5OF9qSclQk,498
10
10
  prefig/core/circle.py,sha256=zWm0emJ2YzH4EcaOqgxMgg-_t4Qcrd2Itfo6_s_61uo,16054
11
- prefig/core/clip.py,sha256=X3TcFYPuZwjZ9SFBWMc1MYY__6XTJqLafPeOLFNOdIE,806
11
+ prefig/core/clip.py,sha256=G4bg7jTGWCd284yzhCwOBbXdxgKvokYbEr2ITA4febI,808
12
12
  prefig/core/compat.py,sha256=_dI4aGtDrfhcw33r1SQS6kMwwgJj8dJ2A2GcLmtwX7o,729
13
13
  prefig/core/coordinates.py,sha256=vEAJ8kL9S1VylxWysqY5qW2WyCMyHj42yFkuAzjfqFs,3518
14
14
  prefig/core/definition.py,sha256=7LiaCxQwwEPdcnMpcMgrkZEfAoTc5ng8LO6Nf50Htwg,1033
15
- prefig/core/diagram.py,sha256=q9BbSm6bSbjnXdWUOvJWVu7zICc077CWext1g2iYing,26219
15
+ prefig/core/diagram.py,sha256=PwUoJ0s3sIdTgFxGir_scQvAI5E_uGnLbRONBXIxofs,26514
16
16
  prefig/core/diffeqs.py,sha256=aLXcmTsnfTG6L2-RiNfSaijzwmJF6xJcQpNQdDAWTQo,7127
17
17
  prefig/core/graph.py,sha256=q81dyJy3CxMWvMNhm74SZ9yjfltatdckmajxegA0z0A,10064
18
- prefig/core/grid_axes.py,sha256=Lb0uqkDkLlsiWOz5UeaY61zYnl_Tbh3FZXtvl-KawZA,12231
18
+ prefig/core/grid_axes.py,sha256=ASzFksHN317l0S0DcJvrA8io7i9Gl_s8lh5az9t8BJM,12357
19
19
  prefig/core/group.py,sha256=KByOibuslP9TqSygNfPSaN4zU5oSRYaH2CPnR21ogTg,5825
20
20
  prefig/core/image.py,sha256=eQKy0mNvCE6J8EA1S5Y08YF3lrb7kCeGG4wrjBQ_-pI,4373
21
21
  prefig/core/implicit.py,sha256=JyFKpKj6Xi1PF-3BeZpd7t0aNe8jH9Wf_E2rghvt-Ug,6179
22
22
  prefig/core/label.py,sha256=iIL0QXyNOGbWSA8xLoPgkkxghTcyHRmdDQw07mvBGjY,25100
23
23
  prefig/core/label_tools.py,sha256=jOawiyrKC5iQs0vq7133xNXqrkJbMqDZVHflT-hOruo,9167
24
- prefig/core/legend.py,sha256=0mVfyU3LvqgDCYUOlCeBD04maV-rj2h0fs1aOEBBt6c,13340
24
+ prefig/core/legend.py,sha256=S8r0M-nfoQL6tMpeq79xTgDQen9c13NAzMX5au1x47Q,13356
25
25
  prefig/core/line.py,sha256=3Q0bIYoKkKlTfdM-wMh9xXSQgEpMAwyWPAmJZgzDFzc,9038
26
26
  prefig/core/math_utilities.py,sha256=sMm3U9rcYKY8oZZWeJjcBokCDO4CxUkvmaX55auR4Eo,5927
27
27
  prefig/core/network.py,sha256=1izAX2AKvnj2knElrdLeojE_0Q0zO0aQM-EsEwor0Os,27217
@@ -32,9 +32,9 @@ prefig/core/point.py,sha256=n95dHgEjynMauBzfSXbQPnZqyUEWRm4HA9fUTh-e_8M,8912
32
32
  prefig/core/polygon.py,sha256=BJ-n9XnxSHb3UFu7lCqOEb48uyGvGGwsA_65dR8_6X4,11429
33
33
  prefig/core/read.py,sha256=Q1Nsluwysg3M5wtUmwIirfNo-Rw9-dFJPEeM4pDCpyo,1988
34
34
  prefig/core/rectangle.py,sha256=TzdVckcPfNV8fI1xs8FgHadx06wn2P6A504oyDO3xGY,3567
35
- prefig/core/repeat.py,sha256=6HtCMzIT0r3bndeVn2oyp_FrBillN3HtJnhATLV_a-I,3700
35
+ prefig/core/repeat.py,sha256=iQHJWhhx6hih1SPFBTk-BSyWSyxDvlOikuKb2F6iHSY,3800
36
36
  prefig/core/riemann_sum.py,sha256=T2dQgJIY17QuuPDOB8XWIP8HYmg5jOQ-LroFH7tiGAU,3012
37
- prefig/core/shape.py,sha256=Qb_-upbSHwEoYrrAnbCoFFFuVIb3JgJLdyP9ckD5evc,8675
37
+ prefig/core/shape.py,sha256=JUy6etGGYzlx5d_CzKpIcK4vmx9BTpJixbCQ3-q87QE,9072
38
38
  prefig/core/slope_field.py,sha256=KThnVBuO_3QK7k6xxCWnsbiv-X9P8oS1SgFPLoynA-E,8797
39
39
  prefig/core/statistics.py,sha256=5qN_-ABN0EFVG12ZP95uSPk82INbWRqI3w2fUdR3wsw,3458
40
40
  prefig/core/tags.py,sha256=7w6E3960o_ZgZl4xYJLVJ1eLttt0vVlB4IgMZGTMyyE,4134
@@ -61,8 +61,8 @@ prefig/resources/schema/pf_schema.rng,sha256=6U72-HDhdS9drcKoTBVyBxo1XLXxMnPJvrQ
61
61
  prefig/resources/template/pf_publication.xml,sha256=eEv8HACv610Apw5DSVNy0reLfELYqHlNy9Oq0GH7C_c,200
62
62
  prefig/scripts/__init__.py,sha256=qJcPi1WRh9UAwu4zIFJbmxWalAMilMYqgi6LxRkF7bI,25
63
63
  prefig/scripts/install_mj.py,sha256=5A6-oc1xbIXka5mkFE70vlp9-Rh_QoxOxGMrQi9Hkio,1219
64
- prefig-0.5.0.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
65
- prefig-0.5.0.dist-info/METADATA,sha256=ujTSJNU9DH_xEBxY_tK1h9Yvc6xqvjhm4RWLAybmlEg,8690
66
- prefig-0.5.0.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
67
- prefig-0.5.0.dist-info/entry_points.txt,sha256=OP4ZQT71q2b0Zfbie-oM2Z1HlxpkuX7qaxJnzwsBOVQ,42
68
- prefig-0.5.0.dist-info/RECORD,,
64
+ prefig-0.5.2.dist-info/LICENSE,sha256=OXLcl0T2SZ8Pmy2_dmlvKuetivmyPd5m1q-Gyd-zaYY,35149
65
+ prefig-0.5.2.dist-info/METADATA,sha256=oD2Es0nmEh7uG4sAJxe6baO7uz698TCGr2QQbnmz_Jw,8690
66
+ prefig-0.5.2.dist-info/WHEEL,sha256=sP946D7jFCHeNz5Iq4fL4Lu-PrWrFsgfLXbbkciIZwg,88
67
+ prefig-0.5.2.dist-info/entry_points.txt,sha256=OP4ZQT71q2b0Zfbie-oM2Z1HlxpkuX7qaxJnzwsBOVQ,42
68
+ prefig-0.5.2.dist-info/RECORD,,
File without changes