summaryrefslogtreecommitdiff
path: root/networkx/convert.py
Commit message (Collapse)AuthorAgeFilesLines
* Use scipy.sparse array datastructure (#6037)Jarrod Millman2022-10-121-1/+1
| | | | | | | | | | | | | | * Use scipy.sparse array datastructure * Add reminder to rm wrapper when scipy adds creation fns. * Rm mention of np matrix from code comment. * Update networkx/algorithms/bipartite/matrix.py Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com> Co-authored-by: Ross Barnowski <rossbar@berkeley.edu> Co-authored-by: Stefan van der Walt <sjvdwalt@gmail.com>
* Update tests in base class and simple rename in convert.py (#5848)Dan Schult2022-07-151-4/+4
|
* remove to/from_scipy_sparse_matrix (#5779)Matt Schwennesen2022-07-011-4/+4
| | | | | | | | * remove to/from_scipy_sparse_matrix * skip geospatial example build Co-authored-by: Mridul Seth <seth.mridul@gmail.com> Co-authored-by: Mridul Seth <mail@mriduls.com>
* Use isort with pre-commit to enforce import guidelines (#5659)Mridul Seth2022-06-021-1/+2
| | | | | * Add isort to pre-commit * Run isort on all python files (except __init__.py ones)
* More numpy.matrix cleanups for NX2.7 (#5319)Ross Barnowski2022-02-121-3/+2
| | | | | | | | | | | | | | | | | | | * Fix return type in docstring of internal function. * Rm explicit mention of numpy matrix from class docstrings. * Fix return type of floyd_warshall_numpy docstring. * Remove mention of numpy matrix from code comment. * Fix simrank similarity internal docstring. * Rm explicit mention of matrix in favor of 2D array. * Update to_networkx_graph array exception wording. * Remove extraneous mention of numpy matrix. * Don't print array in exception message.
* A few `np.matrix` cleanups (#5218)Ross Barnowski2021-12-091-2/+2
| | | | | | | | | | * Use toarray instead of todense in test suite. toarray is less ambiguous and forward-compatible. * Rm isinstance target and use from_numpy_array. np.matrix is a sublcass of ndarray so there is no need to explicitly include it in the isinstance tuple.
* Change exception varname e to err (#5130)Dan Schult2021-10-151-18/+18
| | | | 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.
* add special processing of `multigraph_input` upon graph init (#4823)Dan Schult2021-05-271-6/+11
| | | | | | | | | | | | | | | | | | * add special processing of `multigraph_input` upon graph init Fixes: #4720 Adding a keyword argument `multigraph_input=True` to a graph construction call should treat any incoming input data for the graph as a dict-of-dict-of-dict multigraph data structure. Previously the multigraph_input argument would be added to the graph attribute dict and ignored when processing the input data. * Change default and add tests * make default try mgi=True, and if fails try mgi=False * copy parameter docstring to main class
* Use matrix multiplication operator (#4390)Jarrod Millman2020-11-251-2/+2
| | | Co-authored-by: Ross Barnowski <rossbar@berkeley.edu>
* Improve test coverage of convert module (#4306)Ross Barnowski2020-11-241-8/+8
| | | | | | | * TST: Improve coverage of conversion module. * WIP: Remove attr checks for graph/nodes? * TST: remove to_dict_of_dict tests.
* Address comments from code review.Ross Barnowski2020-11-121-4/+6
|
* Minor touchups to docstringRoss Barnowski2020-11-051-6/+6
|
* Update docstring of to_dict_of_dicts.Ross Barnowski2020-11-051-6/+85
| | | | Better document edge_data behavior. Add examples.
* Simplify importsJarrod Millman2020-09-151-2/+1
|
* Format python in docstrings (#4168)Jarrod Millman2020-08-191-7/+7
| | | | | | | | | | | | | | | | | | | * 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>
* MAINT: Switch to abc-based isinstance checks in to_networkx_graph (#4136)Ross Barnowski2020-08-071-11/+14
| | | | | | | | | * MAINT: use ABCs in conversion function. Switch to using ABC-based isinstance checks in to_networkx_graph. Note: order of execution matters - most general check must be last. * DOC: Update docstring
* use raise from for exceptions in to_networkx_graph (#4009)anentropic2020-06-211-16/+18
| | | Fixes #4002
* allow set of edge nodes (#3907)Mattwmaster582020-04-151-2/+2
| | | | | | | * allow set of edge nodes * clarify documentation Fixes #3884
* Fix scipy deprecation warningsJarrod Millman2020-01-031-43/+61
|
* Remove boiler plate from top of modulesJarrod Millman2019-11-111-11/+3
| | | | | | | | | The copyright and author stuff is not necessary, out-of-date, and inconsistent. It takes up visual space and is a pain to police everyone doing the same thing on the top of the module. Git handles authorship in a comprehensive and authoritative way. The LICENSE.txt file applies to all project code.
* Replacing `Return` to `Returns` in docs for functions (#3301)Moradnejad2019-02-181-6/+6
| | | | | | * Fixed problem in documentation view of this function * Replacing `Return` to `Returns` in function docs
* converter node_attr_dict override fixed. (#3215)Ramil Nugmanov2018-10-301-1/+5
| | | | | | * converter node_attr_dict override fixed. * tests and comments added.
* Enable create_using to be a constructor (#3004)Dan Schult2018-06-171-33/+16
| | | Related to #1393
* Misc. typos (#2872)luzpaz2018-02-141-1/+1
| | | | | | | | | | Found via `codespell -q 3 -I ../networkx-whitelist.txt` where whitelist consisted of: ``` ans childs iff nd te ```
* Comply with pep8Jarrod Millman2017-08-171-6/+3
|
* Comply with pep8Jarrod Millman2017-08-131-11/+8
|
* Add testsJarrod Millman2017-08-121-14/+15
|
* Create separate functions for df as edge-lists and adjacency matricesJarrod Millman2017-08-121-5/+12
| | | | | | | | Fixes #2464. Some related commits: 52eb3d3: from_pandas_dataframe and to_pandas_dataframe were added to work with adjacency matrix. f0c22dd: from_pandas_dataframe was changed to work with edge-lists, but to_pandas_dataframe was not changed.
* Simplify base classes. (#2604)Dan Schult2017-08-121-2/+2
| | | | | | | | | | * move selfloop methods out of graph classes into function.py * replace G.node with G.nodes. fix Pickle of views * Replace G.edge with G.edges * Add a few lines of docs for release realted to this PR.
* Fix call to `from_pandas_dataframe` from `to_networkx_graph` (#2490)Jarrod Millman2017-06-301-105/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | * Fix call to `from_pandas_dataframe` from `to_networkx_graph`, fixes #2111 To make this clean, I decided to make `from_pandas_dataframe` only require one argument by changing the signature from ``` def from_pandas_dataframe(df, source, target, edge_attr=None, create_using=None): ``` to ``` def from_pandas_dataframe(df, source='source', target='target', edge_attr=None, create_using=None): ``` I added additional tests and expanded a doctest. * Skip tests if pandas not installed * Fix docstring for `to_networkx_graph` * Comply with pep8 and cleanup imports
* Move data structure to private names and replace with readonly structures ↵Dan Schult2017-06-261-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (#2475) * Dont assume iterators for nodes/edges/degrees (prep for views) * Add graph view classes for nodes/edges/degree * Add right set operations (not present in python3.3 KeysView * Add nodes before adding edges so python36 tests work By only adding edges, the nodes were added in order (0,1,3,2) and with the ordered nature of python3.6 dicts the tests failed. Could also fix by using nodelist on each call to to_convert_... * weighted graph convert tests testing empty graphs The edge iterator was exhausted for source before being used for dest * allow DegreeView to include case of nbunch * Make node/edge/degree properties of Graph * View contains fix and Viewers can return self. More tests * Add more tests including one for #2347 * Add nbunch tests and pep8 * Rename to EdgeView and EdgeDataView * docs tweaks and pep8 * fix up nodeDataView contains. Add and clean up tests. * Change the graph attributes to read-only properties * Reframe views code and extend _node to all networkx (still need examples) * Clean up and pep8 for view changes * ername AtlasViews, simplify code and add docstrings * Make G[u] return a view, and catch some doc bugs * Update views to use _node,_adj. Add len to EdgeDataView * minor adjustments to example subclass/printgraph
* Add graph view classes for nodes/edge/degrees (#2458)Dan Schult2017-06-131-3/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * Dont assume iterators for nodes/edges/degrees (prep for views) * Add graph view classes for nodes/edges/degree * Add right set operations (not present in python3.3 KeysView * Add nodes before adding edges so python36 tests work By only adding edges, the nodes were added in order (0,1,3,2) and with the ordered nature of python3.6 dicts the tests failed. Could also fix by using nodelist on each call to to_convert_... * weighted graph convert tests testing empty graphs The edge iterator was exhausted for source before being used for dest * allow DegreeView to include case of nbunch * Make node/edge/degree properties of Graph * View contains fix and Viewers can return self. More tests * Add more tests including one for #2347 * Add nbunch tests and pep8 * Rename to EdgeView and EdgeDataView * docs tweaks and pep8 * fix up nodeDataView contains. Add and clean up tests. * Tweaks to improve speed for nodes and edges. * improve views dependence on ABCs, remove len from dataviews * First pass on docs in views.py * Change property to lazy attribute
* Removes unnecessary convert_to_(un)directed funcJeffrey Finkelstein2016-09-211-10/+0
|
* Update add_edge calls to use update for edge attributes.thegreathippo2016-05-011-1/+2
| | | | | | | Since convert and convert_matrix both might be called upon to convert graphs with non-string attributes, it was necessary to modify the code so that the edge attributes are updated via the dict's built-in update rather than simply passing the values as keyword arguments.
* Change sphinx config to improve parametersDan Schult2016-03-081-1/+2
| | | | | | | | Now can use parameters ```x, y : nodes```. It used to convert to ```y(x,) : nodes``` That conf.py change caused blank lines to give a warning so removed them. Misc word changes.
* Examples and doc changesDan Schult2016-01-111-2/+2
|
* to_networkx_graph needs .update() instead of new dictDan Schult2015-08-071-4/+4
| | | | | | In convert.to_networkx_graph, we need to use create_using.node.update() instead of creating a new dict for the node atrributes. We were overwriting instead of updating.
* Update adjacency_iter() method to adjacency() and remove adjacency_list()Mridul Seth2015-07-031-2/+2
|
* Minor docstring updates.chebee7i2015-01-051-6/+6
|
* added Pandas Dataframe into to_networkx_graphJamal2015-01-051-0/+13
|
* Simplifies _prep_create_using functionjfinkels2014-12-051-8/+6
|
* Split matrix conversion functions into new moduleAric Hagberg2013-11-121-508/+11
|
* Merge pull request #992 from hagberg/hashrandom-test-fixesAric Hagberg2013-11-081-2/+6
|\ | | | | Fix tests that fail due to hash randomization
| * Fix tests that fail due to hash randomizationAric Hagberg2013-10-231-2/+6
| |
* | Merge pull request #976 from chebee7i/fw_bugAric Hagberg2013-11-081-35/+73
|\ \ | |/ |/| Subtle bug in floyd_warshall_numpy
| * Revert commits 1bca2d1 and 31b5b70.chebee7i2013-10-241-57/+58
| |
| * Handle nonzero edges via masked arrays.chebee7i2013-10-241-46/+43
| | | | | | | | Also, allow custom multigraph_weight opertor functions.
| * Allow 'weight' to be callable.chebee7i2013-10-241-12/+14
| | | | | | | | For example, weight=lambda attrs: attrs.get('weight', 0).
| * Clarify description of `weight` parameter.chebee7i2013-10-241-1/+2
| |
| * Make `nonedge` default to 0.0. Add more comments.chebee7i2013-10-241-18/+40
| |