OCCRA
Go to Post your robot may have a bit of a "pimpwalk" - GMKlenklen [more]
Home
Go Back   Chief Delphi > Technical > Programming > Python
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
Reply
Thread Tools Rate Thread Display Modes
  #1   Spotlight this post!  
Unread 03-21-2018, 11:55 PM
Danyu Danyu is offline
Registered User
FRC #0195
 
Join Date: Jun 2017
Location: Southington Connecticut
Posts: 13
Danyu is an unknown quantity at this point
Blue alliance api: Match Number

Hi,
I've recently been working on a code for getting data from the blue alliance api. I've been successful in pulling data down, but one of the pieces of data (match number) seems weird. When I create a list just for match number, it prints,

"[1, 2, 1, 2, 1, 2, 3, 1, 2, 1, 2, 3, 1, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 2, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 3, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 4, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 5, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 6, 60, 7, 8, 9, 1, 2, 1, 2]"

I dont understand what happened, can someone explain this to me. Thanks!

numberMatch = []
for match in eventMatches:
numberMatch.append(match.match_number)

print(numberMatch)

That is my code.
Reply With Quote
  #2   Spotlight this post!  
Unread 03-22-2018, 12:15 AM
Brian Maher's Avatar
Brian Maher Brian Maher is offline
Hungry for data
FRC #2791 (Shaker Robotics)
Team Role: College Student
 
Join Date: Apr 2014
Rookie Year: 2012
Location: Troy, NY
Posts: 1,264
Brian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond repute
Re: Blue alliance api: Match Number

I'd recommend you also investigate the "comp_level" attribute.
__________________
2016-present, Mentor, FRC 2791 - Shaker Robotics
2018: Central New York Winner (2791, 340, 5030, 7081), Tech Valley Finalist (2791, 20, 3624, 5123), Darwin Division QF (4946, 2791, 2834, 3461), IRI Invite
2017: Tech Valley Winner (333, 2791, 5952), NYC SF (2791, 2383, 1880), Curie Division QF (2481, 2791, 203, 1807), IRI Invite, Robot Rumble Winner (2791, 5881, 1880)
2016: Tech Valley SF (5236, 2791, 3624), Finger Lakes SF (5254, 2791, 2383), Battlecry Winner (195, 2791, 501), Robot Rumble Winner (2791, 195, 6463)

2012-2015, Student, FRC 1257 - Parallel Universe
2015: Mount Olive QF (1257, 1923, 1811) , North Brunswick Finalist (11, 193, 1257)
2014: Clifton Winner (1626, 869, 1257), MAR CMP QF (1257, 293, 303)
2012: Mount Olive QF (204, 303, 1257)

2017-present, SLFF - Questionable Decisionmakers
2018: Regular Season Finalist, Championship 3rd Place, Fantasy FIM Finalist
2017: Regular Season Winner, Championship Winner, Fantasy FIM Finalist, IRI Winner
Reply With Quote
  #3   Spotlight this post!  
Unread 03-22-2018, 07:31 AM
ColbyG's Avatar
ColbyG ColbyG is offline
Registered User
AKA: Colby
FRC #1777 (Viking Robotics)
Team Role: Programmer
 
Join Date: Aug 2017
Rookie Year: 2018
Location: Kansas City
Posts: 74
ColbyG is just really niceColbyG is just really niceColbyG is just really niceColbyG is just really niceColbyG is just really nice
Re: Blue alliance api: Match Number

You're probably getting qualification #1, elimination #1, quarterfinal #1, semifinal #1, and final #1, and a few more I can't remember. As Brian suggested, use the "comp_level" attribute of each match to find out which type of match each one is.
Reply With Quote
  #4   Spotlight this post!  
Unread 03-22-2018, 07:40 AM
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
FRC #0604 (Quixilver)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 1,058
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Blue alliance api: Match Number

As prior posts have suggested, check out comp_level. Also, take a look at set_number.
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-Present)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App | TBA Blog | TBA Swag
Reply With Quote
  #5   Spotlight this post!  
Unread 03-22-2018, 10:29 PM
Danyu Danyu is offline
Registered User
FRC #0195
 
Join Date: Jun 2017
Location: Southington Connecticut
Posts: 13
Danyu is an unknown quantity at this point
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Brian Maher View Post
I'd recommend you also investigate the "comp_level" attribute.
Do you know if there is a way to change the order of the matches so that it goes qm 1, qm 2... qf1, qf2... sf1, sf2... f1, f2?

Thanks for the reply!
Reply With Quote
  #6   Spotlight this post!  
Unread 03-22-2018, 11:06 PM
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
FRC #0604 (Quixilver)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 1,058
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Danyu View Post
Do you know if there is a way to change the order of the matches so that it goes qm 1, qm 2... qf1, qf2... sf1, sf2... f1, f2?

Thanks for the reply!
No, unfortunately you'll have to sort it yourself.

Maybe we'll sort the output in APIv4...
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-Present)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App | TBA Blog | TBA Swag
Reply With Quote
  #7   Spotlight this post!  
Unread 03-22-2018, 11:41 PM
Danyu Danyu is offline
Registered User
FRC #0195
 
Join Date: Jun 2017
Location: Southington Connecticut
Posts: 13
Danyu is an unknown quantity at this point
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Eugene Fang View Post
No, unfortunately you'll have to sort it yourself.

Maybe we'll sort the output in APIv4...
Im outputting to excel, do you know of a way to sort it from python?

Thanks for the replies!
Reply With Quote
  #8   Spotlight this post!  
Unread 03-22-2018, 11:47 PM
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
FRC #0604 (Quixilver)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 1,058
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Danyu View Post
Im outputting to excel, do you know of a way to sort it from python?

Thanks for the replies!
A Python sort using this as the key will work.

https://github.com/the-blue-alliance.../match.py#L258
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-Present)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App | TBA Blog | TBA Swag
Reply With Quote
  #9   Spotlight this post!  
Unread 03-23-2018, 12:19 AM
Brian Maher's Avatar
Brian Maher Brian Maher is offline
Hungry for data
FRC #2791 (Shaker Robotics)
Team Role: College Student
 
Join Date: Apr 2014
Rookie Year: 2012
Location: Troy, NY
Posts: 1,264
Brian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond reputeBrian Maher has a reputation beyond repute
Re: Blue alliance api: Match Number

An arguable more elegant solution:

Code:
comp_levels = ['qm', 'qf', 'sf', 'f']

def match_order(match):
     return ( comp_levels.index(match['comp_level']), match['match_number'] )

matches.sort(key = match_order)
__________________
2016-present, Mentor, FRC 2791 - Shaker Robotics
2018: Central New York Winner (2791, 340, 5030, 7081), Tech Valley Finalist (2791, 20, 3624, 5123), Darwin Division QF (4946, 2791, 2834, 3461), IRI Invite
2017: Tech Valley Winner (333, 2791, 5952), NYC SF (2791, 2383, 1880), Curie Division QF (2481, 2791, 203, 1807), IRI Invite, Robot Rumble Winner (2791, 5881, 1880)
2016: Tech Valley SF (5236, 2791, 3624), Finger Lakes SF (5254, 2791, 2383), Battlecry Winner (195, 2791, 501), Robot Rumble Winner (2791, 195, 6463)

2012-2015, Student, FRC 1257 - Parallel Universe
2015: Mount Olive QF (1257, 1923, 1811) , North Brunswick Finalist (11, 193, 1257)
2014: Clifton Winner (1626, 869, 1257), MAR CMP QF (1257, 293, 303)
2012: Mount Olive QF (204, 303, 1257)

2017-present, SLFF - Questionable Decisionmakers
2018: Regular Season Finalist, Championship 3rd Place, Fantasy FIM Finalist
2017: Regular Season Winner, Championship Winner, Fantasy FIM Finalist, IRI Winner
Reply With Quote
  #10   Spotlight this post!  
Unread 03-23-2018, 12:22 AM
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
FRC #0604 (Quixilver)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 1,058
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Brian Maher View Post
An arguable more elegant solution:

Code:
comp_levels = ['qm', 'qf', 'sf', 'f']

def match_order(match):
     return ( comp_levels.index(match['comp_level']), match['match_number'] )

matches.sort(key = match_order)
Way more elegant, I never knew sort could take tuples.
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-Present)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App | TBA Blog | TBA Swag
Reply With Quote
  #11   Spotlight this post!  
Unread 03-23-2018, 08:22 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 9,126
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Blue alliance api: Match Number


If you sort the records in each event by the [actual_time] key, then the matches will be in the order you wanted.


Reply With Quote
  #12   Spotlight this post!  
Unread 03-23-2018, 08:28 AM
bdaroz's Avatar
bdaroz bdaroz is offline
Programming Mentor
AKA: Brian Rozmierski
FRC #5881 (TVHS Dragons)
Team Role: Mentor
 
Join Date: Jan 2016
Rookie Year: 2016
Location: Albany, NY
Posts: 833
bdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond reputebdaroz has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Ether View Post

If you sort the records in each event by the [actual_time] key, then the matches will be in the order you wanted.


Except any replays....
Reply With Quote
  #13   Spotlight this post!  
Unread 03-23-2018, 08:40 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 9,126
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Eugene Fang View Post
Way more elegant, I never knew sort could take tuples.
If you sort by ['qm', 'qf', 'sf', 'f'], do you get the correct order for qf1m1 and qf4m1 etc ?



Reply With Quote
  #14   Spotlight this post!  
Unread 03-23-2018, 08:43 AM
Eugene Fang's Avatar
Eugene Fang Eugene Fang is offline
The Blue Alliance
FRC #0604 (Quixilver)
Team Role: Alumni
 
Join Date: Jan 2007
Rookie Year: 2000
Location: Bay Area, CA -> Pittsburgh, PA
Posts: 1,058
Eugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond reputeEugene Fang has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Ether View Post
If you sort by ['qm', 'qf', 'sf', 'f'], do you get the correct order for qf1m1 and qf4m1 etc ?
set_number would need to be included as one of the items in the tuple.

So something like this for play order:
Code:
comp_levels = ['qm', 'ef', 'qf', 'sf', 'f']
matches.sort(key=lambda m: (comp_levels.index(m['comp_level']), m['match_number'], m['set_number']))

And like this for "natural order" (grouped by set):
Code:
comp_levels = ['qm', 'ef', 'qf', 'sf', 'f']
matches.sort(key=lambda m: (comp_levels.index(m['comp_level']), m['set_number'], m['match_number']))
__________________
Eugene Fang
2010 Silicon Valley Regional Dean's List Finalist

Various FLL Teams - Student (2000-2006), Mentor (2007-2010)
FRC Team 604 - Student (2007-2010), Mentor/Remote Advisor (2011-Present)
FRC Team 1323 - Mentor/Remote Advisor (2011-2014)

The Blue Alliance | TBA GameDay | TBA Android App | TBA Blog | TBA Swag

Last edited by Eugene Fang : 03-23-2018 at 08:48 AM.
Reply With Quote
  #15   Spotlight this post!  
Unread 03-23-2018, 09:51 AM
Ether's Avatar
Ether Ether is offline
systems engineer (retired)
no team
 
Join Date: Nov 2009
Rookie Year: 1969
Location: US
Posts: 9,126
Ether has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond reputeEther has a reputation beyond repute
Re: Blue alliance api: Match Number

Quote:
Originally Posted by Eugene Fang View Post

set_number would need to be included as one of the items in the tuple.
You had me wondering about that. Not in the tuple, but in the list of sort keys.


Quote:
So something like this for play order:
Code:
comp_levels = ['qm', 'ef', 'qf', 'sf', 'f']
matches.sort(key=lambda m: (comp_levels.index(m['comp_level']), m['match_number'], m['set_number']))

What is 'ef' ? I don't see it in any of the matches so far.


Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -5. The time now is 12:51 AM.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi