summaryrefslogtreecommitdiff
path: root/networkx/readwrite/tests
Commit message (Collapse)AuthorAgeFilesLines
* Fix typos (#6620)Harri Nieminen2023-04-043-6/+6
|
* Better default alpha value for viz attributes in gexf writer (#6612)Ross Barnowski2023-04-031-0/+10
| | | | | | | | | | | * Add test that fails with current default ('None') * Update default alpha value. Co-authored-by: Dan Schult <dschult@colgate.edu> --------- Co-authored-by: Dan Schult <dschult@colgate.edu>
* Lint using Ruff (#6371)danieleades2023-02-192-13/+13
| | | | | | | | | | | | | | | * lint and fix using ruff * add flake8-pie lints * remove useless import alias * bump version * bump deps --------- Co-authored-by: daniel.eades <daniel.eades@hotmail.com>
* Add generate / write "network text" (formerly graph_str) (#5602)Jon Crall2023-01-301-82/+1263
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add graph_str Formatted Fix bug in choosing the source Fix test * Fixed issue in choosing source verticies for directed graphs * reasonable working state * Fixed logic issues Fix test, cleanup, formatting more tests, better comments, fix parent labels fix pypy issue Fix format * Fixes based on review * Cleaned up test names * Use open_file decor and remove graph_str * Remove useage of forest_str from doctest * Fix style * style * Update networkx/readwrite/text.py Co-authored-by: Dan Schult <dschult@colgate.edu> * Fixed half sentense * Add max_depth * moved comment position * Describe max depth in algo description * Allow with_labels to be specified as a str * Update networkx/readwrite/text.py Co-authored-by: Mridul Seth <mail@mriduls.com> * Add network text autodoc stub * Add removal note for forest_str --------- Co-authored-by: Dan Schult <dschult@colgate.edu> Co-authored-by: Mridul Seth <mail@mriduls.com>
* Fix typos in the networkx codebase (#6335)Anurag Bhat2023-01-051-3/+3
| | | | | * Fix_Typos * Commit_Suggestions
* Update GML parsing/writing to allow empty lists/tuples as node attributes ↵Ross Barnowski2022-10-191-4/+20
| | | | | | | | | | | | | (#6093) * Add failing test for empty list corner case. * Rm test case that rejects empty lists as attributes. * Beef up test by checking full round-trip. * Modify gml parsing to handle empty lists. * Parametrize test: lists and tuples.
* Remove OrderedGraphs (#5813)Jarrod Millman2022-07-124-7/+7
| | | | | | Removes the deprecated OrderedGraph classes. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove pyyaml dependency (#5763)Jarrod Millman2022-06-211-38/+0
| | | | | | | | * Remove pyyaml dependency * Make mypy happy. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Mridul Seth <seth.mridul@gmail.com>
* Remove gdal dependency (#5766)Jarrod Millman2022-06-161-288/+0
| | | | | | | | * Remove gdal dependency * [skip ci] Rm mention of gdal from roadmap. Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Mridul Seth <seth.mridul@gmail.com>
* Remove gpickle (#5773)Jarrod Millman2022-06-161-75/+0
|
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-0213-25/+40
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* Don't use graph6 with directed graphs (#5443) (#5444)Riccardo Bucco2022-03-311-8/+59
| | | | | | | * Don't use graph6 with directed graphs (#5443) * Parametrize graph6 tests * Test graph6 on multigraphs
* Update black (#5438)Mridul Seth2022-03-291-5/+5
| | | | | | | * CI: sync up black dev requirements version with precommit * Run black Co-authored-by: Jarrod Millman <jarrod.millman@gmail.com>
* Add Mypy type checking infrastructure (#5127)Ross Barnowski2021-11-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add minimal mypy configuration file. * Add mypy workflow to GH. * Properly import sentinels from traversal.edgedfs. * mypy doesn't like variables named \"e\". * Rm annotations from single function. * Fix name collisions in test suite. Make sure all tests have unique names. * Rm unused random seed in test setup. * Rm redundant __all__ specification. * Silence mypy error from sum(). Mypy bug? * Fix tsp test instantiation nit. * \"type: ignore\" to suppress conditional fn sigature errors. * Remaining \"type: ignore\" to appease mypy. * Configure mypy to ignore inheritance issues. * Update exclude conf for CI. - Add yaml - Reformat regex containing reportviews * Rm partial annotations from lukes.py. Fixes mypy errors due to unannotated code. * Reorg defaultdict to reduce type: ignore cruft. * Homogenize signatures for fns defined in conditionals. * err as varname only in exception catching. * Fix name collision in Bellman-Ford test suite.
* Drop Py37 (#5143)Jarrod Millman2021-10-232-114/+7
| | | | | | | | | | | | | | | | | | | * Drop Py37 * XML serialization issue * Use math.comb Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it> * Run pyupgrade --py38-plus * Run black * More documentation * Deprecate euclidean Co-authored-by: Simone Gasperini <simone.gasperini2@studio.unibo.it>
* Change exception varname e to err (#5130)Dan Schult2021-10-151-2/+2
| | | | A more descriptive variable name for exceptions. This reduces local var naming conflicts when \`e\` is used e.g. to represent edges as a loop variable.
* More informative GraphML exceptions (#5058)Ross Barnowski2021-09-141-0/+36
| | | | | | | | | * Add tests that fail on uninformative exception. * Raise informative exception when non-supported type used. * Add importorskip to new tests. * Change naming scheme for backward compatibility.
* Support `comments=None` in read/parse edgelist (#5051)Ross Barnowski2021-09-101-0/+8
| | | | | | | * Add support for comments=None in parse_edgelist. * Update docstrings. * if instead of try/except.
* Style changes (#5022)Dan Schult2021-08-141-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add greedy algorithm for solving TSP Many problems of Combinational Optimization can be represented as graphs. These problems have enormous significance in many aspects of science, but there are not any algorithms to solve some of them in polynomial time. However many, heuristic and metaheuristic algorithms have been published over the past years in order to solve / approximate the solutions to these problems. The purpose of this commit is to add implementation of such algorithms for solve one of the most famous problems of Combinational Optimizations, Travelling Salesman Problem (TSP). A greedy algorithm has been implemented at the moment for this reason. "applications" package has been created which include modules that represent a problem. Each module contains several algorithms for solving the specific problem. At this commit, tsp.py module is added which contains greedy_tsp() function; a implementation of a greedy algorithm. * Fix example error * Trivial changes List of changes: Removal of unnesecary _is_weighted() function Improvements on documentation * Add applications package to setup.py file * Change output of greedy algorithm Algorithm's output is a list of nodes now * Add simulated annealing algorithm Add a metaheuristic local search algorithm for solving TSP * Minor changes * Fix example doc errors * Compatible with python 3 * Move tsp module to algorithms package * Code improvements * Handle small graphs and fix doc examples * Documentation changes and rename variables * Adds Threshold Accepting algorithm for TSP * Implemented maximal matching of minimal weight and created test suite. * Removed useless print * Implemented Christofides. * Coding was missing * Add more general traveling_salesman_problem using christofides Also reconfigure import structure and remove min_weight_matching from module since it is now in matching.py * Add new functions to the docs and minor typos * pep8 fixes * fix pep8 and change .gitignore * Add tests of the approximation namespace update docs in approximation/__init__.py * Fix is_matching to check if edges in G. Other tweaks: doc changes and put not_implemented_for on find_matching functions * Improve is_matching selfloop handling and expand tests * Move tsp to approximation directory. Apply black. * Move tsp tests to approximation tests folder * Attempt to bring tsp up to current code. * commit pep8 that my black didnt change, but pep8speaks did find. ?? * tweak a few things and run black * combine #4083 and #3585 into traveling_salesman.py * Match chistofides output to other tsp functions and adjust calling syntax of tests tweak docs tweak see also section * Put big-O complexity in in-line math env. Prevents sphinx from trying to do variable substitution between pipes. * Minor touchups to christofides docstring. * RST touchups to tsp module docstring. * Rm extra string from tsp module. * Docstring touchups for traveling_salesman_problem. * rst fixups for greedy_tsp docstring. * rst formatting for simulated annealing docstring. * More math in-lining for simulated annealing docstring. * rst and minor grammatical fixes to TA docstring. * Fix path-finding and test all methods for tsp function * the refactoring was incomplete. Now maybe is - Add tests of TSP with all methods. - Refactor tests to match simulated_annealing tests and threshold tests. - Unify treatment of weight so unweighted edges use default weight 1. weight now defaults to "weight" with a default value of 1. - Rename tolerance to max_iterations (tolerance is used for error bound) - Rename iterations to N_inner (each iteration takes this many inner loops) - Introduce idioms like `pairwise` and `cycle.copy()` (over cycle[:]) - Allow passthrough of method kwargs for traveling_salesman_problem Still need to: - add test of case where path is more than one edge less that cycle (incomplete_graph) - require cycle input (maybe make default list(G)??) - consider the complexity claims in the doc_strings * More api changes to TSP functions - `chritofides` now allows (and ignores) selfloops - `move` can be a function as well as "1-1" and "1-0" - `method` for traveling_salesman_problem must have 2 arguments instead of passing kwargs. User must "curry" to set parameters - changed doc_string typos in matching.py * Add test to check that cycle=False can remove many edges * Change init_cycle api to require input from user The idea is to make the user specify the initial cycle to start from rather than relying on the programmers default of a greedy algorithm. To easy usage, I check for a string "greedy" as a shortcut. * Update docs with more correct complexity info. * Check for complete graph now more efficient and selfloops ignored * merge is_matching changes * New Networkx changes * Stub for Asadpour. Needed to create GSoC PR * Update to integrate changes from main * Added function stubs and draft docstrings for the Asadpour algorithm * Skeleton classes and methods for tree iterators * Attempting to set up basic tests for MST of a partition * testing * I'm not entirly sure how the commit hook works... * Moved iterators into the correct files to maintain proper codebase visibility * Including Black reformat * Revert "Merge branch 'networkx:main' into main" This reverts commit 0616a2331adfcc02976d305937aa52272ed48266, reversing changes made to 1ea769371f54c4c6f9a51f860caf4a60aef7d094. * Trying to merge again * Attempting to merge (4) * Now passes all tests except test_namespace_alias in /tests/test_import.py * Everything should FINALLY pass (I wipped my networkx dir and re-download from upstream) * reinstall the pre-commit hook * Grabbing black reformats * Working on debugging ascent method plus black reformats * Ascent method terminating, but at non-optimal solution * minor edits * Fixed termination condition, still given non-optimal result * Minor bugfix, still non-optimal result * Fixed subtle bug in find_epsilon() * Cleaned code and tried something which didn't work * Modified the ArborescenceIterator to accept init partition * Black formats * Branch and bound returning optimal solution * Working Ascent method, code needs cleaning * black formatting changes * Performance tweaks and testing fractional answers * Fixed test bug, I hope * Asadpour output for ascent method * Fixed numpy imports crashing pypi tests * Removed branch and bound method. One unit test misbehaving * Added asymmetric fractional test for the ascent method * Removed printn statements and tweaked final test to be more asymmetric * Draft of spanning_tree_distribution * Black changes * Changed HK to only report on the support of the answer * Fixed contraction bug by changing to MultiGraph. Problem with prob > 1 * Black reformats * Fixed pypi test error * Further testing of dist fix * Can sample spanning trees * Developing test for sampling spanning tree * Changed sample_spanning_tree test to Chi squared test * Tweaked signifiance level * Found true minimum sample size * fixed typo * untested implementation of asadpour_tsp * Fixed issue reading flow_dict * Fixed runtime errors in asadpour_tsp * black reformats * Adding test cases * documentation update * Fixed rounding error with tests * One new test and check * Documentation update for the iterators * Attempting to fix class documentation * Pull out the style changes into a separate branch * fix mixed history * more Co-authored-by: Thodoris Sotiropoulos <theosotr@windowslive.com> Co-authored-by: Luca Cappelletti <cappelletti.luca94@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: mjschwenne <mjschwenne@gmail.com>
* bugfix-for-issue-4353: modify default edge_id format (#4842)Berlin Cho2021-06-141-0/+102
| | | | Allow selection of an edge attribute to be the edge id when writing GraphML. Adds edge_id_from_attribute kwarg.
* Decode GraphML/yEd shape type (#4694)Attila Nagy2021-06-141-0/+35
| | | | Decode and preserve GraphML/yEd shape type and add tests for description and yworks GenericNode
* Deserializing custom default properties graph ml (#4872)Jeroen Bergmans2021-06-071-0/+39
| | | | * Add test case for handling default node attributes from graphML * Add decode conversion to key defaults analogous to decode_data_elements
* Refactor testing utilities (#4829)Jarrod Millman2021-05-268-117/+111
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Refactor testing utilities Change `assert_edges_equal`, `assert_graphs_equal`, and `assert_nodes_equal` to be more pytest-idiomatic. For example, `assert_edges_equal` becomes the Boolean function `edges_equal` and then the assert is done the testing file (i.e., `assert edges_equal(edges1, edges2)`). This also makes these utility functions useful in nontesting situations where you want to compare edges, but not raise an exception based on the result. * Move testing utility functions * Use new testing utilities * Deprecate assert_*_equal testing utilities * Document node, edge, and graph equality helper functions * text nits. * Update networkx/tests/test_convert_pandas.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/readwrite/tests/test_sparse6.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/readwrite/tests/test_graph6.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/generators/tests/test_classic.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/tests/test_operations.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tree/tests/test_coding.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/tests/test_dag.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * Update networkx/algorithms/minors/tests/test_contraction.py Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> * add short equality description to docstring * Suppress known warnings Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Dan Schult <dschult@colgate.edu>
* Use pytest.approx (#4827)Jarrod Millman2021-05-211-3/+2
| | | | | * Use pytest.approx * Deprecate almost_equal
* Remove pyyaml dependency via module getattr (#4802)Ross Barnowski2021-05-202-50/+38
| | | | | | | | | | | | | | | | | | | | | | | | | * WIP: adding getattr to nx_yaml module. * WIP: Tests that informative exceptions raised. * Add tests for informative messages. * Add getattrs to higher-up pkgs. * Remove test_yaml.py * Remove pyyaml from requirements. * Update examples in warning messages. Ensure they are correct, runnable examples. * Add security warning and removal time to message. * Cp __getattr__ to other mods/pkgs. * Update deprecation notes w/ getattrs. * Remove yaml section from docs.
* Fixes read/write_gml with nan/inf attributes (#4497)happy2021-05-201-0/+103
| | | | | | | | | | | | | * handle nan/inf for gml files * handle nan/inf for gml files * ran black * Better fix for nan/inf. * add tests for special floats in gml.py Co-authored-by: Dan Schult <dschult@colgate.edu>
* TST: be more explicit about instance comparison. (#4748)Ross Barnowski2021-04-212-14/+14
| | | | | Some tests relied on __eq__ or __ne__ to check whether or not two Graph instances where the same instance. Use is and is not instead.
* TST: An approach to parametrizing read_edgelist tests. (#4292)Ross Barnowski2021-01-051-120/+127
| | | | | | | | | | | | | * TST: An approach to parametrizing read_edgelist tests. Use parametrization to improve code re-use. Pull tests outside class. * TST: Add tests for parse_edgelist. Co-authored-by: Andrew Eckart <andrew.g.eckart@gmail.com> Co-authored-by: Andrew Eckart <andrew.g.eckart@gmail.com>
* Add random_ordered_tree and forest_str (#4294)Jon Crall2020-12-171-0/+315
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Add random_ordered_tree and forest_str * Update networkx/generators/trees.py I think this makes sense. Co-authored-by: Dan Schult <dschult@colgate.edu> * Remove random_ordered_tree * Fix bug in random_tree when n=1 and create_using is specified * Add ascii_only mode to forest_str * fix test * wip * Fix comments * Typo in ascii glyph * Remove reference to OrderedDiGraph * Removed imports in doctests Co-authored-by: Dan Schult <dschult@colgate.edu>
* Remove xml import checks (#4393)Jarrod Millman2020-11-262-3/+0
|
* Use matrix multiplication operator (#4390)Jarrod Millman2020-11-251-6/+3
| | | Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* MAINT: remove deprecated numpy type aliases. (#4373)Ross Barnowski2020-11-201-1/+1
| | | Suppress deprecation warnings from numpy 1.20.
* Move a few imports inside functions to improve import speed of the library ↵Dan Schult2020-11-121-0/+51
| | | | | | | | | | | | | | | | | | | | | (#4296) * move scipy imports into functions * run black * Move xml and lxml import inside functions in graphml.py * Move imports inside functions * Add tests to graphml.py to appease the codecov CI * rearrange KDTree import handling * remove global np from alg_connectivity code * fix black * fix black
* Improve readwrite test coverage (#4310)Jarrod Millman2020-10-311-0/+25
| | | | - tree_graph - edgelist
* Cleanup old platforms (#4202)Jarrod Millman2020-09-101-4/+1
| | | | | * Remove IronPython code * Remove Jython code
* graphml: re-add graph attribute type 'long' after 857aa81 removed it (#4189)josch2020-09-051-0/+23
| | | closes: #4188
* Format python in docstrings (#4168)Jarrod Millman2020-08-192-5/+3
| | | | | | | | | | | | | | | | | | | * Format code w/ black * Format docstrings w/ black * Manual cleanup * Tell pytest to ignore planned deprecations * Don't call plt.show during testing * Another known deprecation * DOC: rm duplicate line from docstring example * Minor cleanup Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Add edge label in GEXF writer as an optional attribute (#3347)Jonathan Schneider2020-08-161-3/+4
| | | | | | | * Add edge label * Add some tests to ensure label is a keyword attribute Co-authored-by: Dan Schult <dschult@colgate.edu>
* MultiGraph from graphml with explicit edge ids #3470 (#3763)kiryph2020-08-161-16/+160
| | | | | | | | | | | | | | | | | | | | * MultiGraph from graphml with explicit edge ids #3470 Prior this commit, a graph with explicit edge ids but no parallel edges stored in a graphml was converted to a Graph and the edge ids were moved to the edge data. This behaviour has been removed. * clean up multigraph handling in read_graphml and friends Added changes to parse_graphml too. multigraph returned when parallel edges exist in file or when new argument "force_multigraph" is True * test parse_graphml and edge_key_type better and cleanup * more tests Co-authored-by: Dan Schult <dschult@colgate.edu>
* Fix parse_edgelist behavior with multiple attributes (#4125)Christoph Martin2020-08-031-0/+42
| | | | | | | * Fix parse_edgelist behavior with multiple attributes * fixed test case Co-authored-by: chris <chris@orchid>
* Format w/ blackJarrod Millman2020-07-1012-461/+533
|
* Correctly infer numpy float types (#3919)Alex Henrie2020-07-051-0/+11
|
* Add option for named key ids to GraphML writing. (#3960)ryan-duve2020-05-171-0/+75
| | | | | | | | | | | * Add option for named key ids to GraphML writing. * Remove 'is True' for PEP8 compliance. * Added tests to confirm the named key ids are written as expected. * Add test showing the read graph's nodes and edges are the same when written with both the default behavior and with the named id attributes. Co-authored-by: dnp <you@example.com>
* Update string formatJarrod Millman2020-01-011-24/+24
| | | | | | | | | find -name "*py" | xargs grep -n '" % ' find -name "*py" | xargs grep -n '"\.format(' find -name "*py" | xargs grep -n "' %" find -name "*py" | xargs grep -n 'msg % ' find -name "*py" | xargs grep -n ' %d ' find -name "*py" | xargs grep -n '\.format('
* Upgrade to Py36 syntaxJarrod Millman2020-01-019-16/+15
| | | | find networkx -name \*.py -exec pyupgrade --py36-plus {} \;
* 3511 gml list support (#3649)Anton Lodder2019-12-121-0/+96
| | | | | | | * 3511 -- GML: Add type/enum for better readibility * 3511 -- Always write multiple values to list Fixes #3511
* Update styleJarrod Millman2019-11-181-134/+147
|
* Fix test_numpy_type to pass under Python 3.8Steve Kowalik2019-11-141-1/+50
| | | | | | | | readwrite.tests.test_gexf.TestGEXF.test_numpy_type failed under Python 3.8 due to ordering of XML attributes, handle it as per f75dbe8. Also change travis to no longer allow failures under 3.8. Fixes #3720
* Remove shebang from non-executablesJarrod Millman2019-11-116-6/+0
|
* Remove superfluous encoding informationJarrod Millman2019-11-112-2/+0
|