Giter Site home page Giter Site logo

Comments (4)

TomHall2020 avatar TomHall2020 commented on June 13, 2024

I had been looking at this as part of #59 already as I needed to initalise Passes from an already constructed Target object there.
But I agree that it makes sense in general, and possibly should even be the default, as my thought process when working the REPL usually goes something like:

# make a target
>>> t = Target("10_zone", (122, "cm"), (70.0, "m"))

# try and make a pass with it
>>> p = Pass(36, t)
ValueError(...)

# swear, remember I have to recreate the Pass with the same parameters
>>> p = Pass(36, "10_zone", (122, "cm"), (70.0, "m"))

from archeryutils.

jatkinson1000 avatar jatkinson1000 commented on June 13, 2024

OK, My gut suggests doing it as a separate PR, but happy for it to come from #59 given you have already started.
I think having target as default, and then having a pass_from_base_target_data classmethod (not called that, but I can't come up with a more concise but clear name right now) is probably best, as you suggest.

Other option would be overloading, but I think that could get messy given they are mutually exclusive argument options rather than one being a subset.

from archeryutils.

TomHall2020 avatar TomHall2020 commented on June 13, 2024

I agree on a classmethod to replicate the current way of initalising passes makes sense, and consistent with the approaches to initialising Targets in that PR as well (seperate constructors rather than overloading). But not averse to factoring that bit out from there and doing it first to keep the changes more focused, especially given this is another breaking API change for all the tests.

. Naming it is tricky, I'd thought of: Pass.from_scratch, Pass.from_parameters, Pass.without_target. But I don't love any of them. And Pass.from_target_data is potentially confusing with the custom target concepts. How about Pass.and_target or Pass.with_target?
Maybe inspiration will come.

from archeryutils.

TomHall2020 avatar TomHall2020 commented on June 13, 2024

Got an implementation using at_target for the classmethod name, obviously that one open to change but it seems not too bad. Snuck in some useful reprs because trying to check these in the repl without them was deeply unpleasant.

Mini PR incoming.

from archeryutils.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.