Comments (5)
from mathgenerator.
Getting 0 every time
@autosaver Are you overriding the max_decimal
kwarg with decimal_to_roman_numerals(max_decimal=0)
or decimal_to_roman_numerals(0)
?
mathgenerator/mathgenerator/misc.py
Line 193 in 6e11124
from mathgenerator.
@lukew3 I edited the gen_func()
associated with decimal_to_roman_numerals
(in the site-packages folder where mathgenerator got pip installed) and was able to resolve the issue.
In the above snippet, I added a line (as you did in misc.py)
x_copy = x
Then in the above snippet, I changed the f-string in the problem statement to reflect the correct variable name.
These fixes corrected the issue, but I'm not sure how to reflect these in my fork to then pull request it as this file isn't in the repository but in the pip installation? I am new to open source contribution so please let me know if I have misread something somewhere or missed a file that's in the fork.
from mathgenerator.
Getting 0 every time
@autosaver Are you overriding the
max_decimal
kwarg withdecimal_to_roman_numerals(max_decimal=0)
ordecimal_to_roman_numerals(0)
?mathgenerator/mathgenerator/misc.py
Line 193 in 6e11124
Actually I was calling it directly without variable
from mathgenerator.
It seems its using :
from ...generator import Generator
import random
import math
def gen_func(maxDecimal=4000):
x = random.randint(0, maxDecimal)
roman_dict = {
1: "I",
5: "V",
10: "X",
50: "L",
100: "C",
500: "D",
1000: "M"
}
div = 1
while x >= div:
div *= 10
div /= 10
solution = ""
while x:
last_value = int(x / div)
if last_value <= 3:
solution += (roman_dict[div] * last_value)
elif last_value == 4:
solution += (roman_dict[div] + roman_dict[div * 5])
elif 5 <= last_value <= 8:
solution += (roman_dict[div * 5] + (roman_dict[div] * (last_value - 5)))
elif last_value == 9:
solution += (roman_dict[div] + roman_dict[div * 10])
x = math.floor(x % div)
div /= 10
problem = f"The number ${x}$ in Roman Numerals is: "
return problem, f'${solution}$'
decimal_to_roman_numerals = Generator("Converts decimal to Roman Numerals", 85,
gen_func,
["maxDecimal=4000"])
Trying to upgrade mathgenerator
from mathgenerator.
Related Issues (20)
- Fix long import times
- CalcuLaTeX Integration HOT 1
- [Gen Idea]: Sum of interior angles of n sided polygon HOT 1
- gcd duplicate generators
- algebra/expanding string integer out of range error HOT 1
- intersection_of_two_lines is likely duplicate of system_of_equations
- Use snake case instead of camelCase or PascalCase for variables and functions
- Use raw strings for latex generation
- intersection_of_two_lines use latex \frac
- mathgenerator as a npm package? HOT 8
- [Gen Idea]: Simplify square root HOT 4
- Create script to generate a gif showcasing generated problems/solutions
- KaTeX based rendering for docs
- Complex to Polar Function Problem/Solution is unclear
- Wrong answer if the coeficient of the variable is equal to the constant while generating algebra, HOT 1
- Phase out sympy and scipy HOT 2
- [Gen Idea]: Adding word problems HOT 1
- the implement of surface_area_pyramid is wrong HOT 2
- Create a solution explainer?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mathgenerator.