Skip to content
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

improve contributors compatibility #99

Merged
merged 4 commits into from
Jun 20, 2018

Conversation

nberard
Copy link
Contributor

@nberard nberard commented Jun 14, 2018

Fix #97 and compatibility with several contributors

Copy link
Contributor

@prhod prhod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ! I've 2 small comments and a question :)

src/gtfs/read.rs Outdated
@@ -744,10 +750,11 @@ fn get_modes_from_gtfs(
.iter()
.map(|mt| get_commercial_mode(mt))
.collect();
let physical_modes = gtfs_mode_types
let physical_modes_set: HashSet<objects::PhysicalMode> = gtfs_mode_types
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should remove the explicit type

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to be there otherwise it gets a vector, we use hashset first to remove duplicate and then transform to a vector for function return

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it cannot infer if he removes the type but he can write HashSet<_>

src/gtfs/read.rs Outdated
.iter()
.map(|mt| get_physical_mode(mt))
.collect();
let physical_modes: Vec<objects::PhysicalMode> = physical_modes_set.into_iter().collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here yes you can remove Vec<objects::PhysicalMode>

}
}

impl Eq for PhysicalMode {}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it ok and useful to declare impl without any function ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it has to be there but i guess it uses the declaration from the trait PartialEq

Eq has no extra methods, it is only informing the compiler that this is an equivalence relation rather than a partial equivalence relation.

see https://doc.rust-lang.org/std/cmp/trait.Eq.html

prhod
prhod previously approved these changes Jun 15, 2018
Copy link
Contributor

@prhod prhod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the reply 👍

src/gtfs/read.rs Outdated
#[derive(Derivative)]
#[derivative(Default(bound = ""))]
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
#[derive(Derivative, Serialize, Deserialize, Debug, Clone, PartialEq, Eq, Hash)]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can add

#[derivative(Default)]

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/gtfs/read.rs Outdated
#[serde(rename = "2")]
StopEntrace,
}

impl Default for StopLocationType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this implementation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

src/gtfs/read.rs Outdated
@@ -744,10 +750,11 @@ fn get_modes_from_gtfs(
.iter()
.map(|mt| get_commercial_mode(mt))
.collect();
let physical_modes = gtfs_mode_types
let physical_modes_set: HashSet<objects::PhysicalMode> = gtfs_mode_types
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it cannot infer if he removes the type but he can write HashSet<_>

src/gtfs/read.rs Outdated
.iter()
.map(|mt| get_physical_mode(mt))
.collect();
let physical_modes: Vec<objects::PhysicalMode> = physical_modes_set.into_iter().collect();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here yes you can remove Vec<objects::PhysicalMode>

@@ -1446,6 +1454,41 @@ mod tests {
});
}

#[test]
fn gtfs_trips_no_direction_id() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this test seems similar to test gtfs_trips() you modify it instead of create a new one

Copy link
Contributor Author

@nberard nberard Jun 15, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as the title says it tests the trips with no column direction_id

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok but in gtfs_trips() there is the same fixture with no direction id.
I thought you might add an assertion.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the trips file with no direction_id for a row does not make the same test as the missing column, that's why i added a new test with a missing column

@nberard nberard force-pushed the fix-96-97-inconsistencies-gtfs2ntfs branch from 079ae8d to 2065388 Compare June 15, 2018 11:15
@nberard nberard changed the title fix tartare issue 529 improve contributors compatibility Jun 15, 2018
src/gtfs/read.rs Outdated
.iter()
.map(|mt| get_physical_mode(mt))
.collect();
let physical_modes = physical_modes_set.into_iter().collect();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let physical_modes = gtfs_mode_types
    .iter()
    .map(|mt| get_physical_mode(mt))
    .collect::<BTreeSet<_>>()
    .into_iter()
    .collect();

BTreeSet because it will have a deterministic order.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order by id? or co2_emission?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

order by Ord

@@ -523,7 +522,7 @@ pub fn read_stops<P: AsRef<path::Path>>(
let comment_links = manage_comment_from_stop(comments, &stop);
let equipment_id = get_equipment_id_and_populate_equipments(equipments, &stop);
match stop.location_type {
StopLocationType::StopArea => {
StopLocationType::StopPoint => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💩

@@ -173,3 +173,15 @@ where
obj.add_prefix(prefix);
}
}

macro_rules! skip_fail {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like this macro: it's too dependent of the context.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should i change the name or just remove the macro?

@nberard nberard force-pushed the fix-96-97-inconsistencies-gtfs2ntfs branch 3 times, most recently from 6d936e4 to bec0150 Compare June 18, 2018 15:17
@datanel datanel merged commit 696dd4d into hove-io:master Jun 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants