bgp.functions package

Submodules

bgp.functions.dimfunc module

Notes

These are some of parts coped from sympy.

class bgp.functions.dimfunc.Dim(data)

Bases: numpy.ndarray

Redefine the Dimension of sympy, the default dimension SI system with 7 number.

1.can be constructed by list of number.

2.can be translated from a sympy.physics.unit.

Examples:

from sympy.physics.units import N
scale,dim = Dim.convert_to_Dim(N)

Examples:

dim=[1,0,1,0,1,0,0]
dim = Dim(dim)

Notes

self.unit = [str(i) for i in SI._base_units]

self.unit_map = {‘meter’: “m”, ‘kilogram’: “kg”, ‘second’: “s”, ‘ampere’: “A”, ‘mole’: “mol”, ‘candela’: “cd”, ‘kelvin’: “K”}

self.dim = [‘length’, ‘mass’, ‘time’, ‘current’, ‘amount_of_substance’, ‘luminous_intensity’, ‘temperature’]

allisnan()
anyisnan()
classmethod convert_to(expr, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!!

classmethod convert_to_Dim(u, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!!

Parameters
  • u (sympy.physics.unit, Expr of sympy.physics.unit) – unit.

  • target_units (None, list of sympy.physics.unit) – if None, the target_units is 7 SI units

  • unit_system (str) – default is unit_system=”SI”

classmethod convert_x(x, u, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!! Quick method. translate x and u to standard system.

Parameters
  • x (np.ndarray or list of ndarray,list of float,list of int) – x

  • u (list of sympy.physics.unit or Expr of sympy.physics.unit) – units

  • target_units (None or list of sympy.physics.unit) – if None, the target_units is 7 SI units

  • unit_system (str) – default is unit_system=”SI”

Returns

  • x (np.ndarray)

  • expr (Expr)

classmethod convert_xi(xi, ui, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!! Quick method. translate xi and ui to standard system.

Parameters
  • xi (np.ndarray) – xi

  • ui (sympy.physics.unit or Expr of sympy.physics.unit) – unit

  • target_units (None or list of sympy.physics.unit) – if None, the target_units is 7 SI units

  • unit_system (str) – default is unit_system=”SI”

Returns

  • xi (np.ndarray)

  • expr (Expr)

get_n(others)
classmethod inverse_convert(dim, scale=1, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!! Quick method. Translate ui to other unit.

Parameters
  • dim (Dim) – dim

  • scale (float) – scale generated before.

  • target_units (None or list of sympy.physics.unit) – if None, the target_units is 7 SI units

  • unit_system (str) – default is unit_system=”SI”

Returns

  • scale (float)

  • expr (Expr)

classmethod inverse_convert_xi(xi, dim, scale=1, target_units=None, unit_system='SI')

depend on sympy 1.5-1.6!!! Quick method. Translate xi, dim to other unit.

Parameters
  • xi (np.ndarray) – xi

  • dim (Dim) – dim

  • scale (float) – if xi is have been scaled, the scale is 1.

  • target_units (None or list of sympy.physics.unit) – if None, the target_units is 7 SI units

  • unit_system (str) – default is unit_system=”SI”

Returns

  • scale (float)

  • expr (Expr)

is_same_base(others)
isfloat()
isinteger()
bgp.functions.dimfunc.check_dimension(x, y=None)

check the consistency of dimension.

Parameters
  • x (container) – dim of x

  • y (Dim) – dim of y

Returns

Return type

bool

bgp.functions.dimfunc.dim_map()

expr to dim function

bgp.functions.gsymfunc module

class bgp.functions.gsymfunc.NewArray(iterable, shape=None, **kwargs)

Bases: sympy.tensor.array.dense_ndim_array.ImmutableDenseNDimArray

as_coefficient(_)
default_assumptions = {}
bgp.functions.gsymfunc.gsym_map()

user’s sympy.expr to np.ndarray function

bgp.functions.newfunc module

bgp.functions.newfunc.check_funcD(funcs, self_grpup=2)

self_group>=2

bgp.functions.newfunc.newfuncD(operation, name='Fc', keep=True, is_jump=False, check=True)
Parameters
  • operation (callable) – the detail of opearation only accept +,-,*,/,-(negative),x^n

  • name (str) – name

  • keep (bool) – the group size after this function. true is the input size,and false is 1.

  • is_jump (bool) – the bool means the rem and rem_dim can be treat 2+ domension problems or not.

  • check (bool) – check the function building

bgp.functions.newfunc.newfuncV(operation, arity=1, name='Fc')
Parameters
  • operation (callable) – the detail of operation only accept +,-,*,/,abs,-(negative),x^n.

  • arity (int) – the arity of operation.

  • name (str) – name.

bgp.functions.npfunc module

bgp.functions.npfunc.np_map()

user’s sympy.expr to np.ndarray function

bgp.functions.symfunc module

bgp.functions.symfunc.sym_dispose_map()

user’s str to sympy.expr function

bgp.functions.symfunc.sym_vector_map()

str to sympy.Expr function

Module contents

Notes: the translation process

the three function should be the same key. 1. sym_vector_map: repr of SymbolTree to sympy.Function sym_dispose_map: repr of SymbolTree to “group” sympy.Function. 2. np_map(): repr of “group” sympy.Function to numpy function 3. dim_map(): repr of “group” sympy.Function to Dim function 4. gsym_map():repr of “group” sympy.Function to universal sympy.Function