Opened 15 months ago

Last modified 3 months ago

#31608 needs_info enhancement

Eliminate pynac's handle_factor method

Reported by: gh-DaveWitteMorris Owned by:
Priority: minor Milestone: sage-9.7
Component: symbolics Keywords: pynac, refactoring
Cc: Merged in:
Authors: Frédéric Chapoton Reviewers:
Report Upstream: N/A Work issues:
Branch: u/chapoton/31608 (Commits, GitHub, GitLab) Commit: b2d366108836694f50299ae9559b71fe8f36478e
Dependencies: Stopgaps:

Status badges

Description

After #31554, the handle_factor method will be used in only 3 places in the pynac source code:

expairseq.cpp:994:  ex newfactor = mf.handle_factor(elem, _ex1);
expairseq.cpp:1003: ex newfactor = mf.handle_factor(elem, _ex1);
expairseq.cpp:1049: combine_overall_coeff(ex_to<numeric>(mf.handle_factor(elem.rest, _ex1)));

It is completely unnecessary in those places, because handle_factor(x, 1) is equal to x. So we should refactor the code to get rid of it (and the class make_flat_inserter that contains it).

Here is the definition:

class make_flat_inserter
{
	public:
		make_flat_inserter(const epvector &epv, bool b)
		{}
		make_flat_inserter(const exvector &v, bool b)
                {}
		ex handle_factor(const ex &x, const ex &coeff)
		{
			if (is_exactly_a<numeric>(coeff) and coeff.is_zero())
				return coeff;
		        return x;
		}
};

Change History (6)

comment:1 Changed 11 months ago by mkoeppe

  • Milestone changed from sage-9.4 to sage-9.5

comment:2 Changed 6 months ago by mkoeppe

  • Milestone changed from sage-9.5 to sage-9.6

comment:3 Changed 4 months ago by chapoton

  • Authors set to Frédéric Chapoton
  • Branch set to u/chapoton/31608
  • Commit set to b2d366108836694f50299ae9559b71fe8f36478e
  • Status changed from new to needs_review

tentative commit


New commits:

b2d3661remove handle_factor

comment:4 Changed 4 months ago by chapoton

seems to go smoothly..

comment:6 Changed 3 months ago by mkoeppe

  • Milestone changed from sage-9.6 to sage-9.7
  • Status changed from needs_review to needs_info
Note: See TracTickets for help on using tickets.