-
Notifications
You must be signed in to change notification settings - Fork 1.4k
fix isTaxYearLeapYear #1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala
Outdated
Show resolved
Hide resolved
|
because this is the first pull request and something many people will see, I would like to say that I learned from a former project manager at the IRS that development on Direct File has stopped since January. the source code is only public because of federal law. it's not likely that this is going to be merged but it's possible that the components of Direct File might be used elsewhere edit: I have started work on OpenFile, a continuation of this project |
cjhskippy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I love that you dove in and looked for a place to replace a TODO comment for a band-aid and tried to resolve the problem at its root.
Adding a modulo operator seems like an elegant way to do this. Love it. One other thing that would make this a really elegant fix would be to include testing to match what was made public.
Other comp nodes appear to have tests to run against them that survived the repo going public. (ex: direct-file/fact-graph-scala/shared/src/test/scala/gov/irs/factgraph/compnodes/DivideSpec.scala ) Should the modulo operator?
Closing out in a compliment sandwich, I'm impressed that you jumped in to a new space with limited documentation and took a first swing that's pretty strong.
| private val operator = ModuloOperator() | ||
|
|
||
| def apply(lhs: CompNode, rhs: CompNode): BooleanNode = | ||
| if (lhs.getClass != rhs.getClass) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should these be restricted just to IntNode ? Not very familiar with scala but I imagine it could get weird with non-integer types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
other operators do limit the nodes that are usable, but there are three different types that could be used here: IntNode, DollarNode, and RationalNode. I really wasn't sure if this was going to be used later on so I just left it as an open type
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. I may be overly cautious.
My thinking was that both the dollar and rational types would often contain decimal values, which in many cases are probably not intended inputs to a modulo. Being restrictive could be a nice warning signal if anyone tries to use this in a way that doesn't work by mistake. If it turns out someone needs to use decimal or dollar inputs later on (and has a better math understanding than me of how that would make sense), it'd be fine to push the work of adding that support to when there's a use case for it.
That being said since you have the only use of modulo anywhere, my feedback is entirely around hypothetical future use.
direct-file/fact-graph-scala/shared/src/main/scala/gov/irs/factgraph/compnodes/Modulo.scala
Outdated
Show resolved
Hide resolved
fmhall
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
jcsumlin
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Co-authored-by: Josh Junon <Qix-@users.noreply.github.com>
|
😆 first time dealing with a force push, sorry if anyone got pinged |
|
Just looking at this: ([divisible by 4] or [divisible by 100 and 400]). It is not correct. For example 2100 is not a leap year but is divisible by 4 so if your code matches that logic it would be wrong. Should be (year % 4 == 0) and (year % 100 != 0 or year % 400 == 0) |
|
good catch lol, I changed it so that it looks more like ([divisible by 100 and divisible by 400] and [not divisible by 100 and divisible by 4]) |
|
I don't think this currently builds. I still love the interest and ambition - adding a new scala operator is going straight into the deep end, and I think you're close. For a PR that modifies the scala + fact dictionary, I think you'll want to check that the following steps work:
I learned a lot from diving into this PR. I think I can help if you get stuck, or to pick this up if it feels like too much work. |
|
thank you, I didn't see where the testing was. I was able to get it to work and fix the tests |
|
Better! I still get errors when running One way to make the logic a little easier to follow and avoid the need for nested switch / case statements is to rely on short-circuit evaluation by listing the cases in this order:
Happy to share as an example, but I think you've got this PR so close you deserve the glory for bringing it to a close. |
|
I rewrote it and I think that will work, none of the tests are running for me now so I don't know |
|
Lovely. Spotless complained about the formatting but after running spotless in the backend directory, all the tests passed and I was able to verify correct leap year behavior for 2024 (true), 2025 (false), 2100 (false), and 2400 (true). With those minor revisions, this will be a great first PR for anyone to look at who wants to modify the Direct File fact graph. This is a nice, practical use that covers some gnarly territory. ⭐ Branch with the spotless fixes applied: cjhskippy@f5509e1 |
Fixes error running tests by using `mvn spotless:apply` in the backend directory
|
👍 ty, I cherry picked your commit to this branch |
cjhskippy
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Endorse. This makes me wonder what would have been possible if community engagement could have been part of Direct File's development.
As a former Direct File team member, I'm happy to say it looks like good work to me. 🎉
|
the IRS added modulation in this commit so I'm closing this |
in
constants.xml,isTaxYearLeapYearis hardcoded for 2024 and 2028. this PR adds logic to see if a year is a leap year ([divisible by 4] or [divisible by 100 and 400]). it also adds a modulo operator to the fact graph to accomplish this