Opened 2 years ago

Closed 2 years ago

#24126 closed enhancement (fixed)

py3: some more care for keys()[...]

Reported by: chapoton Owned by:
Priority: major Milestone: sage-8.1
Component: python3 Keywords:
Cc: tscrim, jdemeyer, jhpalmieri Merged in:
Authors: Frédéric Chapoton Reviewers: Jeroen Demeyer
Report Upstream: N/A Work issues:
Branch: 62750bf (Commits) Commit: 62750bfca20fa155c92687570657bf923eaeb41b
Dependencies: Stopgaps:

Description

similar to #23824 and #23831, part of #15981

Change History (11)

comment:1 Changed 2 years ago by chapoton

  • Branch set to u/chapoton/24126
  • Cc tscrim jdemeyer jhpalmieri added
  • Commit set to 6015764ed91081b13c701b825dac755eebee51d8
  • Status changed from new to needs_review

New commits:

6015764py3: some more care for keys()[...]

comment:2 Changed 2 years ago by jdemeyer

Replace list(d.keys()) by list(d) for a dict d.

comment:3 Changed 2 years ago by jdemeyer

And replace list(d.keys())[0] by next(iter(d)).

comment:4 Changed 2 years ago by git

  • Commit changed from 6015764ed91081b13c701b825dac755eebee51d8 to 9e4208d5c42c74a7b69a4f9f0d46042ed0280972

Branch pushed to git repo; I updated commit sha1. New commits:

9e4208dtrac 24126 better like that

comment:5 Changed 2 years ago by chapoton

Thanks, done.

comment:6 Changed 2 years ago by jdemeyer

  1. In src/sage/numerical/mip.pyx and src/sage/numerical/sdp.pyx, you can remove the assert statements.
  1. In src/sage/rings/polynomial/multi_polynomial_element.py, you still have list(x.dict().keys())[0]
  1. In src/sage/rings/polynomial/multi_polynomial_element.py you can simplify
    range( 0 , max(m[var_idx] for m in monomial_coefficients.keys())+1 )
    

to

range(max(m[var_idx] for m in monomial_coefficients) + 1)
  1. In src/sage/graphs/graph.py and src/sage/graphs/digraph.py, I would write
            if format is None and isinstance(data, dict):
                if not data:
                    format = 'dict_of_dicts'
                else:
                    val = next(iter(data.values()))
                    if isinstance(val, list):
                        format = 'dict_of_lists'
                    elif isinstance(val, dict):
                        format = 'dict_of_dicts'
    

comment:7 Changed 2 years ago by git

  • Commit changed from 9e4208d5c42c74a7b69a4f9f0d46042ed0280972 to 62750bfca20fa155c92687570657bf923eaeb41b

Branch pushed to git repo; I updated commit sha1. New commits:

62750bftrac 24126 even better

comment:8 Changed 2 years ago by chapoton

Thanks again. Now done.

comment:9 Changed 2 years ago by chapoton

and bot is green

comment:10 Changed 2 years ago by jdemeyer

  • Reviewers set to Jeroen Demeyer
  • Status changed from needs_review to positive_review

comment:11 Changed 2 years ago by vbraun

  • Branch changed from u/chapoton/24126 to 62750bfca20fa155c92687570657bf923eaeb41b
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.