Package: rithm
rithmIn what followspythonis an alias forpython3.8orpypy3.8or any later version (python3.9,pypy3.9and so on).InstallationInstall the latestpip&setuptoolspackages versionspython-mpipinstall--upgradepipsetuptoolsUserDownload and install the latest stable version fromPyPIrepositorypython-mpipinstall--upgraderithmDeveloperDownload the latest version fromGitHubrepositorygitclonehttps://github.com/lycantropos/rithm.gitcdrithmInstall dependenciespython-mpipinstall-rrequirements.txtInstallpythonsetup.pyinstallUsagePythonArbitrary precision integerWith setup>>>fromrithm.integerimportIntwe can:construct>>>Int()Int(0)>>>Int(9)Int(9)>>>Int('9')Int(9)>>>Int('0b1001',2)Int(9)>>>Int('0o11',8)Int(9)>>>Int('0x9',16)Int(9)>>>Int('1001',2)Int(9)>>>Int('0o11',8)Int(9)>>>Int('9',16)Int(9)>>>Int(9.99)Int(9)compare>>>Int(9)==Int(9)True>>>Int(9)>=Int(9)True>>>Int(9)>Int(8)True>>>Int(9)<=Int(9)True>>>Int(9)<Int(10)Truecalculate>>>abs(Int(-9))Int(9)>>>Int(4)+Int(5)Int(9)>>>Int(9)&Int(11)Int(9)>>>Int(19)//Int(2)Int(9)>>>~Int(-10)Int(9)>>>Int(19)%Int(10)Int(9)>>>Int(3)*Int(3)Int(9)>>>-Int(-9)Int(9)>>>Int(1)|Int(8)Int(9)>>>Int(3)**Int(2)Int(9)>>>Int(5)<<Int(1)Int(10)>>>Int(5)>>Int(1)Int(2)>>>Int(25)-Int(16)Int(9)>>>Int(18)/Int(2)Fraction(Int(9),Int(1))>>>Int(2)^Int(11)Int(9)Exact fractionWith setup>>>fromrithm.fractionimportFractionwe can:construct>>>Fraction()Fraction(Int(0),Int(1))>>>Fraction(1)Fraction(Int(1),Int(1))>>>Fraction(1,2)Fraction(Int(1),Int(2))>>>Fraction(50,100)Fraction(Int(1),Int(2))>>>Fraction(0.5)Fraction(Int(1),Int(2))compare>>>Fraction(1,2)==Fraction(1,2)True>>>Fraction(1,2)>=Fraction(1,2)True>>>Fraction(1,2)>Fraction(1,3)True>>>Fraction(1,2)<Fraction(2,3)True>>>Fraction(1,2)!=Fraction(1,3)Truecalculate>>>abs(Fraction(-1,2))Fraction(Int(1),Int(2))>>>Fraction(1,3)+Fraction(1,6)Fraction(Int(1),Int(2))>>>Fraction(3,2)//Fraction(1)Int(1)>>>Fraction(3,2)%Fraction(1)Fraction(Int(1),Int(2))>>>Fraction(1,3)*Fraction(3,2)Fraction(Int(1),Int(2))>>>-Fraction(-1,2)Fraction(Int(1),Int(2))>>>Fraction(1,2)**2Fraction(Int(1),Int(4))>>>Fraction(3,2)-Fraction(1)Fraction(Int(1),Int(2))>>>Fraction(1,3)/Fraction(2,3)Fraction(Int(1),Int(2))RustArbitrary precision integer/// With setupusestd::convert::TryFrom;usetraiter::numbers::{Abs,DivEuclid,FromStrRadix,Pow,RemEuclid,Zero};userithm::big_int;#[cfg(target_arch ="x86")]typeDigit=u16;#[cfg(not(target_arch ="x86"))]typeDigit=u32;constDIGIT_BITNESS:usize=(Digit::BITS-1)asusize;const_:()=assert!(big_int::is_valid_digit_bitness::<Digit,DIGIT_BITNESS>());typeBigInt=big_int::BigInt<Digit,DIGIT_BITNESS>;/// we can:/// - constructassert_eq!(BigInt::zero(),0);assert_eq!(BigInt::from(9),9);assert_eq!(BigInt::try_from("9").unwrap(),9);assert_eq!(BigInt::try_from("0b1001").unwrap(),9);assert_eq!(BigInt::try_from("0o11").unwrap(),9);assert_eq!(BigInt::try_from("0x9").unwrap(),9);assert_eq!(BigInt::from_str_radix("1001",2).unwrap(),9);assert_eq!(BigInt::from_str_radix("11",8).unwrap(),9);assert_eq!(BigInt::from_str_radix("9",16).unwrap(),9);assert_eq!(BigInt::try_from(9.99).unwrap(),9);/// - compareassert!(BigInt::from(9)==BigInt::from(9));assert!(BigInt::from(9)>=BigInt::from(9));assert!(BigInt::from(9)>BigInt::from(8));assert!(BigInt::from(9)<=BigInt::from(9));assert!(BigInt::from(9)<BigInt::from(10));/// - calculateassert_eq!(BigInt::from(-9).abs(),9);assert_eq!(BigInt::from(4)+BigInt::from(5),9);assert_eq!(BigInt::from(9)&BigInt::from(11),9);assert_eq!(BigInt::from(1)|BigInt::from(8),9);assert_eq!(BigInt::from(2)^BigInt::from(11),9);assert_eq!(BigInt::from(19)/BigInt::from(2),9);assert_eq!(BigInt::from(19).div_euclid(BigInt::from(2)),9);assert_eq!(BigInt::from(3)*BigInt::from(3),9);assert_eq!(-BigInt::from(-9),9);assert_eq!(!BigInt::from(-10),9);assert_eq!(BigInt::from(3).pow(BigInt::from(2)),9);assert_eq!(BigInt::from(19)%BigInt::from(10),9);assert_eq!(BigInt::from(19).rem_euclid(BigInt::from(10)),9);assert_eq!(BigInt::from(5)<<1,10);assert_eq!(BigInt::from(5)>>1,2);assert_eq!(BigInt::from(25)-BigInt::from(16),9);Exact fraction/// With setupusestd::convert::TryFrom;usetraiter::numbers::{Abs,DivEuclid,One,Pow,RemEuclid,Zero};userithm::fraction;typeFraction=fraction::Fraction<i8>;/// we can:/// - constructassert_eq!(Fraction::zero(),0);assert_eq!(Fraction::one(),1);assert_eq!(Fraction::new(1,2),Some(Fraction::from(1)/2));assert_eq!(Fraction::new(50,100),Fraction::new(1,2));assert_eq!(Fraction::try_from(0.5).unwrap(),Fraction::new(1,2).unwrap());/// - compareassert!(Fraction::new(1,2).unwrap()==Fraction::new(1,2).unwrap());assert!(Fraction::new(1,2).unwrap()>=Fraction::new(1,2).unwrap());assert!(Fraction::new(1,2).unwrap()>Fraction::new(1,3).unwrap());assert!(Fraction::new(1,2).unwrap()<=Fraction::new(1,2).unwrap());assert!(Fraction::new(1,2).unwrap()<Fraction::new(2,3).unwrap());assert!(Fraction::new(1,2).unwrap()!=Fraction::new(1,3).unwrap());/// - calculateassert_eq!(Fraction::new(-1,2).unwrap().abs(),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(1,3).unwrap()+Fraction::new(1,6).unwrap(),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(1,3).unwrap()/Fraction::new(2,3).unwrap(),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(3,2).unwrap().div_euclid(Fraction::from(1)),1);assert_eq!(Fraction::new(1,3).unwrap()*Fraction::new(3,2).unwrap(),Fraction::new(1,2).unwrap());assert_eq!(-Fraction::new(-1,2).unwrap(),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(1,2).unwrap().pow(2),Fraction::new(1,4).unwrap());assert_eq!(Fraction::new(3,2).unwrap()%Fraction::from(1),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(3,2).unwrap().rem_euclid(Fraction::from(1)),Fraction::new(1,2).unwrap());assert_eq!(Fraction::new(3,2).unwrap()-Fraction::from(1),Fraction::new(1,2).unwrap());DevelopmentBumping versionPreparationInstallbump2version.Pre-releaseChoose which version number category to bump followingsemver
specification.Test bumping versionbump2version--dry-run--verbose$CATEGORYwhere$CATEGORYis the target version number category name, possible
values arepatch/minor/major.Bump versionbump2version--verbose$CATEGORYThis will set version tomajor.minor.patch-alpha.ReleaseTest bumping versionbump2version--dry-run--verbosereleaseBump versionbump2version--verbosereleaseThis will set version tomajor.minor.patch.Running testsInstall dependenciespython-mpipinstall-rrequirements-tests.txtPlainpytestInsideDockercontainer:withCPythondocker-compose--filedocker-compose.cpython.ymlupwithPyPydocker-compose--filedocker-compose.pypy.ymlupBashscript:withCPython./run-tests.shor./run-tests.shcpythonwithPyPy./run-tests.shpypyPowerShellscript:withCPython.\run-tests.ps1or.\run-tests.ps1cpythonwithPyPy.\run-tests.ps1pypy