topologicpy 0.7.37__py3-none-any.whl → 0.7.39__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.
topologicpy/ANN.py CHANGED
@@ -471,27 +471,11 @@ class ANN():
471
471
  ----------
472
472
  name : str
473
473
  The name of the dataset. This can be one of ['breast_cancer', 'california_housing', 'digits', 'iris', 'wine']
474
-
475
- trainRatio : float , optional
476
- The ratio of the data to use for training and validation vs. the ratio to use for testing. The default is 0.6
477
- which means that 60% of the data will be used for training and validation while 40% of the data will be reserved for testing.
478
- randomState : int , optional
479
- The randomState parameter is used to ensure reproducibility of the results. When you set the randomState parameter to a specific integer value,
480
- it controls the shuffling of the data before splitting it into training and testing sets.
481
- This means that every time you run your code with the same randomState value and the same dataset, you will get the same split of the data.
482
- The default is 42 which is just a randomly picked integer number. Specify None for random sampling.
483
474
 
484
475
  Returns
485
476
  -------
486
- dict
487
- Returns the following dictionary:
488
- XTrain, XTest, yTrain, yTest, inputSize, outputSize
489
- XTrain is the list of features used for training
490
- XTest is the list of features used for testing
491
- yTrain is the list of targets used for training
492
- yTest is the list of targets used for testing
493
- inputSize is the size (length) of the input
494
- outputSize is the size (length) of the output
477
+ sklearn.utils._bunch.Bunch
478
+ The created dataset.
495
479
  """
496
480
  # Load dataset
497
481
  if name == 'breast_cancer':
topologicpy/Face.py CHANGED
@@ -521,8 +521,8 @@ class Face():
521
521
 
522
522
  Returns
523
523
  -------
524
- topologic_core.Cell
525
- The created cell.
524
+ topologic_core.Face
525
+ The created face.
526
526
 
527
527
  """
528
528
  from topologicpy.Vertex import Vertex
@@ -2170,19 +2170,15 @@ class Face():
2170
2170
  origin : topologic_core.Vertex , optional
2171
2171
  The location of the origin of the squircle. The default is None which results in the squircle being placed at (0, 0, 0).
2172
2172
  radius : float , optional
2173
- The radius of the squircle. The default is 0.5.
2173
+ The desired radius of the squircle. The default is 0.5.
2174
2174
  sides : int , optional
2175
- The number of sides of the squircle. The default is 121.
2175
+ The desired number of sides of the squircle. The default is 121.
2176
2176
  a : float , optional
2177
2177
  The "a" factor affects the x position of the points to interpolate between a circle and a square.
2178
2178
  A value of 1 will create a circle. Higher values will create a more square-like shape. The default is 2.0.
2179
2179
  b : float , optional
2180
2180
  The "b" factor affects the y position of the points to interpolate between a circle and a square.
2181
2181
  A value of 1 will create a circle. Higher values will create a more square-like shape. The default is 2.0.
2182
- radius : float , optional
2183
- The desired radius of the squircle. The default is 0.5.
2184
- sides : int , optional
2185
- The desired number of sides for the squircle. The default is 100.
2186
2182
  direction : list , optional
2187
2183
  The vector representing the up direction of the circle. The default is [0, 0, 1].
2188
2184
  placement : str , optional
topologicpy/Graph.py CHANGED
@@ -1289,7 +1289,7 @@ class Graph:
1289
1289
  return values
1290
1290
 
1291
1291
  @staticmethod
1292
- def ByAdjacencyMatrixCSVPath(path):
1292
+ def ByAdjacencyMatrixCSVPath(path: str, dictionaries: list = None, silent: bool = False):
1293
1293
  """
1294
1294
  Returns graphs according to the input path. This method assumes the CSV files follow an adjacency matrix schema.
1295
1295
 
@@ -1297,6 +1297,11 @@ class Graph:
1297
1297
  ----------
1298
1298
  path : str
1299
1299
  The file path to the adjacency matrix CSV file.
1300
+ dictionaries : list , optional
1301
+ A list of dictionaries to assign to the vertices of the graph. This list should be in
1302
+ the same order and of the same length as the rows in the adjacency matrix.
1303
+ silent : bool , optional
1304
+ If set to True, no warnings or error messages are displayed. The default is False.
1300
1305
 
1301
1306
  Returns
1302
1307
  -------
@@ -1310,10 +1315,10 @@ class Graph:
1310
1315
 
1311
1316
  # Convert DataFrame to a nested list
1312
1317
  adjacency_matrix = adjacency_matrix_df.values.tolist()
1313
- return Graph.ByAdjacencyMatrix(adjacencyMatrix=adjacency_matrix)
1318
+ return Graph.ByAdjacencyMatrix(adjacencyMatrix=adjacency_matrix, dictionaries=dictionaries, silent=silent)
1314
1319
 
1315
1320
  @staticmethod
1316
- def ByAdjacencyMatrix(adjacencyMatrix, xMin=-0.5, yMin=-0.5, zMin=-0.5, xMax=0.5, yMax=0.5, zMax=0.5):
1321
+ def ByAdjacencyMatrix(adjacencyMatrix, dictionaries = None, xMin=-0.5, yMin=-0.5, zMin=-0.5, xMax=0.5, yMax=0.5, zMax=0.5, silent=False):
1317
1322
  """
1318
1323
  Returns graphs according to the input folder path. This method assumes the CSV files follow DGL's schema.
1319
1324
 
@@ -1321,18 +1326,23 @@ class Graph:
1321
1326
  ----------
1322
1327
  adjacencyMatrix : list
1323
1328
  The adjacency matrix expressed as a nested list of 0s and 1s.
1324
- xMin : float, optional
1329
+ dictionaries : list , optional
1330
+ A list of dictionaries to assign to the vertices of the graph. This list should be in
1331
+ the same order and of the same length as the rows in the adjacency matrix.
1332
+ xMin : float , optional
1325
1333
  The desired minimum value to assign for a vertex's X coordinate. The default is -0.5.
1326
- yMin : float, optional
1334
+ yMin : float , optional
1327
1335
  The desired minimum value to assign for a vertex's Y coordinate. The default is -0.5.
1328
- zMin : float, optional
1336
+ zMin : float , optional
1329
1337
  The desired minimum value to assign for a vertex's Z coordinate. The default is -0.5.
1330
- xMax : float, optional
1338
+ xMax : float , optional
1331
1339
  The desired maximum value to assign for a vertex's X coordinate. The default is 0.5.
1332
- yMax : float, optional
1340
+ yMax : float , optional
1333
1341
  The desired maximum value to assign for a vertex's Y coordinate. The default is 0.5.
1334
- zMax : float, optional
1342
+ zMax : float , optional
1335
1343
  The desired maximum value to assign for a vertex's Z coordinate. The default is 0.5.
1344
+ silent : bool , optional
1345
+ If set to True, no warnings or error messages are displayed. The default is False.
1336
1346
 
1337
1347
  Returns
1338
1348
  -------
@@ -1342,16 +1352,25 @@ class Graph:
1342
1352
  """
1343
1353
  from topologicpy.Vertex import Vertex
1344
1354
  from topologicpy.Edge import Edge
1355
+ from topologicpy.Topology import Topology
1345
1356
  import random
1346
1357
 
1347
1358
  if not isinstance(adjacencyMatrix, list):
1348
1359
  print("Graph.ByAdjacencyMatrix - Error: The input adjacencyMatrix parameter is not a valid list. Returning None.")
1349
1360
  return None
1361
+ if isinstance(dictionaries, list):
1362
+ if not len(dictionaries) == len(adjacencyMatrix):
1363
+ if not silent:
1364
+ print("Graph.ByAdjacencyMatrix - Error: The length of the dictionaries list and the adjacency matrix are different. Returning None.")
1365
+ return None
1366
+
1350
1367
  # Add vertices with random coordinates
1351
1368
  vertices = []
1352
1369
  for i in range(len(adjacencyMatrix)):
1353
1370
  x, y, z = random.uniform(xMin,xMax), random.uniform(yMin,yMax), random.uniform(zMin,zMax)
1354
- vertices.append(Vertex.ByCoordinates(x, y, z))
1371
+ v = Vertex.ByCoordinates(x, y, z)
1372
+ v = Topology.SetDictionary(v, dictionaries[i])
1373
+ vertices.append(v)
1355
1374
 
1356
1375
  # Create the graph using vertices and edges
1357
1376
  if len(vertices) == 0:
@@ -4667,6 +4686,8 @@ class Graph:
4667
4686
 
4668
4687
  Parameters
4669
4688
  ----------
4689
+ adjacencyMatrix: list
4690
+ The input adjacency matrix.
4670
4691
  path : str
4671
4692
  The desired path to the output folder where the graphs, edges, and nodes CSV files will be saved.
4672
4693
 
@@ -4917,7 +4938,6 @@ class Graph:
4917
4938
  The desired graph label column header. The default is "label".
4918
4939
  graphFeaturesHeader : str , optional
4919
4940
  The desired graph features column header. The default is "feat".
4920
-
4921
4941
  edgeLabelKey : str , optional
4922
4942
  The edge label dictionary key saved in each graph edge. The default is "label".
4923
4943
  defaultEdgeLabel : int , optional
@@ -4952,7 +4972,6 @@ class Graph:
4952
4972
  This value is ignored if an edgeMaskKey is foud.
4953
4973
  bidirectional : bool , optional
4954
4974
  If set to True, a reversed edge will also be saved for each edge in the graph. Otherwise, it will not. The default is True.
4955
-
4956
4975
  nodeFeaturesKeys : list , optional
4957
4976
  The list of features keys saved in the dicitonaries of nodes. The default is [].
4958
4977
  nodeLabelKey : str , optional
@@ -7425,7 +7444,7 @@ class Graph:
7425
7444
  The desired default vertex size. The default is 6.
7426
7445
  vertexSizeKey : str , optional
7427
7446
  If not set to None, the vertex size will be derived from the dictionary value set at this key. If set to "degree", the size of the vertex will be determined by its degree (number of neighbors). The default is None.
7428
- vertexColor : int , optional
7447
+ vertexColor : str , optional
7429
7448
  The desired default vertex color. his can be a named color or a hexadecimal value. The default is 'black'.
7430
7449
  vertexColorKey : str , optional
7431
7450
  If not set to None, the vertex color will be derived from the dictionary value set at this key. The default is None.
@@ -7865,6 +7884,8 @@ class Graph:
7865
7884
  The dictionary key to use to display the edge label. The default is None.
7866
7885
  edgeGroupKey : str , optional
7867
7886
  The dictionary key to use to display the edge group. The default is None.
7887
+ edgeGroups : list , optional
7888
+ The list of edge groups against which to index the color of the edge. The default is [].
7868
7889
  showEdges : bool , optional
7869
7890
  If set to True the edges will be drawn. Otherwise, they will not be drawn. The default is True.
7870
7891
  showEdgeLegend : bool , optional
topologicpy/Grid.py CHANGED
@@ -307,8 +307,6 @@ class Grid():
307
307
  ----------
308
308
  face : topologic_core.Face , optional
309
309
  The input face. If set to None, the grid will be created on the XY plane. The default is None.
310
- origin : topologic_core.Vertex , optional
311
- The origin of the grid vertices. If set to None: if the face is set, the origin will be set to vertex at the face's 0,0 paratmer. If the face is set to None, the origin will be set to (0, 0, 0). The default is None.
312
310
  uRange : list , optional
313
311
  A list of *u* parameters for the *u* grid lines from the uOrigin. The default is [0.0,0.25,0.5,0.75,1.0].
314
312
  vRange : list , optional
topologicpy/Helper.py CHANGED
@@ -163,40 +163,6 @@ class Helper:
163
163
  iterated_list.append(y)
164
164
  return iterated_list
165
165
 
166
- @staticmethod
167
- def K_Means(data, k=4, maxIterations=100):
168
- import random
169
- def euclidean_distance(p, q):
170
- return sum((pi - qi) ** 2 for pi, qi in zip(p, q)) ** 0.5
171
-
172
- # Initialize k centroids randomly
173
- centroids = random.sample(data, k)
174
-
175
- for _ in range(maxIterations):
176
- # Assign each data point to the nearest centroid
177
- clusters = [[] for _ in range(k)]
178
- for point in data:
179
- distances = [euclidean_distance(point, centroid) for centroid in centroids]
180
- nearest_centroid_index = distances.index(min(distances))
181
- clusters[nearest_centroid_index].append(point)
182
-
183
- # Compute the new centroids as the mean of the points in each cluster
184
- new_centroids = []
185
- for cluster in clusters:
186
- if not cluster:
187
- # If a cluster is empty, keep the previous centroid
188
- new_centroids.append(centroids[clusters.index(cluster)])
189
- else:
190
- new_centroids.append([sum(dim) / len(cluster) for dim in zip(*cluster)])
191
-
192
- # Check if the centroids have converged
193
- if new_centroids == centroids:
194
- break
195
-
196
- centroids = new_centroids
197
-
198
- return {'clusters': clusters, 'centroids': centroids}
199
-
200
166
  @staticmethod
201
167
  def MergeByThreshold(listA, threshold=0.0001):
202
168
  """
topologicpy/Neo4j.py CHANGED
@@ -276,7 +276,7 @@ class Neo4j:
276
276
  return Graph.ByVerticesEdges(vertices,edges)
277
277
 
278
278
  @staticmethod
279
- def AddGraph(neo4jGraph, graph, labelKey=None, relationshipKey=None, bidirectional=True, deleteAll=True, mantissa: int = 6, tolerance: float = 0.0001):
279
+ def AddGraph(neo4jGraph, graph, labelKey=None, relationshipKey=None, mantissa: int = 6, tolerance: float = 0.0001):
280
280
  """
281
281
  Adds the input topologic graph to the input neo4j graph
282
282
 
@@ -286,8 +286,10 @@ class Neo4j:
286
286
  The input neo4j graph.
287
287
  graph : topologic_core.Graph
288
288
  The input topologic graph.
289
- categoryKey : str
290
- The category key in the dictionary under which to look for the category value.
289
+ labelKey : str , optional
290
+ The label key in the dictionary under which to look for the label value.
291
+ relationshipKey: str , optional
292
+ The relationship key in the dictionary under which to look for the relationship value.
291
293
  mantissa : int, optional
292
294
  The desired length of the mantissa. The default is 6.
293
295
  tolerance : float , optional
topologicpy/Polyskel.py CHANGED
@@ -115,7 +115,11 @@ class Ray2:
115
115
  return None # Rays are parallel and do not intersect
116
116
 
117
117
  # Calculate the intersection point using vector algebra
118
- t = (other.p - self.p).cross(other.v) / self.v.cross(other.v)
118
+ denom = self.v.cross(other.v)
119
+ if not denom == 0:
120
+ t = (other.p - self.p).cross(other.v) / self.v.cross(other.v)
121
+ else:
122
+ return None
119
123
  if t >= 0:
120
124
  return self.p + self.v * t # Intersection point
121
125
  else: