rusty-graph 0.3.2__cp38-cp38-win_amd64.whl → 0.3.4__cp38-cp38-win_amd64.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.

Potentially problematic release.


This version of rusty-graph might be problematic. Click here for more details.

Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: rusty_graph
3
- Version: 0.3.2
3
+ Version: 0.3.4
4
4
  Classifier: Programming Language :: Rust
5
5
  Classifier: Programming Language :: Python :: Implementation :: CPython
6
6
  Classifier: Programming Language :: Python :: Implementation :: PyPy
@@ -25,6 +25,10 @@ A high-performance graph database library with Python bindings written in Rust.
25
25
  - [Working with Nodes](#working-with-nodes)
26
26
  - [Creating Connections](#creating-connections)
27
27
  - [Filtering and Querying](#filtering-and-querying)
28
+ - [Basic Filtering](#basic-filtering)
29
+ - [Filtering Orphan Nodes](#filtering-orphan-nodes)
30
+ - [Sorting Results](#sorting-results)
31
+ - [Limiting Results](#limiting-results)
28
32
  - [Traversing the Graph](#traversing-the-graph)
29
33
  - [Statistics and Calculations](#statistics-and-calculations)
30
34
  - [Saving and Loading](#saving-and-loading)
@@ -34,6 +38,8 @@ A high-performance graph database library with Python bindings written in Rust.
34
38
 
35
39
  ```bash
36
40
  pip install rusty-graph
41
+ # upgrade
42
+ pip install rusty-graph --upgrade
37
43
  ```
38
44
 
39
45
  ## Introduction
@@ -197,18 +203,83 @@ product_orphans = graph.type_filter('Product').filter_orphans(include_orphans=Tr
197
203
 
198
204
  ### Sorting Results
199
205
 
206
+ Rusty Graph offers flexible options for sorting nodes based on their properties. The `sort_spec` parameter can be used in various methods including `type_filter()`, `filter()`, `filter_orphans()`, `traverse()`, and the standalone `sort()` method.
207
+
208
+ #### Sort Specification Format Options
209
+
210
+ 1. **Single field string**: Sorts by the specified field in ascending order.
211
+ ```python
212
+ # Sort products by price (lowest to highest)
213
+ sorted_products = graph.type_filter('Product').sort('price')
214
+
215
+ # Can also be used in other methods
216
+ cheap_products = graph.type_filter('Product').filter(
217
+ {'stock': {'>': 10}},
218
+ sort_spec='price'
219
+ )
220
+ ```
221
+
222
+ 2. **Field with direction**: Explicitly specify ascending or descending order.
223
+ ```python
224
+ # Sort products by price (highest to lowest)
225
+ expensive_first = graph.type_filter('Product').sort('price', ascending=False)
226
+ ```
227
+
228
+ 3. **List of tuples**: For multi-field sorting with different directions.
229
+ ```python
230
+ # First sort by stock (descending), then by price (ascending)
231
+ # This prioritizes high-stock items, and for items with equal stock,
232
+ # shows the cheapest ones first
233
+ complex_sort = graph.type_filter('Product').sort([
234
+ ('stock', False), # False = descending order
235
+ ('price', True) # True = ascending order
236
+ ])
237
+ ```
238
+
239
+ 4. **Dictionary with field and direction**: Alternative format for single field sorting.
240
+ ```python
241
+ # Sort by rating in descending order
242
+ top_rated = graph.type_filter('Product').filter(
243
+ {},
244
+ sort_spec={'field': 'rating', 'ascending': False}
245
+ )
246
+ ```
247
+
248
+ #### Using Sort Specifications in Different Methods
249
+
250
+ Sort specifications work consistently across methods:
251
+
200
252
  ```python
201
- # Sort by a single field (ascending by default)
202
- sorted_products = graph.type_filter('Product').sort('price')
253
+ # In type_filter
254
+ latest_users = graph.type_filter('User', sort_spec='creation_date', max_nodes=10)
203
255
 
204
- # Sort explicitly by direction
205
- expensive_first = graph.type_filter('Product').sort('price', ascending=False)
256
+ # In filter
257
+ new_expensive = graph.type_filter('Product').filter(
258
+ {'price': {'>': 500.0}},
259
+ sort_spec=[('creation_date', False), ('price', True)]
260
+ )
206
261
 
207
- # Sort by multiple fields
208
- sorted_complex = graph.type_filter('Product').sort([
209
- ('stock', False), # Highest stock first
210
- ('price', True) # Then by price, lowest first
211
- ])
262
+ # In traversal
263
+ alice_recent_purchases = graph.type_filter('User').filter({'name': 'Alice'}).traverse(
264
+ connection_type='PURCHASED',
265
+ sort_target='date',
266
+ max_nodes=5
267
+ )
268
+
269
+ # In filter_orphans
270
+ recent_orphans = graph.filter_orphans(
271
+ include_orphans=True,
272
+ sort_spec='last_modified',
273
+ max_nodes=20
274
+ )
275
+
276
+ # In children_properties_to_list
277
+ expensive_products = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
278
+ property='title',
279
+ sort_spec='price', # Sort children by price before creating the list
280
+ max_nodes=3,
281
+ store_as='top_expensive_purchases'
282
+ )
212
283
  ```
213
284
 
214
285
  ### Limiting Results
@@ -259,6 +330,26 @@ unique_categories = graph.type_filter('Product').unique_values(
259
330
  store_as='category_list',
260
331
  max_length=10
261
332
  )
333
+
334
+ # Convert children properties to a comma-separated list in parent nodes
335
+ # Option 1: Store results in parent nodes
336
+ users_with_products = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
337
+ property='title', # Default is 'title' if not specified
338
+ filter={'price': {'<': 500.0}}, # Optional filtering of children
339
+ sort_spec='price', # Optional sorting of children
340
+ max_nodes=5, # Optional limit of children per parent
341
+ store_as='purchased_products', # Property name to store the list in parent
342
+ max_length=100, # Optional maximum string length (adds "..." if truncated)
343
+ keep_selection=False # Whether to keep the current selection
344
+ )
345
+
346
+ # Option 2: Get results as a dictionary without storing them
347
+ product_names = graph.type_filter('User').traverse('PURCHASED').children_properties_to_list(
348
+ property='title',
349
+ sort_spec='price',
350
+ max_nodes=5
351
+ )
352
+ print(product_names) # Returns {'User1': 'Product1, Product2', 'User2': 'Product3, Product4, Product5'}
262
353
  ```
263
354
 
264
355
  ### Custom Calculations
@@ -0,0 +1,6 @@
1
+ rusty_graph-0.3.4.dist-info/METADATA,sha256=ix0AGbtZEQaNj1Dz56oqKE324FBzH9hJnSMvvLQosDM,12869
2
+ rusty_graph-0.3.4.dist-info/WHEEL,sha256=4HtObfOomBNL7IBszeftbFfpctPxP7JmvdmCHQVg0Dg,94
3
+ rusty_graph-0.3.4.dist-info/licenses/LICENSE,sha256=APR3-pK3VHs2KSVNVV9RQwAM0yIdoLq4FTCy1Cx2EMs,938
4
+ rusty_graph/__init__.py,sha256=_Fds04T5qV95XgyZm7qIPfLghgoCZi-_hDbw-e_18oA,127
5
+ rusty_graph/rusty_graph.cp38-win_amd64.pyd,sha256=3SV15eerRj_v4sYjAgiDVWIK86Zr9QYu29yZdxgWw14,1043968
6
+ rusty_graph-0.3.4.dist-info/RECORD,,
@@ -1,6 +0,0 @@
1
- rusty_graph-0.3.2.dist-info/METADATA,sha256=V8y7e0gV0dME-hbGjdib4eV9JingTrXvrYPd4W4frgA,9393
2
- rusty_graph-0.3.2.dist-info/WHEEL,sha256=4HtObfOomBNL7IBszeftbFfpctPxP7JmvdmCHQVg0Dg,94
3
- rusty_graph-0.3.2.dist-info/licenses/LICENSE,sha256=APR3-pK3VHs2KSVNVV9RQwAM0yIdoLq4FTCy1Cx2EMs,938
4
- rusty_graph/__init__.py,sha256=_Fds04T5qV95XgyZm7qIPfLghgoCZi-_hDbw-e_18oA,127
5
- rusty_graph/rusty_graph.cp38-win_amd64.pyd,sha256=rb0TS1P9B4DTF1QG6jVq8meMc1L2GqueRbCo2PYIKJE,1020928
6
- rusty_graph-0.3.2.dist-info/RECORD,,